Anonymous committed 5d26a3e

refactored the computer action into its own method.

  • Participants
  • Parent commits 4972e09

Comments (0)

Files changed (1)


         # let the computer act
+    def computer_action(self, char):
+        """Let the selected char act once."""
+        target = char.best_target_hex()
+        char.move_to_hex(*target)
+        char.attack_best_target_if_possible()
+        self._initiative_step_current()
     def computer_turn(self):
         """Let the computer act once."""
         # game end condition
                           description="the player character who can act now")
         # otherwise battle on :)
-        target = next_char.best_target_hex()
-        next_char.move_to_hex(*target)
-        next_char.attack_best_target_if_possible()
-        self._initiative_step_current()
+        self.computer_action(next_char)
         self.phase["player"] = "wait"
         # TODO: return the result of the action instead. Or at least a list of changed characters. Best a list of all characters who changed state and how they changed state.
         return Result("step", commands=[Command(self.switch_to_cpu_turn, "continue")])