Archived
avoid adding cards to player hand during his turn
This commit is contained in:
@@ -68,12 +68,12 @@ async def effect_sacrifice(_effect: Effect, turn: "Turn", target: str):
|
||||
|
||||
|
||||
async def effect_draw(_effect: Effect, turn: "Turn", _target: str):
|
||||
return await turn.player.draw(1)
|
||||
return await turn.player.draw_and_play(1)
|
||||
|
||||
|
||||
async def effect_draw_and_discard(_effect: Effect, turn: "Turn", _target: str):
|
||||
turn.discard_markers += 1
|
||||
return await turn.player.draw(1)
|
||||
return await turn.player.draw_and_play(1)
|
||||
|
||||
|
||||
async def effect_discard(_effect: Effect, turn: "Turn", target: str):
|
||||
@@ -97,7 +97,7 @@ async def effect_stack_next_card(_effect: Effect, turn: "Turn", target: str):
|
||||
|
||||
|
||||
async def effect_play_next_card(_effect: Effect, turn: "Turn", target: str):
|
||||
return await turn.buy_card(target, turn.player.buy_in_hand)
|
||||
return await turn.buy_card(target, turn.player.buy_in_board)
|
||||
|
||||
|
||||
card_effect_all_behaviours = {
|
||||
|
||||
+21
-4
@@ -154,6 +154,23 @@ class Player(Serializable):
|
||||
await self.notify_update()
|
||||
return True
|
||||
|
||||
async def draw_and_play(self, amount: int) -> bool:
|
||||
"""Draw a card from the stack to the board. Handles stack rebuild from discard automatically"""
|
||||
|
||||
while amount > 0:
|
||||
if len(self.stack_pile) == 0:
|
||||
if len(self.discard_pile) == 0:
|
||||
print("No more cards to draw !")
|
||||
return False
|
||||
await self._rebuild_stack()
|
||||
|
||||
if len(self.stack_pile) > 0:
|
||||
self.board.append(self.stack_pile.pop())
|
||||
amount = amount - 1
|
||||
|
||||
await self.notify_update()
|
||||
return True
|
||||
|
||||
async def buy_card(self, card: Card) -> bool:
|
||||
|
||||
if card in self.game.gem_stack:
|
||||
@@ -185,11 +202,11 @@ class Player(Serializable):
|
||||
await self.game.notify_controller("update", self.game.serialize_guest())
|
||||
return True
|
||||
|
||||
async def draw_from_discard(self, card_id: str):
|
||||
async def play_from_discard(self, card_id: str):
|
||||
|
||||
card = self.source_card(card_id, self.discard_pile)
|
||||
if card is not None:
|
||||
self.hand.append(card)
|
||||
self.board.append(card)
|
||||
else:
|
||||
print("Card not found in discard pile")
|
||||
return
|
||||
@@ -208,7 +225,7 @@ class Player(Serializable):
|
||||
await self.notify_update()
|
||||
return True
|
||||
|
||||
async def buy_in_hand(self, card: Card) -> bool:
|
||||
async def buy_in_board(self, card: Card) -> bool:
|
||||
if card in self.game.gem_stack:
|
||||
self.game.gem_stack.remove(card)
|
||||
elif card in self.game.market:
|
||||
@@ -219,7 +236,7 @@ class Player(Serializable):
|
||||
print("Card not found in market or gem_stack")
|
||||
return False
|
||||
|
||||
self.hand.append(card)
|
||||
self.board.append(card)
|
||||
await self.game.notify_controller("update", self.game.serialize_guest())
|
||||
await self.notify_update()
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user