游戏可以运行
This commit is contained in:
@@ -2,8 +2,9 @@
|
||||
|
||||
from card_game.config import (
|
||||
STARTING_CAPITAL_HP, MAX_PROVISIONS, MAX_HAND_SIZE,
|
||||
MAX_SUPPORT_SLOTS, MAX_FRONTLINE_SLOTS, DECK_SIZE, STARTING_HAND_SIZE,
|
||||
MAX_SUPPORT_SLOTS, MAX_FRONTLINE_SLOTS, DECK_SIZE,
|
||||
FATIGUE_START_DAMAGE, FACTIONS, DECK_PRESETS,
|
||||
FIRST_HAND_SIZE, SECOND_HAND_SIZE,
|
||||
)
|
||||
from card_game.deck import Deck
|
||||
from card_game.card import Card
|
||||
@@ -33,14 +34,16 @@ class Player:
|
||||
preset = DECK_PRESETS[self.faction_id]
|
||||
self.deck.build(preset["cards"])
|
||||
|
||||
def start_game(self):
|
||||
def start_game(self, hand_size=None):
|
||||
self.build_deck()
|
||||
for _ in range(STARTING_HAND_SIZE):
|
||||
if hand_size is None:
|
||||
hand_size = FIRST_HAND_SIZE
|
||||
for _ in range(hand_size):
|
||||
self.draw_card()
|
||||
|
||||
def start_turn(self, turn_number):
|
||||
self.turn_number = turn_number
|
||||
gained = min(turn_number + 1, MAX_PROVISIONS)
|
||||
gained = min(turn_number, MAX_PROVISIONS)
|
||||
self.provisions = gained
|
||||
self.max_provisions = gained
|
||||
|
||||
@@ -176,6 +179,15 @@ class Player:
|
||||
if unit.current_hp < unit.max_hp:
|
||||
unit.current_hp = min(unit.max_hp, unit.current_hp + 1)
|
||||
|
||||
def get_attack_cost(self, unit):
|
||||
cost = unit.op_cost
|
||||
if self.faction_id == "yan" and unit.unit_type == "cavalry":
|
||||
cost = max(0, cost - 1)
|
||||
return cost
|
||||
|
||||
def can_afford_attack(self, unit):
|
||||
return self.provisions >= self.get_attack_cost(unit)
|
||||
|
||||
def cleanup_dead(self):
|
||||
for i in range(len(self.support_line)):
|
||||
u = self.support_line[i]
|
||||
|
||||
Reference in New Issue
Block a user