def setUp(self): # Get player names # player_names = ["Annie","*Ben","*Carla"] self.player_names = testUtility.GetPlayers() # number of curses and victory cards if len(self.player_names) > 2: self.nV = 12 else: self.nV = 8 self.nC = -10 + 10 * len(self.player_names) # Refactored Get boxs self.box = testUtility.GetBoxes(self.nV) # refactored supplu order self.supply_order = testUtility.SupplyOrder() # Pick 10 cards from box to be in the supply. self.supply = defaultdict(list) # The supply always has these cards self.supply["Copper"] = [Dominion.Copper()] self.supply["Silver"] = [Dominion.Silver()] self.supply["Gold"] = [Dominion.Gold()] self.supply["Estate"] = [Dominion.Estate()] self.supply["Duchy"] = [Dominion.Duchy()] self.supply["Province"] = [Dominion.Province()] self.supply["Curse"] = [Dominion.Curse()] # initialize the trash self.trash = [] self.player = Dominion.Player('Annie')
def initSupply(box, player_names): nC, nV = getCursesAndVictories(player_names) #Pick 10 cards from box to be in the supply. boxlist = [k for k in box] random.shuffle(boxlist) random10 = boxlist[:10] supply = defaultdict(list, [(k, box[k]) for k in random10]) #The supply always has these cards supply["Copper"] = [Dominion.Copper()] * (60 - len(player_names) * 7) supply["Silver"] = [Dominion.Silver()] * 40 supply["Gold"] = [Dominion.Gold()] * 30 supply["Estate"] = [Dominion.Estate()] * nV supply["Duchy"] = [Dominion.Duchy()] * nV supply["Province"] = [Dominion.Province()] * nV supply["Curse"] = [Dominion.Curse()] * nC supply_order = { 0: ['Curse', 'Copper'], 2: ['Estate', 'Cellar', 'Chapel', 'Moat'], 3: ['Silver', 'Chancellor', 'Village', 'Woodcutter', 'Workshop'], 4: [ 'Gardens', 'Bureaucrat', 'Feast', 'Militia', 'Moneylender', 'Remodel', 'Smithy', 'Spy', 'Thief', 'Throne Room' ], 5: [ 'Duchy', 'Market', 'Council Room', 'Festival', 'Laboratory', 'Library', 'Mine', 'Witch' ], 6: ['Gold', 'Adventurer'], 8: ['Province'] } return supply, supply_order
def get_supply(box, num_players, nC, nV): """ :param box: dictionary containing starting lists of action cards :param num_players: number of players :param nC: starting number of curse cards :param nV: starting number of each victory card :return: dictionary of 10 randomly selected action cards and a prescribed amount of coin, victory, and curse cards (according to this function) """ boxlist = [k for k in box] random.shuffle(boxlist) random10 = boxlist[:10] supply = defaultdict(list, [(k, box[k]) for k in random10]) # The supply always has these cards supply["Copper"] = [Dominion.Copper()] * (60 - num_players * 7) supply["Silver"] = [Dominion.Silver()] * 40 supply["Gold"] = [Dominion.Gold()] * 30 supply["Estate"] = [Dominion.Estate()] * nV supply["Duchy"] = [Dominion.Duchy()] * nV supply["Province"] = [Dominion.Province()] * nV supply["Curse"] = [Dominion.Curse()] * nC return supply
def addDefaultSupplyCards(supply, nV, nC, player_names): supply["Copper"] = [Dominion.Copper()] * (60 - len(player_names) * 7) supply["Silver"] = [Dominion.Silver()] * 40 supply["Gold"] = [Dominion.Gold()] * 30 supply["Estate"] = [Dominion.Estate()] * nV supply["Duchy"] = [Dominion.Duchy()] * nV supply["Province"] = [Dominion.Province()] * nV supply["Curse"] = [Dominion.Curse()] * nC
def SetSupply(supply): supply["Copper"] = [Dominion.Copper()] * (60 - len(player_names) * 7) supply["Silver"] = [Dominion.Silver()] * 40 supply["Gold"] = [Dominion.Gold()] * 30 supply["Estate"] = [Dominion.Estate()] * nV supply["Duchy"] = [Dominion.Duchy()] * nV supply["Province"] = [Dominion.Province()] * nV supply["Curse"] = [Dominion.Curse()] * nC
def updateSupplyWithoutVictoryCards(supply, player_names, nV, nC): supply["Copper"] = [Dominion.Copper()] * (60 - len(player_names) * 7) supply["Silver"] = [Dominion.Silver()] * 40 supply["Gold"] = [Dominion.Gold()] * 30 supply["Estate"] = [] supply["Duchy"] = [] supply["Province"] = [] supply["Curse"] = [Dominion.Curse()] * nC
def SupplyBaseStart(supply, player_names, nV, nC): supply["Copper"] = [Dominion.Copper()] * (60 - len(player_names) * 7) supply["Silver"] = [Dominion.Silver()] * 40 supply["Gold"] = [Dominion.Gold()] * 30 supply["Estate"] = [Dominion.Estate()] * nV supply["Duchy"] = [Dominion.Duchy()] * nV supply["Province"] = [Dominion.Province()] * nV supply["Curse"] = [Dominion.Curse()] * nC return supply
def supplyCards(nC, nV, player_names, supply): #The supply always has these cards supply["Copper"]=[Dominion.Copper()]*(60-len(player_names)*7) supply["Silver"]=[Dominion.Silver()]*40 supply["Gold"]=[Dominion.Gold()]*30 supply["Estate"]=[Dominion.Estate()]*nV supply["Duchy"]=[Dominion.Duchy()]*nV supply["Province"]=[Dominion.Province()]*nV supply["Curse"]=[Dominion.Curse()]*nC
def generateSupplies(nV, nC, supply, player_names): supply["Copper"] = [Dominion.Copper()] * (60 - len(player_names) * 7) supply["Silver"] = [Dominion.Silver()] * 40 supply["Gold"] = [Dominion.Gold()] * 30 supply["Estate"] = [Dominion.Estate()] * nV supply["Duchy"] = [Dominion.Duchy()] * nV supply["Province"] = [Dominion.Province()] * nV supply["Curse"] = [Dominion.Curse()] * nC return supply
def add_required_supplies(supply, nV, nC, player_names): # The supply always has these cards supply["Copper"]=[Dominion.Copper()]*(60-len(player_names)*7) supply["Silver"]=[Dominion.Silver()]*40 supply["Gold"]=[Dominion.Gold()]*30 supply["Estate"]=[Dominion.Estate()]*nV supply["Duchy"]=[Dominion.Duchy()]*nV supply["Province"]=[Dominion.Province()]*nV supply["Curse"]=[Dominion.Curse()]*nC
def addStandardCards(supply, numPlayers, nC, nV): supply["Copper"] = [Dominion.Copper()] * (60 - numPlayers * 7) supply["Silver"] = [Dominion.Silver()] * 40 supply["Gold"] = [Dominion.Gold()] * 30 supply["Estate"] = [Dominion.Estate()] * nV supply["Duchy"] = [Dominion.Duchy()] * nV supply["Province"] = [Dominion.Province()] * nV supply["Curse"] = [Dominion.Curse()] * nC return supply
def GetStandardSupply(supply, player_names, nV, nC): #The supply always has these cards supply["Copper"] = [Dominion.Copper()] * (60 - len(player_names) * 7) supply["Silver"] = [Dominion.Silver()] * 40 supply["Gold"] = [Dominion.Gold()] * 30 supply["Estate"] = [Dominion.Estate()] * nV supply["Duchy"] = [Dominion.Duchy()] * nV supply["Province"] = [Dominion.Province()] * nV supply["Curse"] = [Dominion.Curse()] * nC return supply
def GetSupply(box, random10, player_names, nV, nC): supply = defaultdict(list, [(k, box[k]) for k in random10]) # The supply always has these cards supply["Copper"] = [Dominion.Copper()] * (60 - len(player_names) * 7) supply["Silver"] = [Dominion.Silver()] * 40 supply["Gold"] = [Dominion.Gold()] * 30 supply["Estate"] = [Dominion.Estate()] * nV supply["Duchy"] = [Dominion.Duchy()] * nV supply["Province"] = [Dominion.Province()] * nV supply["Curse"] = [Dominion.Curse()] * nC return supply
def get_supply(box, player_names, nV, nC): boxlist = [k for k in box] random.shuffle(boxlist) random10 = boxlist[:10] supply = defaultdict(list, [(k, box[k]) for k in random10]) supply["Copper"] = [Dominion.Copper()] * (60 - len(player_names) * 7) supply["Silver"] = [Dominion.Silver()] * 40 supply["Gold"] = [Dominion.Gold()] * 30 supply["Estate"] = [Dominion.Estate()] * nV supply["Duchy"] = [Dominion.Duchy()] * nV supply["Province"] = [Dominion.Province()] * nV supply["Curse"] = [Dominion.Curse()] * nC return supply
def update_supply(supply, num_victory, num_curses, num_players): """ Sets the supply of some of the items Modifies the given supply dict Nothing returned """ supply["Copper"] = [Dominion.Copper()] * (60 - num_players * 7) supply["Silver"] = [Dominion.Silver()] * 40 supply["Gold"] = [Dominion.Gold()] * 30 supply["Estate"] = [Dominion.Estate()] * num_victory supply["Duchy"] = [Dominion.Duchy()] * num_victory supply["Province"] = [Dominion.Province()] * num_victory supply["Curse"] = [Dominion.Curse()] * num_curses
def test_gameover(self): supply = {} supply['Province'] = [Dominion.Province()] * 10 supply['Market'] = [Dominion.Market()] * 10 supply['Gold'] = [Dominion.Gold()] * 10 supply['Festival'] = [Dominion.Festival()] * 10 # gameover should return false self.assertFalse(Dominion.gameover(supply)) # gameover should return true supply['Province'] = [Dominion.Province()] * 0 self.assertTrue(Dominion.gameover(supply)) # gameover should return false supply['Province'] = [Dominion.Province()] * 1 supply['Market'] = [Dominion.Market()] * 0 supply['Gold'] = [Dominion.Gold()] * 0 self.assertFalse(Dominion.gameover(supply)) # gameover should return true supply['Festival'] = [Dominion.Festival()] * 0 self.assertTrue(Dominion.gameover(supply))
def init_supply(box, nV, nC, num_players): boxlist = [k for k in box] random.shuffle(boxlist) random10 = boxlist[:10] supply = defaultdict(list, [(k, box[k]) for k in random10]) #The supply always has these cards supply["Copper"] = [Dominion.Copper()] * (60 - num_players * 7) supply["Silver"] = [Dominion.Silver()] * 40 supply["Gold"] = [Dominion.Gold()] * 30 supply["Estate"] = [Dominion.Estate()] * nV supply["Duchy"] = [Dominion.Duchy()] * nV supply["Province"] = [Dominion.Province()] * nV supply["Curse"] = [Dominion.Curse()] * nC return supply
def getSupply(nV, nC, player_names, box): # Pick 10 cards from box to be in the supply. boxlist = [k for k in box] random.shuffle(boxlist) random10 = boxlist[:10] supply = defaultdict(list, [(k, box[k]) for k in random10]) # The supply always has these cards supply["Copper"] = [Dominion.Copper()] * (60 - len(player_names) * 7) supply["Silver"] = [Dominion.Silver()] * 40 supply["Gold"] = [Dominion.Gold()] * 30 supply["Estate"] = [Dominion.Estate()] * nV supply["Duchy"] = [Dominion.Duchy()] * nV supply["Province"] = [Dominion.Province()] * nV supply["Curse"] = [Dominion.Curse()] * nC
def getSupply(box, player_names): boxlist = [k for k in box] random.shuffle(boxlist) random10 = boxlist[:10] supply = defaultdict(list, [(k, box[k]) for k in random10]) #determine the victory and curse cards based on the number of players nV = _getVictoryNum(player_names) nC = _getCurseNum(player_names) #add the treasure, victory and curse cards, the supply always has these cards supply["Copper"] = [Dominion.Copper()] * (60 - len(player_names) * 7) supply["Silver"] = [Dominion.Silver()] * 40 supply["Gold"] = [Dominion.Gold()] * 30 supply["Estate"] = [Dominion.Estate()] * nV supply["Duchy"] = [Dominion.Duchy()] * nV supply["Province"] = [Dominion.Province()] * nV supply["Curse"] = [Dominion.Curse()] * nC return supply
def test_gameover(self): # set up data self.set_up() game_over = Dominion.gameover(self.supply) self.assertEqual(False, game_over) # set province cards to 0 sets gameover to true self.supply["Province"] = [Dominion.Province()] * 0 game_over = Dominion.gameover(self.supply) self.assertEqual(True, game_over) # set three supply piles to empty sets gameover to true self.supply = testUtility.getSupply(self.nV, self.nC, self.player_names, self.box) self.supply["Gold"] = [Dominion.Gold()] * 0 self.supply["Estate"] = [Dominion.Estate()] * 0 self.supply["Duchy"] = [Dominion.Duchy()] * 0 game_over = Dominion.gameover(self.supply) self.assertEqual(True, game_over)
def create_supply(player_count): box = create_box(player_count) #Pick 10 cards from box to be in the supply. boxlist = [k for k in box] random.shuffle(boxlist) random10 = boxlist[:10] supply = defaultdict(list,[(k,box[k]) for k in random10]) #The supply always has these cards supply["Copper"]=[Dominion.Copper()]*(60-player_count*7) supply["Silver"]=[Dominion.Silver()]*40 supply["Gold"]=[Dominion.Gold()]*30 supply["Estate"]=[Dominion.Estate()]*number_of_victory_cards(player_count) supply["Duchy"]=[Dominion.Duchy()]*number_of_victory_cards(player_count) supply["Province"]=[Dominion.Province()]*number_of_victory_cards(player_count) supply["Curse"]=[Dominion.Curse()]*number_of_curse_cards(player_count) return supply
def setUp(self): self.player_names = testUtility.GetPlayers() # number of curses and victory cards if len(self.player_names) > 2: self.nV = 12 else: self.nV = 8 self.nC = -10 + 10 * len(self.player_names) # Refactored Get boxs self.box = testUtility.GetBoxes(self.nV) # refactored supplu order self.supply_order = testUtility.SupplyOrder() # Pick 10 cards from box to be in the supply. self.boxlist = [k for k in self.box] random.shuffle(self.boxlist) self.random10 = self.boxlist[:10] self.supply = defaultdict(list, [(k, self.box[k]) for k in self.random10]) # The supply always has these cards self.supply["Copper"] = [Dominion.Copper() ] * (60 - len(self.player_names) * 7) self.supply["Silver"] = [Dominion.Silver()] * 40 self.supply["Gold"] = [Dominion.Gold()] * 30 self.supply["Estate"] = [Dominion.Estate()] * self.nV self.supply["Duchy"] = [Dominion.Duchy()] * self.nV self.supply["Province"] = [Dominion.Province()] * self.nV self.supply["Curse"] = [Dominion.Curse()] * self.nC # initialize the trash self.trash = [] self.name = "Blueberry" self.actions = 3 self.coins = 10 self.player = Dominion.Player('Annie') self.player2 = Dominion.Player('Carla')
def test_cardsummary(self): #This function will iterate and calculate cards in the deck. # it will filter out and register card names and count total number of cards #initate variables player = Dominion.Player("Duke") #set hand, and hand to 0 # reset discard to contain new Dominion cards player.hand = [] player.deck = [] assert len(player.stack()) == 0 # this way we can change and modify to show proper results player.deck = [Dominion.Province()] * 10 + [Dominion.Gold()] * 10 # call function testSummary = player.cardsummary() # assert assert testSummary['Gold'] == 10 assert testSummary['Province'] == 10 assert testSummary['VICTORY POINTS'] == 60
def getSupply(box, player_names, nV, nC): """ Returns a randomized supply for the current game. Takes in arguments the current box object, supply order, and the number of Victory Cards and Curses in play. """ #Pick 10 cards from box to be in the supply. boxlist = [k for k in box] random.shuffle(boxlist) random10 = boxlist[:10] supply = defaultdict(list, [(k, box[k]) for k in random10]) #The supply always has these cards supply["Copper"] = [Dominion.Copper()] * (60 - len(player_names) * 7) supply["Silver"] = [Dominion.Silver()] * 40 supply["Gold"] = [Dominion.Gold()] * 30 supply["Estate"] = [Dominion.Estate()] * nV supply["Duchy"] = [Dominion.Duchy()] * nV supply["Province"] = [Dominion.Province()] * nV supply["Curse"] = [Dominion.Curse()] * nC return supply
'Mine', 'Witch' ], 6: ['Gold', 'Adventurer'], 8: ['Province'] } #Pick 10 cards from box to be in the supply. boxlist = [k for k in box] random.shuffle(boxlist) random10 = boxlist[:10] supply = defaultdict(list, [(k, box[k]) for k in random10]) #The supply always has these cards supply["Copper"] = [Dominion.Copper()] * (60 - len(player_names) * 7) supply["Silver"] = [Dominion.Silver()] * 40 supply["Gold"] = [Dominion.Gold()] * 30 supply["Estate"] = [Dominion.Estate()] * nV supply["Duchy"] = [Dominion.Duchy()] * nV supply["Province"] = [Dominion.Province()] * nV supply["Curse"] = [Dominion.Curse()] * nC #initialize the trash trash = [] #Costruct the Player objects players = [] for name in player_names: if name[0] == "*": players.append(Dominion.ComputerPlayer(name[1:])) elif name[0] == "^": players.append(Dominion.TablePlayer(name[1:]))
5:['Duchy','Market','Council Room','Festival','Laboratory','Library','Mine','Witch'], 6:['Gold','Adventurer'],8:['Province']} #Pick 10 cards from box to be in the supply. boxlist = [k for k in box] random.shuffle(boxlist) random10 = boxlist[:10] supply = defaultdict(list,[(k,box[k]) for k in random10]) #The supply always has these cards supply["Copper"]=[Dominion.Copper()]*(60-len(player_names)*7) supply["Silver"]=[Dominion.Silver()]*40 supply["Gold"]=[Dominion.Gold()]*0 # bug 0 gold cards supply["Estate"]=[Dominion.Estate()]*nV supply["Duchy"]=[Dominion.Duchy()]*1 supply["Province"]=[Dominion.Province()]*1 # Note bug 1 the first province is the last province supply["Curse"]=[Dominion.Curse()]*nC #initialize the trash trash = [] #Costruct the Player objects players = testUtility.InitializePlayers(player_names) #Play the game turn = 0
nV = testUtility.get_numberVCards(len(player_names)) nC = testUtility.get_numberCCards(len(player_names)) box = testUtility.getBoxes(nV) supply_order = testUtility.getSupply_Order() #Pick 10 cards from box to be in the supply. boxSupply = testUtility.get_boxSupply(box) #The supply always has these cards # supply = testUtility.getSupply(player_names, nV, nC) # Insert Bug #1: supply["copper"]=[Dominion.Gold()]*(60-len(player_names)*7) supply["Copper"]=[Dominion.Gold()]*(60-len(player_names)*7) supply["Silver"]=[Dominion.Silver()]*40 supply["Gold"]=[Dominion.Gold()]*30 supply["Estate"]=[Dominion.Estate()]*nV supply["Duchy"]=[Dominion.Duchy()]*nV supply["Province"]=[Dominion.Province()]*nV supply["Curse"]=[Dominion.Curse()]*nC #initialize the trash trash = [] #Costruct the Player objects players = testUtility.getPlayers(player_names)