def _makePile(self, cardData, howManyCards): pile = Pile() for i in range(howManyCards): pile.drop(Card( name=cardData['name'], type=cardData['type'], cost=cardData.get('cost', 0), effects=cardData.get('effects', None), imageUrl=cardData['image'])) return pile
def __init__(self, players): if isinstance(players, int): players = [Player() for x in range(3)] self.num_players = len(players) self.current_turn = players[0] initial_victory_cards = 12 if self.num_players == 2: initial_victory_cards = 8 self.province_pile = Pile(PileType.VICTORY_CARDS, [Province() for i in range(initial_victory_cards)]) self.victory_cards = [self.province_pile] self.all_supply_piles = [self.victory_cards]
class State(): def __init__(self, players): if isinstance(players, int): players = [Player() for x in range(3)] self.num_players = len(players) self.current_turn = players[0] initial_victory_cards = 12 if self.num_players == 2: initial_victory_cards = 8 self.province_pile = Pile(PileType.VICTORY_CARDS, [Province() for i in range(initial_victory_cards)]) self.victory_cards = [self.province_pile] self.all_supply_piles = [self.victory_cards] def is_finished(self): if self.province_pile.is_empty(): return True # TODO: Check for more than 3 empty piles return False def whoes_turn(self): return self.current_turn
class Player(object): Name = None DrawPile = Pile() DiscardPile = Pile() Hand = HandClass() def __init__(self, name=None): self.Name = name self.DrawPile = Pile() self.DiscardPile = Pile() self.Hand = HandClass() def draw(self): if self.DrawPile.len() == 0: self.moveDiscardPileToDrawPile() drawnCard = self.DrawPile.draw() self.Hand.draw(drawnCard) return drawnCard def discard(self, card): self.DiscardPile.drop(self.Hand.discard(card)) def drawHand(self): for i in range(dominion_rules.HAND_SIZE): self.draw() def discardHand(self): while self.Hand.len() > 0: card = self.Hand.Cards[0] self.discard(card) def shuffle(self): self.DrawPile.shuffle() def moveDiscardPileToDrawPile(self): while self.DiscardPile.len() > 0: self.DrawPile.drop(self.DiscardPile.draw()) self.DrawPile.shuffle() def moveDrawPileToDiscardPile(self): while self.DrawPile.len() > 0: self.DiscardPile.drop(self.DrawPile.draw())
def __init__(self, name=None): self.Name = name self.DrawPile = Pile() self.DiscardPile = Pile() self.Hand = HandClass()
def _combinePiles(self, pileArray): newPile = Pile() for pile in pileArray: for card in pile.Cards: newPile.drop(card) return newPile