def get_boxes(nV): """ :param nV: starting number of each victory card, used here for calculating number of garden cards :return: box, a dictionary containing starting lists of action cards """ box = {} box["Woodcutter"] = [Dominion.Woodcutter()] * 10 box["Smithy"] = [Dominion.Smithy()] * 10 box["Laboratory"] = [Dominion.Laboratory()] * 10 box["Village"] = [Dominion.Village()] * 10 box["Festival"] = [Dominion.Festival()] * 10 box["Market"] = [Dominion.Market()] * 10 box["Chancellor"] = [Dominion.Chancellor()] * 10 box["Workshop"] = [Dominion.Workshop()] * 10 box["Moneylender"] = [Dominion.Moneylender()] * 10 box["Chapel"] = [Dominion.Chapel()] * 10 box["Cellar"] = [Dominion.Cellar()] * 10 box["Remodel"] = [Dominion.Remodel()] * 10 box["Adventurer"] = [Dominion.Adventurer()] * 10 box["Feast"] = [Dominion.Feast()] * 10 box["Mine"] = [Dominion.Mine()] * 10 box["Library"] = [Dominion.Library()] * 10 box["Gardens"] = [Dominion.Gardens()] * nV box["Moat"] = [Dominion.Moat()] * 10 box["Council Room"] = [Dominion.Council_Room()] * 10 box["Witch"] = [Dominion.Witch()] * 10 box["Bureaucrat"] = [Dominion.Bureaucrat()] * 10 box["Militia"] = [Dominion.Militia()] * 10 box["Spy"] = [Dominion.Spy()] * 10 box["Thief"] = [Dominion.Thief()] * 10 box["Throne Room"] = [Dominion.Throne_Room()] * 10 return box
def initBox(nV): #Define box box = {} box["Woodcutter"]=[Dominion.Woodcutter()]*10 box["Smithy"]=[Dominion.Smithy()]*10 box["Laboratory"]=[Dominion.Laboratory()]*10 box["Village"]=[Dominion.Village()]*10 box["Festival"]=[Dominion.Festival()]*10 box["Market"]=[Dominion.Market()]*10 box["Chancellor"]=[Dominion.Chancellor()]*10 box["Workshop"]=[Dominion.Workshop()]*10 box["Moneylender"]=[Dominion.Moneylender()]*10 box["Chapel"]=[Dominion.Chapel()]*10 box["Cellar"]=[Dominion.Cellar()]*10 box["Remodel"]=[Dominion.Remodel()]*10 box["Adventurer"]=[Dominion.Adventurer()]*10 box["Feast"]=[Dominion.Feast()]*10 box["Mine"]=[Dominion.Mine()]*10 box["Library"]=[Dominion.Library()]*10 box["Gardens"]=[Dominion.Gardens()]*nV box["Moat"]=[Dominion.Moat()]*10 box["Council Room"]=[Dominion.Council_Room()]*10 box["Witch"]=[Dominion.Witch()]*10 box["Bureaucrat"]=[Dominion.Bureaucrat()]*10 box["Militia"]=[Dominion.Militia()]*10 box["Spy"]=[Dominion.Spy()]*10 box["Thief"]=[Dominion.Thief()]*10 box["Throne Room"]=[Dominion.Throne_Room()]*10 return box
def define_box(nV): box = {} box["Woodcutter"]=[Dominion.Woodcutter()]*10 box["Smithy"]=[Dominion.Smithy()]*10 box["Laboratory"]=[Dominion.Laboratory()]*10 box["Village"]=[Dominion.Village()]*10 box["Festival"]=[Dominion.Festival()]*10 box["Market"]=[Dominion.Market()]*10 box["Chancellor"]=[Dominion.Chancellor()]*10 box["Workshop"]=[Dominion.Workshop()]*10 box["Moneylender"]=[Dominion.Moneylender()]*10 box["Chapel"]=[Dominion.Chapel()]*10 box["Cellar"]=[Dominion.Cellar()]*10 box["Remodel"]=[Dominion.Remodel()]*10 box["Adventurer"]=[Dominion.Adventurer()]*10 box["Feast"]=[Dominion.Feast()]*10 box["Mine"]=[Dominion.Mine()]*10 box["Library"]=[Dominion.Library()]*10 box["Gardens"]=[Dominion.Gardens()]*nV box["Moat"]=[Dominion.Moat()]*10 box["Council Room"]=[Dominion.Council_Room()]*10 box["Witch"]=[Dominion.Witch()]*10 box["Bureaucrat"]=[Dominion.Bureaucrat()]*10 box["Militia"]=[Dominion.Militia()]*10 box["Spy"]=[Dominion.Spy()]*10 box["Thief"]=[Dominion.Thief()]*10 box["Throne Room"]=[Dominion.Throne_Room()]*10 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 box, supply_order
def test_draw(self): self.setUp() # Store the state of the hand self.player.hand.clear() local_hand = self.player.hand # Call the method with no arguments self.player.draw() # Test default arg dest == self.hand self.assertEqual(local_hand, self.player.hand) # Call method with empty hand test_discard = self.player.discard self.player.deck.clear() self.player.draw() # Test second if which assigns discard to deck self.assertEqual(test_discard, self.player.deck) # Assign a new deck self.player.deck = [Dominion.Province()] * 2 + [Dominion.Gardens()] test_sub0 = self.player.deck[0] # Call the method test_draw = self.player.draw() # Test the 3rd if condition self.assertEqual(test_sub0, test_draw)
def get_box(num_victory): """ Input: the number of victory cards Returns: a dictionary of cards The number of "Gardens" is determined by the # of victory cards """ box = {} box["Woodcutter"] = [Dominion.Woodcutter()] * 10 box["Smithy"] = [Dominion.Smithy()] * 10 box["Laboratory"] = [Dominion.Laboratory()] * 10 box["Village"] = [Dominion.Village()] * 10 box["Festival"] = [Dominion.Festival()] * 10 box["Market"] = [Dominion.Market()] * 10 box["Chancellor"] = [Dominion.Chancellor()] * 10 box["Workshop"] = [Dominion.Workshop()] * 10 box["Moneylender"] = [Dominion.Moneylender()] * 10 box["Chapel"] = [Dominion.Chapel()] * 10 box["Cellar"] = [Dominion.Cellar()] * 10 box["Remodel"] = [Dominion.Remodel()] * 10 box["Adventurer"] = [Dominion.Adventurer()] * 10 box["Feast"] = [Dominion.Feast()] * 10 box["Mine"] = [Dominion.Mine()] * 10 box["Library"] = [Dominion.Library()] * 10 box["Gardens"] = [Dominion.Gardens()] * num_victory box["Moat"] = [Dominion.Moat()] * 10 box["Council Room"] = [Dominion.Council_Room()] * 10 box["Witch"] = [Dominion.Witch()] * 10 box["Bureaucrat"] = [Dominion.Bureaucrat()] * 10 box["Militia"] = [Dominion.Militia()] * 10 box["Spy"] = [Dominion.Spy()] * 10 box["Thief"] = [Dominion.Thief()] * 10 box["Throne Room"] = [Dominion.Throne_Room()] * 10 return box
def test_calcpoints(self): # set up and instantiate Garden card self.set_up() self.player.points = 0 # 1 victory point for every 10 cards in stack # assert change in value with different size stacks # first assert player begins game with 3 victory points self.player.points = self.player.calcpoints() self.assertEqual(3, self.player.points) # test 11 cards in stack, including 1 gardens # assert victory points equal to 4 self.player.deck.append(Dominion.Gardens()) self.assertEqual(11, len(self.player.stack())) self.player.points = self.player.calcpoints() self.assertEqual(4, self.player.points) # test 21 card stack, assert victory points equal to 5 self.player.deck.append(Dominion.Copper()) self.player.deck.append(Dominion.Copper()) self.player.deck.append(Dominion.Copper()) self.player.deck.append(Dominion.Copper()) self.player.deck.append(Dominion.Copper()) self.player.deck.append(Dominion.Copper()) self.player.deck.append(Dominion.Copper()) self.player.deck.append(Dominion.Copper()) self.player.deck.append(Dominion.Copper()) self.player.deck.append(Dominion.Copper()) self.assertEqual(21, len(self.player.stack())) self.player.points = self.player.calcpoints() self.assertEqual(5, self.player.points)
def test_card_summary(self): self.setUp() self.player.hand.insert(0, Dominion.Gardens()) summary = self.player.cardsummary() ecount = summary['Estate'] ccount = summary['Copper'] vcount = summary['VICTORY POINTS'] self.assertEqual(3, ecount) self.assertEqual(7, ccount) self.assertEqual(summary['Gardens'], 1) self.assertEqual(self.player.calcpoints(), vcount)
def test_calcpoints(self): self.setUp() # Victory card Province points = 6 && Gardens = 0 self.player.deck = [Dominion.Province()] * 2 + [Dominion.Gardens()] # Call the method point_total = self.player.calcpoints() # Test that balance = 12 self.assertEqual(point_total, 12)
def test_cardsummary(self): self.setUp() # Set up the player deck and it's summary self.player.deck = [Dominion.Province()] * 2 + [Dominion.Gardens()] summary_guess = {"Province": 2, "Gardens": 1, 'VICTORY POINTS': 12} # Call the method test_summary = self.player.cardsummary() # Test that the method returns the correct summary self.assertEqual(summary_guess, test_summary)
def test_calc_points(self): self.setUp() i = 0 for card in self.player.stack(): if card.vpoints == 0: self.player.hand.pop(i) i += 1 break i += 1 self.player.hand.insert(0, Dominion.Gardens()) #for card in self.player.stack(): # print(card.vpoints) testPoints = Dominion.Player.calcpoints(self.player) self.assertEqual(4, testPoints)
def test_calcpoints(self): player = Dominion.Player("Bob") points = 3 self.assertEqual(player.calcpoints(), points) for i in range(TestPlayer.NUM_TRIALS): vpoints = random.randint(1, 30) card = Dominion.Card("name", "category", 0, 0, vpoints) player.deck.append(card) points += vpoints self.assertEqual(player.calcpoints(), points) for i in range(TestPlayer.NUM_TRIALS): card = Dominion.Gardens() player.deck.append(card) points2 = points + len(player.stack()) // 10 * (i + 1) self.assertEqual(player.calcpoints(), points2)
def test_calcpoints(self): self.player = Dominion.Player("Annie") # Clear the hand and deck completely self.player.hand = [] self.player.deck = [] self.assertEqual(self.player.calcpoints(), 0) # Estates are worth one point self.player.hand.append(Dominion.Estate()) self.assertEqual(self.player.calcpoints(), 1) # Gardens count as a multiplier of points, but they are not relevant until you have at least 10 victory cards self.player.hand.append(Dominion.Gardens()) self.assertEqual(self.player.calcpoints(), 1) # Add more gardens, to get to the boundary of 10 victory cards n = 0 while n < 8: self.player.hand.append(Dominion.Gardens()) n += 1 # 1 point for the victory point + 1 point for (number of cards / 10) * 9 gardens = 10 self.assertEqual(self.player.calcpoints(), 10)
def setUp(self): # Set Up Test Utility Values self.trash = [] self.player = Dominion.Player('Annie') self.hand = [Dominion.Woodcutter()] * 2 + [Dominion.Gardens()] self.player.played = [] # Initialize action card props self.name = "Adventurer" self.cost = 6 self.actions = 0 self.cards = 0 self.buys = 0 self.coins = 0 # Instantiate Feast and Adventurer Action cards self.Feast_card = Dominion.Feast() self.Adventurer_card = Dominion.Adventurer()
def test_calcpoints(self): #used to calculate Victory Points. #variables player = Dominion.Player("Duke") #empty card collections player.hand = [] player.deck = [] assert len(player.stack()) == 0 # add additional cards to change the expected points to be different # original from deck and stack == 3 player.deck = [Dominion.Province()] * 10 + [Dominion.Duchy( )] * 10 + [Dominion.Gardens()] * 10 # 60 + 30 = 90 + ( 3*10) = 120; 30 Cards #call function playPoints = player.calcpoints() #assert assert playPoints == 120
def test_calcPoints(self): # init data self.dataSetUp() # test before adding action cards self.assertEqual(3, self.player.calcpoints()) # should be 3 from 3 estates # add 2 provinces (6 points each) self.player.deck += [Dominion.Province()] * 2 # test calcPoints self.assertEqual(15, self.player.calcpoints()) # add 2 Duchies (3 points each) self.player.deck += [Dominion.Duchy()] * 2 # test calcPoints self.assertEqual(21, self.player.calcpoints()) # add 6 gardens (2 points each) self.player.deck += [Dominion.Gardens()] * 6 # test calcPoints self.assertEqual(33, self.player.calcpoints())
def getBoxes(nV): """ Returns a box object takes nV as an argument that represents the number of Victory Cards in play """ #Create a box object box = {} box["Woodcutter"] = [Dominion.Woodcutter()] * 10 box["Smithy"] = [Dominion.Smithy()] * 10 box["Laboratory"] = [Dominion.Laboratory()] * 10 box["Village"] = [Dominion.Village()] * 10 box["Festival"] = [Dominion.Festival()] * 10 box["Market"] = [Dominion.Market()] * 10 box["Chancellor"] = [Dominion.Chancellor()] * 10 box["Workshop"] = [Dominion.Workshop()] * 10 box["Moneylender"] = [Dominion.Moneylender()] * 10 box["Chapel"] = [Dominion.Chapel()] * 10 box["Cellar"] = [Dominion.Cellar()] * 10 box["Remodel"] = [Dominion.Remodel()] * 10 box["Adventurer"] = [Dominion.Adventurer()] * 10 box["Feast"] = [Dominion.Feast()] * 10 box["Mine"] = [Dominion.Mine()] * 10 box["Library"] = [Dominion.Library()] * 10 box["Gardens"] = [Dominion.Gardens()] * nV box["Moat"] = [Dominion.Moat()] * 10 box["Council Room"] = [Dominion.Council_Room()] * 10 box["Witch"] = [Dominion.Witch()] * 10 box["Bureaucrat"] = [Dominion.Bureaucrat()] * 10 box["Militia"] = [Dominion.Militia()] * 10 box["Spy"] = [Dominion.Spy()] * 10 box["Thief"] = [Dominion.Thief()] * 10 box["Throne Room"] = [Dominion.Throne_Room()] * 10 return box
box["Smithy"] = [Dominion.Smithy()] * 10 box["Laboratory"] = [Dominion.Laboratory()] * 10 box["Village"] = [Dominion.Village()] * 10 box["Festival"] = [Dominion.Festival()] * 10 box["Market"] = [Dominion.Market()] * 10 box["Chancellor"] = [Dominion.Chancellor()] * 10 box["Workshop"] = [Dominion.Workshop()] * 10 box["Moneylender"] = [Dominion.Moneylender()] * 10 box["Chapel"] = [Dominion.Chapel()] * 10 box["Cellar"] = [Dominion.Cellar()] * 10 box["Remodel"] = [Dominion.Remodel()] * 10 box["Adventurer"] = [Dominion.Adventurer()] * 10 box["Feast"] = [Dominion.Feast()] * 10 box["Mine"] = [Dominion.Mine()] * 10 box["Library"] = [Dominion.Library()] * 10 box["Gardens"] = [Dominion.Gardens()] * nV box["Moat"] = [Dominion.Moat()] * 10 box["Council Room"] = [Dominion.Council_Room()] * 10 box["Witch"] = [Dominion.Witch()] * 10 box["Bureaucrat"] = [Dominion.Bureaucrat()] * 10 box["Militia"] = [Dominion.Militia()] * 10 box["Spy"] = [Dominion.Spy()] * 10 box["Thief"] = [Dominion.Thief()] * 10 box["Throne Room"] = [Dominion.Throne_Room()] * 10 supply_order = { 0: ['Curse', 'Copper'], 2: ['Estate', 'Cellar', 'Chapel', 'Moat'], 3: ['Silver', 'Chancellor', 'Village', 'Woodcutter', 'Workshop'], 4: [ 'Gardens', 'Bureaucrat', 'Feast', 'Militia', 'Moneylender', 'Remodel',
def test_calcpoints(self): self.setUp() #clear all card's in player's deck and hand on setup self.player.deck = [] self.player.hand = [] # check the case where the player has no victory card points = self.player.calcpoints() self.assertEqual(0, points) #add 1 estate card to player's deck #check the case where the player has only 1 victory card in the stack self.player.deck.append(Dominion.Estate()) points = self.player.calcpoints() self.assertEqual(1, points) # add 1 estate card to player's deck and hand each # check the case where the player has only 2 victory cards in the stack self.player.hand.append(Dominion.Estate()) points = self.player.calcpoints() self.assertEqual(2, points) # add 1 duchy card to player's deck and hand each # check the case where the player has only 3 victory cards in the stack # and has a different type of victory card self.player.played.append(Dominion.Duchy()) points = self.player.calcpoints() self.assertEqual(5, points) # add 1 Province card to player's discard pile # check the case where the player has only 4 victory cards in the stack # and has a different type of victory card self.player.discard.append(Dominion.Province()) points = self.player.calcpoints() self.assertEqual(11, points) # add another estate card to player's aside # check the case where the player has only 5 victory cards in the stack # and has a different type of victory card self.player.aside.append(Dominion.Estate()) points = self.player.calcpoints() self.assertEqual(12, points) # add another estate card to player's aside # check the case where the player has only 6 victory cards in the stack self.player.hold.append(Dominion.Estate()) points = self.player.calcpoints() self.assertEqual(13, points) # add a garden card to player's hand # check the case where the player has the garden card in the stack self.player.deck.append(Dominion.Gardens()) points = self.player.calcpoints() self.assertEqual(13, points) # add 4 other victory cards so that the Garden card is calculated in the points self.player.deck.append(Dominion.Estate()) self.player.deck.append(Dominion.Estate()) self.player.deck.append(Dominion.Estate()) self.player.deck.append(Dominion.Estate()) points = self.player.calcpoints() self.assertEqual(18, points) # add another garden card to player's hand # check the case where the player has the garden card in the stack self.player.deck.append(Dominion.Gardens()) points = self.player.calcpoints() self.assertEqual(19, points)
box["Laboratory"] = [Dominion.Smithy()] * 10 box["Village"] = [Dominion.Laboratory()] * 10 box["Festival"] = [Dominion.Village()] * 10 box["Market"] = [Dominion.Festival()] * 10 box["Chancellor"] = [Dominion.Market()] * 10 box["Workshop"] = [Dominion.Chancellor()] * 10 box["Moneylender"] = [Dominion.Workshop()] * 10 box["Chapel"] = [Dominion.Moneylender()] * 10 box["Cellar"] = [Dominion.Chapel()] * 10 box["Remodel"] = [Dominion.Cellar()] * 10 box["Adventurer"] = [Dominion.Remodel()] * 10 box["Feast"] = [Dominion.Adventurer()] * 10 box["Mine"] = [Dominion.Feast()] * 10 box["Library"] = [Dominion.Mine()] * 10 box["Gardens"] = [Dominion.Library()] * 10 box["Moat"] = [Dominion.Gardens()] * nV box["Council Room"] = [Dominion.Moat()] * 10 box["Witch"] = [Dominion.Council_Room()] * 10 box["Bureaucrat"] = [Dominion.Witch()] * 10 box["Militia"] = [Dominion.Bureaucrat()] * 10 box["Spy"] = [Dominion.Militia()] * 10 box["Thief"] = [Dominion.Spy()] * 10 box["Throne Room"] = [Dominion.Thief()] * 10 # Get supply order supply_order = testUtility.getSupplyOrder() # Pick 10 cards from box to be in the supply. boxlist = testUtility.getBoxList(box) random10 = testUtility.getRandom10(boxlist) supply = testUtility.getSupply(box, random10)