Exemplo n.º 1
0
 def analyse_enemy_damage(self, enemy_ship):
     if self.enemy_was_damaged:
         enemy_has_surface = bool(
             ServiceOrder.get_surface_order(
                 self.current_turn_opponent_orders))
         enemy_has_torpedo = bool(
             ServiceOrder.get_attack_order(
                 self.current_turn_opponent_orders))
         enemy_has_trigger = bool(
             ServiceOrder.get_trigger_order(
                 self.current_turn_opponent_orders))
         own_ship_has_shooted = bool(
             ServiceOrder.get_attack_order(self.last_turn_own_orders))
         if own_ship_has_shooted:
             if not (enemy_has_surface or enemy_has_torpedo
                     or enemy_has_trigger):
                 self.enemy_was_hit_last_turn(enemy_ship)
         return
     # Case first turn
     elif self.last_turn_own_orders is None:
         return
     # Case damage taken but not because of our own torpedo (Surface or enemy torpedo)
     elif not ServiceOrder.get_attack_order(self.last_turn_own_orders):
         return
     # Case I shot a torpedo but did not hit
     else:
         attack_order = ServiceOrder.get_attack_order(
             self.last_turn_own_orders)
         position_torpedo = ServiceOrder.get_position_from_attack_order(
             attack_order)
         enemy_ship.enemy_board.update_board_torpedo_did_not_hit_in_position(
             position_torpedo, enemy_ship.delta_position)
Exemplo n.º 2
0
 def read_opponent_order(self, enemy_ship):
     if self.current_turn_opponent_orders == "NA":
         return
     list_orders = ServiceOrder.split_orders(
         self.current_turn_opponent_orders)
     for order in list_orders:
         silence_order = ServiceOrder.get_silence_order(order)
         if bool(silence_order):
             self.analyse_opponent_silence_order(enemy_ship)
         move_order = ServiceOrder.get_move_order(order)
         if bool(move_order):
             self.analyse_opponent_move_order(enemy_ship, move_order)
         surface_order = ServiceOrder.get_surface_order(order)
         if bool(surface_order):
             self.analyse_opponent_surface_order(enemy_ship, surface_order)
         attack_order = ServiceOrder.get_attack_order(order)
         if bool(attack_order):
             self.analyse_opponent_attack_order(enemy_ship, attack_order)