def execute(self, unit_orders, end_action, turn_count): self.end_action = end_action self.grid.reset_cell_colors() self.orders = unit_orders FloatingText.create_new( FloatingText("ROUND %d" % turn_count, (suie.SCREEN_WIDTH // 2 - 80, 150), (255, 255, 255), font_size=20)) self._generate_info() Timer.create_new(Timer(2000, self.stage1))
def _select_action(self, action): active_units = self.left_units if self.active == "left" else self.right_units if self.current_phase == BattlePhase.ORDER: if action == BattleAction.ATTACK: self.current_phase = BattlePhase.TARGET FloatingText.create_new(FloatingText("attack", self.selected_avatar.sprite.get_center(), [255] * 4)) self.selected_action = BattleAction.ATTACK self._update_panels() elif action == BattleAction.DEFEND: self.current_phase = BattlePhase.TARGET FloatingText.create_new(FloatingText("defend", self.selected_avatar.sprite.get_center(), [255] * 4)) self.selected_action = BattleAction.DEFEND self._update_panels() elif action == BattleAction.NEXT_UNIT: empty_unit = False for unit in active_units: if not unit in self.unit_orders: empty_unit = True if not empty_unit: self._end_turn() return if not self.selected_avatar: self._select_avatar(active_units[0]) else: index = active_units.index(self.selected_avatar) index += 1 if index < (len(active_units) - 1) else -index self._select_avatar(active_units[index]) elif action == BattleAction.GUARD: FloatingText.create_new(FloatingText("guard", self.selected_avatar.sprite.get_center(), [255] * 4)) x, y = self.selected_avatar.sprite.get_center() self.action_sfx = SFX('assets/sfx/shield.png', (10, 1), (64, 64), (x - 10, y - 50), 0, 9, frame_speed=80) self.unit_orders[self.selected_avatar] = { "order": BattleAction.GUARD, "target": None } self._select_action(BattleAction.NEXT_UNIT) elif self.current_phase == BattlePhase.TARGET: if action == BattleAction.CANCEL: self.current_phase = BattlePhase.ORDER self._update_panels()