def turn(self, gameState): self.actions = 1 self.buys = 1 self.money = "0" for card in self.durationCards: card.cbInitTurn(gameState) # Action print "*** DEBUG: %s's turn. Hand: %s." % (self.name, self.hand) self.actionFunc(self) # Buy for card in self.hand: if card.treasure: card.cbPlay(gameState) options = [] for supply in gameState.supplies: if not supply.isEmpty(): if utils.cmpMoney(self.money, supply.cost()) >= 0: options.append(supply) self.buyFunc(self, options) # Cleanup self.discardPile += self.hand self.hand = [] self.draw(5)
def getBuyOptions(self): options = [] for supply in self.gameState.supplies: if not supply.isEmpty(): if utils.cmpMoney(self.money, supply.cost()) >= 0: options.append(supply) return options
def buy(self, supply): assert (utils.cmpMoney(self.money, supply.cost()) >= 0, "not enough money :(") assert (self.buys > 0, "no buys remain in turn :(") self.buys -= 1 self.money = utils.subtractMoney(self.money, supply.cost()) self.player.discardPile.append(supply.buy())