Compare commits
1 Commits
34ce39930c
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 3df3e4f560 |
Binary file not shown.
Binary file not shown.
@@ -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:
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user