Class: TrialBattleUpdater
- Inherits:
-
Object
- Object
- TrialBattleUpdater
- Defined in:
- app/models/trial_battle_updater.rb
Overview
This class is updater of Battle in Trial.
Constant Summary
- BASE_MOD =
Modifier value if no parameter is provided.
1
Class Method Summary (collapse)
Class Method Details
+ (Object) execute(move_turn, atk_squad, def_squad, distance)
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'app/models/trial_battle_updater.rb', line 7 def self.execute(move_turn, atk_squad, def_squad, distance) p "Battle of " + atk_squad.id.to_s + "," + def_squad.id.to_s + "," + distance.to_s # Set-up phase atk_squad.mobs.each do |mob| mob.enemy_mobs = def_squad.mobs mob.friend_mobs = atk_squad.mobs mob.attacker = true mob.hate = 0 if mob.forward_job? mob.vpos = Params::BATTLE_START_ATK_VPOS + 1 else mob.vpos = Params::BATTLE_START_ATK_VPOS end end def_squad.mobs.each do |mob| mob.enemy_mobs = atk_squad.mobs mob.friend_mobs = def_squad.mobs mob.attacker = false mob.hate = 0 if mob.forward_job? mob.vpos = Params::BATTLE_START_DEF_VPOS - 1 else mob.vpos = Params::BATTLE_START_DEF_VPOS end end battle_ended_flg = false loop_index = 0 until battle_ended_flg sorted_by_dex_mobs = Tools.sort_by_dex(atk_squad.mobs + def_squad.mobs) sorted_by_dex_mobs.each do |mob| next if mob.dead? or mob.retreated_from_battle? if atk_squad.annihilated? or atk_squad.retreated_from_battle? p "atk_squad was defeated." battle_ended_flg = true break elsif def_squad.annihilated? or def_squad.retreated_from_battle? p "def_squad was defeated." battle_ended_flg = true break end # DoT / HoT execution phase # Battle phase if distance > 1 # Ranged attack else # Vertical move print mob.attacker.to_s + " " + mob.name_with_job + " pre-move:" + mob.vpos.to_s mob.vpos_move print " post-move:" + mob.vpos.to_s + "\n" battle_method = mob.battle_action next if battle_method.blank? if battle_method.battle_type == :weapon phys_attack(move_turn, mob) else if battle_method.method.type_symbol == :dd.to_s or battle_method.method.type_symbol == :dot.to_s skill_attack(move_turn, mob, battle_method.method) elsif battle_method.method.type_symbol == :debuff.to_s skill_debuff(move_turn, mob, battle_method.method) elsif battle_method.method.type_symbol == :hd.to_s or battle_method.method.type_symbol == :hot.to_s skill_heal(move_turn, mob, battle_method.method) elsif battle_method.method.type_symbol == :buff.to_s skill_buff(move_turn, mob, battle_method.method) elsif battle_method.method.type_symbol == :other.to_s skill_other(move_turn, mob, battle_method.method) end end end end loop_index += 1 battle_ended_flg = true if loop_index > 100 end end |