kit carlson

This commit is contained in:
Alberto Xamin 2020-11-23 17:54:38 +01:00
parent 08ff9abad6
commit d2a67b7350
No known key found for this signature in database
GPG Key ID: 4F026F48309500A2
2 changed files with 34 additions and 17 deletions

View File

@ -26,6 +26,9 @@ class Deck:
self.game.notify_scrap_pile()
return card
def put_on_top(self, card: Card):
self.cards.insert(0, card)
def draw(self) -> Card:
card = self.cards.pop(0)
if len(self.cards) == 0:

View File

@ -1,3 +1,4 @@
import deck
from enum import IntEnum
import json
from random import randrange
@ -124,6 +125,12 @@ class Player:
def draw(self, pile):
if self.pending_action != PendingAction.DRAW:
return
if isinstance(self.character, characters.KitCarlson):
self.is_drawing = True
self.available_cards = [self.game.deck.draw() for i in range(3)]
self.pending_action = PendingAction.CHOOSE
self.notify_self()
else:
self.pending_action = PendingAction.PLAY
if pile == 'scrap' and isinstance(self.character, characters.PedroRamirez):
self.hand.append(self.game.deck.draw_from_scrap_pile())
@ -316,6 +323,13 @@ class Player:
self.choose_action = ''
self.pending_action = PendingAction.PLAY
self.notify_self()
elif self.is_drawing and isinstance(self.character, characters.KitCarlson):
self.hand.append(self.available_cards.pop(card_index))
if len(self.available_cards) == 1:
self.game.deck.put_on_top(self.available_cards.pop())
self.is_drawing = False
self.pending_action = PendingAction.PLAY
self.notify_self()
else:
self.game.respond_emporio(self, card_index)