游戏可以运行
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -82,36 +82,48 @@ class AIPlayer:
|
|||||||
def _attack(self, ai):
|
def _attack(self, ai):
|
||||||
actions = []
|
actions = []
|
||||||
player = self.battlefield.player
|
player = self.battlefield.player
|
||||||
|
|
||||||
|
# Frontline units: attack enemy frontline > enemy support > capital
|
||||||
for unit in ai.get_frontline_units():
|
for unit in ai.get_frontline_units():
|
||||||
if not unit.can_attack or unit.has_attacked:
|
if not unit.can_attack or unit.has_attacked:
|
||||||
continue
|
continue
|
||||||
enemy_units = player.get_frontline_units()
|
enemy_front = player.get_frontline_units()
|
||||||
if enemy_units:
|
enemy_support = player.get_support_units()
|
||||||
killable = [u for u in enemy_units if u.current_hp <= unit.get_effective_attack()]
|
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 killable:
|
if killable:
|
||||||
target = min(killable, key=lambda u: u.current_hp)
|
target = min(killable, key=lambda u: u.current_hp)
|
||||||
else:
|
else:
|
||||||
target = max(enemy_units, key=lambda u: u.get_effective_attack())
|
target = max(all_enemy, key=lambda u: u.get_effective_attack())
|
||||||
dead = self.battlefield.resolve_attack(unit, target)
|
|
||||||
actions.append(("attack_unit", unit, target))
|
|
||||||
else:
|
|
||||||
self.battlefield.attack_capital(unit)
|
|
||||||
actions.append(("attack_capital", unit))
|
|
||||||
|
|
||||||
# Ranged units in support attack
|
|
||||||
for unit in ai.get_support_units():
|
|
||||||
if not unit.can_attack or unit.has_attacked or not unit.is_ranged():
|
|
||||||
continue
|
|
||||||
enemy_units = player.get_frontline_units()
|
|
||||||
if enemy_units:
|
|
||||||
killable = [u for u in enemy_units if u.current_hp <= unit.get_effective_attack()]
|
|
||||||
target = min(killable, key=lambda u: u.current_hp) if killable else min(enemy_units, key=lambda u: u.current_hp)
|
|
||||||
self.battlefield.resolve_attack(unit, target)
|
self.battlefield.resolve_attack(unit, target)
|
||||||
actions.append(("attack_unit", unit, target))
|
actions.append(("attack_unit", unit, target))
|
||||||
else:
|
else:
|
||||||
self.battlefield.attack_capital(unit)
|
self.battlefield.attack_capital(unit)
|
||||||
actions.append(("attack_capital", unit))
|
actions.append(("attack_capital", unit))
|
||||||
|
|
||||||
|
# Support units: attack enemy frontline > enemy support > capital (ranged only)
|
||||||
|
for unit in ai.get_support_units():
|
||||||
|
if not unit.can_attack or unit.has_attacked:
|
||||||
|
continue
|
||||||
|
enemy_front = player.get_frontline_units()
|
||||||
|
enemy_support = player.get_support_units()
|
||||||
|
if unit.is_ranged():
|
||||||
|
all_enemy = enemy_front + enemy_support
|
||||||
|
if all_enemy:
|
||||||
|
killable = [u for u in all_enemy if u.current_hp <= unit.get_effective_attack()]
|
||||||
|
target = min(killable, key=lambda u: u.current_hp) if killable else min(all_enemy, key=lambda u: u.current_hp)
|
||||||
|
self.battlefield.resolve_attack(unit, target)
|
||||||
|
actions.append(("attack_unit", unit, target))
|
||||||
|
else:
|
||||||
|
self.battlefield.attack_capital(unit)
|
||||||
|
actions.append(("attack_capital", unit))
|
||||||
|
elif enemy_front:
|
||||||
|
killable = [u for u in enemy_front if u.current_hp <= unit.get_effective_attack()]
|
||||||
|
target = min(killable, key=lambda u: u.current_hp) if killable else min(enemy_front, key=lambda u: u.current_hp)
|
||||||
|
self.battlefield.resolve_attack(unit, target)
|
||||||
|
actions.append(("attack_unit", unit, target))
|
||||||
|
|
||||||
return actions
|
return actions
|
||||||
|
|
||||||
def _handle_deploy(self, card, ai):
|
def _handle_deploy(self, card, ai):
|
||||||
|
|||||||
@@ -267,10 +267,12 @@ class Game:
|
|||||||
opponent = self.battlefield.get_opponent(player)
|
opponent = self.battlefield.get_opponent(player)
|
||||||
|
|
||||||
if unit.zone == "support":
|
if unit.zone == "support":
|
||||||
if unit.can_attack and not unit.has_attacked and unit.is_ranged():
|
if unit.can_attack and not unit.has_attacked:
|
||||||
self.ui.selected_unit = unit
|
self.ui.selected_unit = unit
|
||||||
self.ui.target_mode = "attack"
|
self.ui.target_mode = "attack"
|
||||||
targets = list(opponent.get_frontline_units())
|
targets = list(opponent.get_frontline_units())
|
||||||
|
targets.extend(opponent.get_support_units())
|
||||||
|
if unit.is_ranged():
|
||||||
targets.append(("capital", opponent))
|
targets.append(("capital", opponent))
|
||||||
self.ui.valid_targets = targets
|
self.ui.valid_targets = targets
|
||||||
return
|
return
|
||||||
@@ -284,6 +286,7 @@ class Game:
|
|||||||
self.ui.selected_unit = unit
|
self.ui.selected_unit = unit
|
||||||
self.ui.target_mode = "attack"
|
self.ui.target_mode = "attack"
|
||||||
targets = list(opponent.get_frontline_units())
|
targets = list(opponent.get_frontline_units())
|
||||||
|
targets.extend(opponent.get_support_units())
|
||||||
targets.append(("capital", opponent))
|
targets.append(("capital", opponent))
|
||||||
self.ui.valid_targets = targets
|
self.ui.valid_targets = targets
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class Player:
|
|||||||
unit.reset_turn_flags()
|
unit.reset_turn_flags()
|
||||||
if unit.zone == "frontline" and unit.turn_played < turn_number:
|
if unit.zone == "frontline" and unit.turn_played < turn_number:
|
||||||
unit.can_attack = True
|
unit.can_attack = True
|
||||||
if unit.zone == "support" and unit.is_ranged() and unit.turn_played < turn_number:
|
if unit.zone == "support" and unit.turn_played < turn_number:
|
||||||
unit.can_attack = True
|
unit.can_attack = True
|
||||||
|
|
||||||
# Chu healer
|
# Chu healer
|
||||||
|
|||||||
35
saved_decks/qi.json
Normal file
35
saved_decks/qi.json
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"faction": "qi",
|
||||||
|
"cards": [
|
||||||
|
"qi_tongshang",
|
||||||
|
"qi_tongshang",
|
||||||
|
"qi_tongshang",
|
||||||
|
"qi_changgong",
|
||||||
|
"qi_changgong",
|
||||||
|
"qi_changgong",
|
||||||
|
"qi_guanzhong",
|
||||||
|
"qi_guanzhong",
|
||||||
|
"qi_jiji",
|
||||||
|
"qi_jiji",
|
||||||
|
"qi_jiji",
|
||||||
|
"qi_shangren",
|
||||||
|
"qi_shangren",
|
||||||
|
"qi_shangren",
|
||||||
|
"qi_sunbin",
|
||||||
|
"qi_sunbin",
|
||||||
|
"qi_gongshou",
|
||||||
|
"qi_gongshou",
|
||||||
|
"qi_gongshou",
|
||||||
|
"qi_maobing",
|
||||||
|
"qi_maobing",
|
||||||
|
"qi_maobing",
|
||||||
|
"qi_fuguo",
|
||||||
|
"qi_tianqi",
|
||||||
|
"qi_tianqi",
|
||||||
|
"ally_wu_shuijun",
|
||||||
|
"ally_wu_shuijun",
|
||||||
|
"ally_wu_shuijun",
|
||||||
|
"ally_yue_nvjian",
|
||||||
|
"ally_yue_nvjian"
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user