diff --git a/card_game/__pycache__/ai.cpython-312.pyc b/card_game/__pycache__/ai.cpython-312.pyc index c12a520..5ed5ead 100644 Binary files a/card_game/__pycache__/ai.cpython-312.pyc and b/card_game/__pycache__/ai.cpython-312.pyc differ diff --git a/card_game/__pycache__/main.cpython-312.pyc b/card_game/__pycache__/main.cpython-312.pyc index 914cab7..3353f0d 100644 Binary files a/card_game/__pycache__/main.cpython-312.pyc and b/card_game/__pycache__/main.cpython-312.pyc differ diff --git a/card_game/ai.py b/card_game/ai.py index 3ed5be2..e9cb433 100644 --- a/card_game/ai.py +++ b/card_game/ai.py @@ -83,19 +83,20 @@ class AIPlayer: actions = [] player = self.battlefield.player - # Frontline units: attack enemy frontline > enemy support > capital + # Frontline units: non-archer attacks enemy support only, archer attacks all for unit in ai.get_frontline_units(): if not unit.can_attack or unit.has_attacked or not ai.can_afford_attack(unit): continue - enemy_front = player.get_frontline_units() - enemy_support = player.get_support_units() - all_enemy = enemy_front + enemy_support - if all_enemy: - killable = [u for u in all_enemy if u.current_hp <= unit.get_effective_attack()] + if unit.is_ranged(): + targets = player.get_frontline_units() + player.get_support_units() + else: + targets = player.get_support_units() + if targets: + killable = [u for u in targets if u.current_hp <= unit.get_effective_attack()] if killable: target = min(killable, key=lambda u: u.current_hp) else: - target = max(all_enemy, key=lambda u: u.get_effective_attack()) + target = max(targets, key=lambda u: u.get_effective_attack()) self.battlefield.resolve_attack(unit, target) actions.append(("attack_unit", unit, target)) else: diff --git a/card_game/main.py b/card_game/main.py index 63a4700..3706aeb 100644 --- a/card_game/main.py +++ b/card_game/main.py @@ -296,8 +296,8 @@ class Game: self.ui.selected_unit = unit self.ui.target_mode = "attack" targets = list(opponent.get_frontline_units()) - targets.extend(opponent.get_support_units()) if unit.is_ranged(): + targets.extend(opponent.get_support_units()) targets.append(("capital", opponent)) self.ui.valid_targets = targets return @@ -310,9 +310,10 @@ class Game: if unit.can_attack and not unit.has_attacked and player.can_afford_attack(unit): self.ui.selected_unit = unit self.ui.target_mode = "attack" - targets = list(opponent.get_frontline_units()) - targets.extend(opponent.get_support_units()) + targets = list(opponent.get_support_units()) targets.append(("capital", opponent)) + if unit.is_ranged(): + targets.extend(opponent.get_frontline_units()) self.ui.valid_targets = targets def _handle_deploy_click(self, pos):