if pc . countitem ( "50050" ) < 1 then 
say_title ( gameforge . horse_exchange_ticket . _20_sayTitle ) 
say ( gameforge . pony_levelup . _530_say ) 
setstate ( "need_item50050" ) 
elseif horse . get_stamina_pct ( ) <= 10 then 
say_title ( gameforge . horse_exchange_ticket . _20_sayTitle ) 
say ( gameforge . pony_levelup . _550_say ) 
elseif horse . get_health_pct ( ) <= 10 then 
say_title ( gameforge . horse_exchange_ticket . _20_sayTitle ) 
say ( gameforge . pony_levelup . _560_say ) 
elseif horse . get_level ( ) == 10 then 
say_title ( gameforge . horse_exchange_ticket . _20_sayTitle ) 
say ( gameforge . pony_levelup . _570_say ) 
elseif horse . is_riding ( ) == 0 then 
say_title ( gameforge . horse_exchange_ticket . _20_sayTitle ) 
say ( gameforge . pony_levelup . _580_say ) 
elseif ( horse . get_level ( ) >= 8 and horse . get_level ( ) <= 9 ) then 
say_title ( gameforge . horse_exchange_ticket . _20_sayTitle ) 
say ( gameforge . pony_levelup . _590_say ) 
if is_test_server ( ) then 
pc . setqf ( "next_time" , get_time ( ) + 10 ) 
else 
pc . setqf ( "next_time" , get_time ( ) + number ( 12 , 24 ) * 60 * 60 ) 
end 
if is_test_server ( ) then 
local s = select ( "1 val(1) 12.50%" , "2 val(1) 12.50%" , "3 val(1) 12.50%" , "4 val(1) 12.50%" , "5 val(1) 12.50%" , "6 val(1) 12.50%" , "7 val(1) 12.50%" , "8 val(1) 12.50%" ) 
if 1 == s then 
setstate ( "training_frame_red_step1" ) 
elseif 2 == s then 
setstate ( "training_frame_blue_step1" ) 
elseif 3 == s then 
setstate ( "training_frame_yellow_step1" ) 
elseif 4 == s then 
setstate ( "training_frame_purple_step1" ) 
elseif 5 == s then 
setstate ( "training_frame_white_step1" ) 
elseif 6 == s then 
setstate ( "training_snow_red_step1" ) 
elseif 7 == s then 
setstate ( "training_snow_blue_step1" ) 
elseif 8 == s then 
setstate ( "training_snow_yellow_step1" ) 
end 
else 
local s = number ( 1 , 8 ) 
if 1 >= s then 
setstate ( "training_frame_red_step1" ) 
elseif 2 >= s then 
setstate ( "training_frame_blue_step1" ) 
elseif 3 >= s then 
setstate ( "training_frame_yellow_step1" ) 
elseif 4 >= s then 
setstate ( "training_frame_purple_step1" ) 
elseif 5 >= s then 
setstate ( "training_frame_white_step1" ) 
elseif 6 >= s then 
setstate ( "training_snow_red_step1" ) 
elseif 7 >= s then 
setstate ( "training_snow_blue_step1" ) 
elseif 8 >= s then 
setstate ( "training_snow_yellow_step1" ) 
end 
end 
elseif ( horse . get_level ( ) >= 6 and horse . get_level ( ) <= 7 ) then 
say_title ( gameforge . horse_exchange_ticket . _20_sayTitle ) 
say ( gameforge . pony_levelup . _620_say ) 
if is_test_server ( ) then 
pc . setqf ( "next_time" , get_time ( ) + 10 ) 
else 
pc . setqf ( "next_time" , get_time ( ) + number ( 12 , 24 ) * 60 * 60 ) 
end 
if is_test_server ( ) then 
local s = select ( "1 choose(1) 11.11%" , "2 choose(1) 11.11%" , "3 choose(1) 11.11%" , "4 choose(1) 11.11%" , "5 choose(1) 11.11%" , "6 choose(1) 11.11%" , "7 choose(1) 11.11%" , "8 choose(1) 11.11%" , "9 choose(1) 11.11%" ) 
if 1 == s then 
setstate ( "training_valley_red_step1" ) 
elseif 2 == s then 
setstate ( "training_valley_blue_step1" ) 
elseif 3 == s then 
setstate ( "training_valley_yellow_step1" ) 
elseif 4 == s then 
setstate ( "training_desert_red_step1" ) 
elseif 5 == s then 
setstate ( "training_desert_blue_step1" ) 
elseif 6 == s then 
setstate ( "training_desert_yellow_step1" ) 
elseif 7 == s then 
setstate ( "training_desert_purple_step1" ) 
elseif 8 == s then 
setstate ( "training_desert_white_step1" ) 
elseif 9 == s then 
setstate ( "training_desert_sky_step1" ) 
end 
else 
local s = number ( 1 , 9 ) 
if 1 >= s then 
setstate ( "training_valley_red_step1" ) 
elseif 2 >= s then 
setstate ( "training_valley_blue_step1" ) 
elseif 3 >= s then 
setstate ( "training_valley_yellow_step1" ) 
elseif 4 >= s then 
setstate ( "training_desert_red_step1" ) 
elseif 5 >= s then 
setstate ( "training_desert_blue_step1" ) 
elseif 6 >= s then 
setstate ( "training_desert_yellow_step1" ) 
elseif 7 >= s then 
setstate ( "training_desert_purple_step1" ) 
elseif 8 >= s then 
setstate ( "training_desert_white_step1" ) 
elseif 9 >= s then 
setstate ( "training_desert_sky_step1" ) 
end 
end 
elseif ( horse . get_level ( ) >= 3 and horse . get_level ( ) <= 5 ) then 
say_title ( gameforge . horse_exchange_ticket . _20_sayTitle ) 
say ( gameforge . pony_levelup . _650_say ) 
if is_test_server ( ) then 
pc . setqf ( "next_time" , get_time ( ) + 10 ) 
else 
pc . setqf ( "next_time" , get_time ( ) + number ( 12 , 24 ) * 60 * 60 ) 
end 
if pc . get_empire ( ) == 1 then 
if is_test_server ( ) then 
local s = select ( "1 choose(1) 25.00%" , "2 choose(1) 25.00%" , "3 choose(1) 25.00%" , "4 choose(1) 25.00%" ) 
if 1 == s then 
setstate ( "training1_normal1" ) 
elseif 2 == s then 
setstate ( "training1_normal2" ) 
elseif 3 == s then 
setstate ( "training1_normal3" ) 
elseif 4 == s then 
setstate ( "training1_normal4" ) 
end 
else 
local s = number ( 1 , 4 ) 
if 1 >= s then 
setstate ( "training1_normal1" ) 
elseif 2 >= s then 
setstate ( "training1_normal2" ) 
elseif 3 >= s then 
setstate ( "training1_normal3" ) 
elseif 4 >= s then 
setstate ( "training1_normal4" ) 
end 
end 
elseif pc . get_empire ( ) == 2 then 
if is_test_server ( ) then 
local s = select ( "1 choose(1) 25.00%" , "2 choose(1) 25.00%" , "3 choose(1) 25.00%" , "4 choose(1) 25.00%" ) 
if 1 == s then 
setstate ( "training2_normal1" ) 
elseif 2 == s then 
setstate ( "training2_normal2" ) 
elseif 3 == s then 
setstate ( "training2_normal3" ) 
elseif 4 == s then 
setstate ( "training2_normal4" ) 
end 
else 
local s = number ( 1 , 4 ) 
if 1 >= s then 
setstate ( "training2_normal1" ) 
elseif 2 >= s then 
setstate ( "training2_normal2" ) 
elseif 3 >= s then 
setstate ( "training2_normal3" ) 
elseif 4 >= s then 
setstate ( "training2_normal4" ) 
end 
end 
elseif pc . get_empire ( ) == 3 then 
if is_test_server ( ) then 
local s = select ( "1 choose(1) 25.00%" , "2 choose(1) 25.00%" , "3 choose(1) 25.00%" , "4 choose(1) 25.00%" ) 
if 1 == s then 
setstate ( "training3_normal1" ) 
elseif 2 == s then 
setstate ( "training3_normal2" ) 
elseif 3 == s then 
setstate ( "training3_normal3" ) 
elseif 4 == s then 
setstate ( "training3_normal4" ) 
end 
else 
local s = number ( 1 , 4 ) 
if 1 >= s then 
setstate ( "training3_normal1" ) 
elseif 2 >= s then 
setstate ( "training3_normal2" ) 
elseif 3 >= s then 
setstate ( "training3_normal3" ) 
elseif 4 >= s then 
setstate ( "training3_normal4" ) 
end 
end 
end 
elseif ( horse . get_level ( ) >= 1 and horse . get_level ( ) <= 2 ) then 
say_title ( gameforge . horse_exchange_ticket . _20_sayTitle ) 
say ( gameforge . pony_levelup . _680_say ) 
if is_test_server ( ) then 
pc . setqf ( "next_time" , get_time ( ) + 10 ) 
else 
pc . setqf ( "next_time" , get_time ( ) + number ( 12 , 24 ) * 60 * 60 ) 
end 
if pc . get_empire ( ) == 1 then 
if is_test_server ( ) then 
local s = select ( "1 val(1) 25.00%" , "2 val(1) 25.00%" , "3 val(1) 25.00%" , "4 val(1) 25.00%" ) 
if 1 == s then 
setstate ( "training1_easy1" ) 
elseif 2 == s then 
setstate ( "training1_easy2" ) 
elseif 3 == s then 
setstate ( "training1_easy3" ) 
elseif 4 == s then 
setstate ( "training1_easy4" ) 
end 
else 
local s = number ( 1 , 4 ) 
if 1 >= s then 
setstate ( "training1_easy1" ) 
elseif 2 >= s then 
setstate ( "training1_easy2" ) 
elseif 3 >= s then 
setstate ( "training1_easy3" ) 
elseif 4 >= s then 
setstate ( "training1_easy4" ) 
end 
end 
elseif pc . get_empire ( ) == 2 then 
if is_test_server ( ) then 
local s = select ( "1 val(1) 25.00%" , "2 val(1) 25.00%" , "3 val(1) 25.00%" , "4 val(1) 25.00%" ) 
if 1 == s then 
setstate ( "training2_easy1" ) 
elseif 2 == s then 
setstate ( "training2_easy2" ) 
elseif 3 == s then 
setstate ( "training2_easy3" ) 
elseif 4 == s then 
setstate ( "training2_easy4" ) 
end 
else 
local s = number ( 1 , 4 ) 
if 1 >= s then 
setstate ( "training2_easy1" ) 
elseif 2 >= s then 
setstate ( "training2_easy2" ) 
elseif 3 >= s then 
setstate ( "training2_easy3" ) 
elseif 4 >= s then 
setstate ( "training2_easy4" ) 
end 
end 
elseif pc . get_empire ( ) == 3 then 
if is_test_server ( ) then 
local s = select ( "1 val(1) 25.00%" , "2 val(1) 25.00%" , "3 val(1) 25.00%" , "4 val(1) 25.00%" ) 
if 1 == s then 
setstate ( "training3_easy1" ) 
elseif 2 == s then 
setstate ( "training3_easy2" ) 
elseif 3 == s then 
setstate ( "training3_easy3" ) 
elseif 4 == s then 
setstate ( "training3_easy4" ) 
end 
else 
local s = number ( 1 , 4 ) 
if 1 >= s then 
setstate ( "training3_easy1" ) 
elseif 2 >= s then 
setstate ( "training3_easy2" ) 
elseif 3 >= s then 
setstate ( "training3_easy3" ) 
elseif 4 >= s then 
setstate ( "training3_easy4" ) 
end 
end 
end 
else 
say ( gameforge . pony_levelup . _690_say ) 
end 
