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 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 updateSupplyWithoutTreasure(supply, player_names, nV, nC): supply["Copper"] = [] supply["Silver"] = [] supply["Gold"] = [] 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 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 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 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 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 test_protect(self): #print("play test_protect...") dis1 = len(players[1].discard) #print(players[1].discard) supply["Curse"] = [Dominion.Curse()] * 1 supply["Moat"] = [Dominion.Moat()] * 1 players[1].hand.append(supply['Moat'][0]) Dominion.Witch().play(players[0], players, supply, trash) #print(players[1].discard) dis2 = len(players[1].discard) self.assertEqual(dis1, dis2)
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 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 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(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 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 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
} #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:])) else: players.append(Dominion.Player(name)) #Play the game
# Get player names player_names = testUtility.get_player_names() # number of curses and victory cards nV = testUtility.get_num_victory_cards(player_names) nC = testUtility.get_num_curse_cards(player_names) # Define box box = testUtility.get_box(nV) supply_order = testUtility.get_supply_order() # Pick 10 cards from box to be in the supply and teh cards which are always in supply supply = testUtility.get_supply(box, player_names, nV, nC) """ Test Case: Change the coppers in the Supply to Curses """ supply["Copper"] = [Dominion.Curse()] * (60 - len(player_names) * 7) # initialize the trash trash = testUtility.get_trash() # Costruct the Player objects players = testUtility.get_players(player_names) # Play the game testUtility.play_game(supply, supply_order, players, trash) # Final score testUtility.print_final_score(players)
box = testUtility.GetBoxes(nV) supply_order = testUtility.GetSupplyOrder() #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 testUtility.CreateSupply(supply, player_names, nV, nC) #TEST SCENARIO: supply["Duchy"]=[Dominion.Curse()]*nC #initialize the trash trash = [] #Costruct the Player objects players = [] testUtility.ConstructPlayerObjects(players, player_names) #Play the game turn = 0 while not Dominion.gameover(supply): turn += 1 print("\r") for value in supply_order:
player_names = testUtility.getPlayerNames() #number of curses and victory cards nV = testUtility.getNumberVictory(player_names) nC = testUtility.getNumberCurse(player_names) #Define box #note to self* passing nV for the victory cards for gardens box = testUtility.getBoxes(nV) #set up the layout of the cards supply_order = testUtility.getSupplyOrder() #randomize supply and add static cards supply = testUtility.getSupply(box, player_names, nV, nC) #initialize the trash trash = [] #Costruct the Player objects players = testUtility.getPlayers(player_names) #ITERATION TO EXPLORE TEST SCENERIOS GOES HERE # ATTEMPT TO CHANGE: We redefined the dictionary so that it will act as a Dominion Curse Card; we also reset the card quanity to one # Expected Results: The Province should change into a curse card and should be counted as a (-1)VP # ACTUAL RESULT: The Game shows a province card at one, but will not register that there is a province card when the user buys the game. This prevents the players from # winning and completing the game once province is bought. supply["Province"] = [Dominion.Curse()] * 1 #Play the game testUtility.playGame(supply_order, supply, players, trash)