BattleEndHandler.register('PSDK trainer messages') do |handler|
next unless $game_temp.trainer_battle
# Showing trainers
$game_temp.vs_type.times.map do |i|
next handler.scene.visual.battler_sprite(1, -i - 1)
end.compact.each(&:go_in)
ids = [$game_variables[Yuki::Var::Trainer_Battle_ID], $game_variables[Yuki::Var::Second_Trainer_ID]].select { |i| i > 0 }
if handler.logic.battle_result == 0
handler.logic.battle_phase_exp
Audio.bgm_play(*handler.scene.battle_info.victory_bgm)
# Defeat message
ids.each do |id|
handler.scene.display_message_and_wait(text_get(48, id))
end
# Add money
if (v = handler.scene.battle_info.total_money(handler.logic)) > 0
PFM.game_state.add_money(v)
handler.scene.display_message_and_wait(parse_text(18, 60, PFM::Text::TRNAME[0] => $trainer.name, PFM::Text::NUMXR => v.to_s))
end
else
# Victory message
ids.each do |id|
handler.scene.display_message_and_wait(text_get(47, id))
end
end
end