游戏可以运行

This commit is contained in:
2026-05-24 09:05:39 +08:00
parent ef564338a6
commit a8c5fb2356
8 changed files with 43 additions and 44 deletions

View File

@@ -106,8 +106,7 @@ class Battlefield:
if owner and owner.faction_id == "qin":
owner.provisions += 1
if "no_retaliation" not in attacker.abilities:
if not (attacker.is_ranged() and attacker.zone == "support"):
if "no_retaliation" not in attacker.abilities and not attacker.is_ranged():
retal = defender.get_effective_defense() if defender.is_alive() else 0
if retal > 0:
attacker.take_damage(retal)

View File

@@ -60,10 +60,10 @@ class Card:
self.buffs = [(a, d, t - 1) for a, d, t in self.buffs if t > 1]
def can_move_and_attack(self):
return "charge" in self.abilities
return self.unit_type == "cavalry" or "charge" in self.abilities
def is_ranged(self):
return "ranged" in self.abilities
return self.unit_type == "archer" or "ranged" in self.abilities
def get_keywords(self):
result = []

View File

@@ -108,7 +108,7 @@ RARITY_LIMITS = {
}
# --- Unit Types ---
UNIT_TYPES = ["infantry", "cavalry", "chariot", "archer", "siege"]
UNIT_TYPES = ["infantry", "cavalry", "archer"]
# ============================================================
# CARD DATABASE
@@ -142,7 +142,7 @@ CARD_DATABASE = {
"defense": 2,
"max_hp": 2,
"description": "弓手·可从营地射击",
"abilities": ["ranged"],
"abilities": [],
"rarity": "common",
},
"qin_bubing": {
@@ -172,7 +172,7 @@ CARD_DATABASE = {
"defense": 2,
"max_hp": 2,
"description": "骑兵·冲锋",
"abilities": ["charge"],
"abilities": [],
"rarity": "common",
},
"qin_gongcheng": {
@@ -180,14 +180,14 @@ CARD_DATABASE = {
"name": "攻城弩",
"faction": "qin",
"type": "unit",
"unit_type": "siege",
"unit_type": "archer",
"cost": 5,
"op_cost": 2,
"attack": 3,
"defense": 1,
"max_hp": 3,
"description": "攻城·对都城双倍伤害",
"abilities": ["siege", "ranged"],
"abilities": ["siege"],
"rarity": "rare",
},
"qin_shangyang": {
@@ -250,7 +250,7 @@ CARD_DATABASE = {
"defense": 2,
"max_hp": 3,
"description": "弓手·可从营地射击",
"abilities": ["ranged"],
"abilities": [],
"rarity": "common",
},
"qin_ruiqi": {
@@ -265,7 +265,7 @@ CARD_DATABASE = {
"defense": 2,
"max_hp": 2,
"description": "骑兵·冲锋",
"abilities": ["charge"],
"abilities": [],
"rarity": "common",
},
"qin_fangzhen": {
@@ -339,7 +339,7 @@ CARD_DATABASE = {
"defense": 2,
"max_hp": 2,
"description": "弓手·可从营地射击",
"abilities": ["ranged"],
"abilities": [],
"rarity": "common",
},
"qi_tianqi": {
@@ -347,7 +347,7 @@ CARD_DATABASE = {
"name": "天齐战车",
"faction": "qi",
"type": "unit",
"unit_type": "chariot",
"unit_type": "infantry",
"cost": 5,
"op_cost": 2,
"attack": 4,
@@ -417,7 +417,7 @@ CARD_DATABASE = {
"defense": 2,
"max_hp": 2,
"description": "弓手·可从营地射击",
"abilities": ["ranged"],
"abilities": [],
"rarity": "common",
},
"qi_shangdui": {
@@ -506,7 +506,7 @@ CARD_DATABASE = {
"defense": 3,
"max_hp": 3,
"description": "弓手·可从营地射击",
"abilities": ["ranged"],
"abilities": [],
"rarity": "common",
},
"chu_zhancha": {
@@ -514,7 +514,7 @@ CARD_DATABASE = {
"name": "楚战车",
"faction": "chu",
"type": "unit",
"unit_type": "chariot",
"unit_type": "infantry",
"cost": 5,
"op_cost": 2,
"attack": 4,
@@ -584,7 +584,7 @@ CARD_DATABASE = {
"defense": 2,
"max_hp": 2,
"description": "骑兵·冲锋",
"abilities": ["charge"],
"abilities": [],
"rarity": "common",
},
"chu_nushou": {
@@ -599,7 +599,7 @@ CARD_DATABASE = {
"defense": 2,
"max_hp": 2,
"description": "弓手·可从营地射击",
"abilities": ["ranged"],
"abilities": [],
"rarity": "common",
},
"chu_wuzhu2": {
@@ -643,7 +643,7 @@ CARD_DATABASE = {
"defense": 1,
"max_hp": 2,
"description": "骑兵·行动费用-1",
"abilities": ["charge"],
"abilities": [],
"rarity": "common",
},
"yan_cike": {
@@ -688,7 +688,7 @@ CARD_DATABASE = {
"defense": 2,
"max_hp": 2,
"description": "弓手·可从营地射击",
"abilities": ["ranged"],
"abilities": [],
"rarity": "common",
},
"yan_jingke": {
@@ -766,7 +766,7 @@ CARD_DATABASE = {
"defense": 1,
"max_hp": 2,
"description": "骑兵·冲锋·行动费用-1",
"abilities": ["charge"],
"abilities": [],
"rarity": "common",
},
"yan_chihou": {
@@ -822,7 +822,7 @@ CARD_DATABASE = {
"defense": 3,
"max_hp": 3,
"description": "弓手·可从营地射击",
"abilities": ["ranged"],
"abilities": [],
"rarity": "common",
},
"han_shushi": {
@@ -867,7 +867,7 @@ CARD_DATABASE = {
"defense": 2,
"max_hp": 3,
"description": "骑兵·冲锋",
"abilities": ["charge"],
"abilities": [],
"rarity": "common",
},
"han_weiwei": {
@@ -930,7 +930,7 @@ CARD_DATABASE = {
"defense": 3,
"max_hp": 3,
"description": "弓手·可从营地射击",
"abilities": ["ranged"],
"abilities": [],
"rarity": "common",
},
"han_tiejiang": {
@@ -989,7 +989,7 @@ CARD_DATABASE = {
"defense": 2,
"max_hp": 2,
"description": "骑兵·冲锋",
"abilities": ["charge"],
"abilities": [],
"rarity": "common",
},
"zhao_tieqi": {
@@ -1004,7 +1004,7 @@ CARD_DATABASE = {
"defense": 3,
"max_hp": 4,
"description": "骑兵·无视报复",
"abilities": ["charge", "no_retaliation"],
"abilities": ["no_retaliation"],
"rarity": "rare",
},
"zhao_bubing": {
@@ -1034,7 +1034,7 @@ CARD_DATABASE = {
"defense": 2,
"max_hp": 2,
"description": "弓手·可从营地射击",
"abilities": ["ranged"],
"abilities": [],
"rarity": "common",
},
"zhao_qixi": {
@@ -1097,7 +1097,7 @@ CARD_DATABASE = {
"defense": 2,
"max_hp": 3,
"description": "骑兵·冲锋",
"abilities": ["charge"],
"abilities": [],
"rarity": "common",
},
"zhao_gongshou2": {
@@ -1112,7 +1112,7 @@ CARD_DATABASE = {
"defense": 2,
"max_hp": 2,
"description": "弓手·可从营地射击",
"abilities": ["ranged"],
"abilities": [],
"rarity": "common",
},
"zhao_qiangbing": {
@@ -1186,7 +1186,7 @@ CARD_DATABASE = {
"defense": 2,
"max_hp": 2,
"description": "弓手·可从营地射击",
"abilities": ["ranged"],
"abilities": [],
"rarity": "common",
},
"wei_qibing": {
@@ -1201,7 +1201,7 @@ CARD_DATABASE = {
"defense": 2,
"max_hp": 3,
"description": "骑兵·冲锋",
"abilities": ["charge"],
"abilities": [],
"rarity": "common",
},
"wei_zhengjun": {
@@ -1279,7 +1279,7 @@ CARD_DATABASE = {
"defense": 3,
"max_hp": 3,
"description": "弓手·可从营地射击",
"abilities": ["ranged"],
"abilities": [],
"rarity": "common",
},
"wei_zhancha": {
@@ -1287,7 +1287,7 @@ CARD_DATABASE = {
"name": "魏战车",
"faction": "wei",
"type": "unit",
"unit_type": "chariot",
"unit_type": "infantry",
"cost": 5,
"op_cost": 2,
"attack": 4,
@@ -1414,7 +1414,7 @@ CARD_DATABASE = {
"defense": 2,
"max_hp": 2,
"description": "骑兵·冲锋",
"abilities": ["charge"],
"abilities": [],
"rarity": "rare",
},
"ally_song_yishang": {
@@ -1474,7 +1474,7 @@ CARD_DATABASE = {
"defense": 3,
"max_hp": 3,
"description": "弓手·可从营地射击",
"abilities": ["ranged"],
"abilities": [],
"rarity": "common",
},
"ally_wu_wuzixu": {
@@ -1714,7 +1714,7 @@ CARD_DATABASE = {
"defense": 2,
"max_hp": 2,
"description": "弓手·可从营地射击",
"abilities": ["ranged"],
"abilities": [],
"rarity": "common",
},
"ally_cai_qingtong": {

View File

@@ -257,8 +257,8 @@ class UI:
# Line 2: type + stats
if card_data["type"] == "unit":
icon = {"infantry": "", "cavalry": "", "chariot": "",
"archer": "", "siege": ""}.get(card_data.get("unit_type"), "?")
icon = {"infantry": "", "cavalry": "",
"archer": ""}.get(card_data.get("unit_type"), "?")
stats = f"{icon}{card_data['attack']}{card_data['defense']}{card_data['max_hp']}"
else:
stats = f"谋略: {card_data['description'][:12]}"
@@ -297,8 +297,8 @@ class UI:
self.screen.blit(cs, (x + small_w - cs.get_width() - 4, y + 3))
if card_data["type"] == "unit":
icon = {"infantry": "", "cavalry": "", "chariot": "",
"archer": "", "siege": ""}.get(card_data.get("unit_type"), "?")
icon = {"infantry": "", "cavalry": "",
"archer": ""}.get(card_data.get("unit_type"), "?")
stats = f"{icon}{card_data['attack']}{card_data['defense']}{card_data['max_hp']}"
else:
stats = f"谋略: {card_data['description'][:12]}"
@@ -492,8 +492,8 @@ class UI:
self.screen.blit(name_surf, (x + w // 2 - name_surf.get_width() // 2, y + 3))
# Unit type icon
icon_char = {"infantry": "", "cavalry": "", "chariot": "",
"archer": "", "siege": ""}.get(unit.unit_type, "?")
icon_char = {"infantry": "", "cavalry": "",
"archer": ""}.get(unit.unit_type, "?")
self.screen.blit(self.font_sm.render(icon_char, True, TENG_HUANG), (x + 3, y + 3))
# Operation cost
@@ -564,8 +564,8 @@ class UI:
self.screen.blit(name_surf, (x + w // 2 - name_surf.get_width() // 2, y + 28))
if card.card_type == "unit":
icon = {"infantry": "", "cavalry": "", "chariot": "",
"archer": "", "siege": ""}.get(card.unit_type, "?")
icon = {"infantry": "", "cavalry": "",
"archer": ""}.get(card.unit_type, "?")
self.screen.blit(self.font_sm.render(icon, True, TENG_HUANG), (x + 3, y + h - 40))
self.screen.blit(self.font_md.render(str(card.attack), True, (200, 80, 60)), (x + 5, y + h - 22))
self.screen.blit(self.font_md.render(str(card.defense), True, (60, 80, 160)), (x + w - 15, y + h - 22))