游戏可以运行
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user