Ejemplo n.º 1
0
    def test_use(self):
        # define variables
        # call function
        # assert calls

        #use calls for a player and trash.
        # thus we need a trash bin and a player
        # we can then test the size of each deck respectively to ensure use is properly used

        #initalize variables
        # note assert to make sure they have nothing in them
        player = Dominion.Player("Duke")
        trash = []
        #assert len(trash) == 0
        assert len(player.played) == 0
        assert len(player.hand) == 5
        actionCard = Dominion.Action_card("MegaCard",1, 1, 1, 1, 1)
        player.hand.append(actionCard)
        assert len(player.hand) == 6


        #call function
        actionCard.use(player, trash)

        #assert
        assert len(player.played) == 1
    def test_use(self):
        #init data
        self.dataSetUp()
        cardName = "Smithy"
        cost = 4
        actions = 0
        cards = 3
        buys = 0
        coins = 0

        #initiate a Smithy action card object
        card = Dominion.Action_card(cardName,cost,actions,cards,buys,coins,)

        #add card to hand
        self.player.hand.append(card)

        #Assert player has 6 cards in hand and has played no cards
        self.assertEqual(0, len(self.player.played))
        self.assertEqual(6, len(self.player.hand))

        #use the card
        card.use(self.player, self.trash)

        #Assert changes made
        self.assertEqual(1, len(self.player.played))
        self.assertEqual(5, len(self.player.hand))
        self.assertEqual("Smithy", self.player.played[0].name)
    def test_augment(self):
        # init data
        self.dataSetUp()
        cardName = "Smithy"
        cost = 4
        actions = 0
        cards = 3
        buys = 0
        coins = 0

        #do a trun to init some vars
        sys.stdin = StringIO('\n') #force hitting enter
        self.player.turn([], self.supply, self.trash)

        # initiate a Smithy action card object
        card = Dominion.Action_card(cardName, cost, actions, cards, buys, coins, )

        # add card to hand
        self.player.hand.append(card)

        # Assert player has 6 cards in hand and has played no cards
        self.assertEqual(0, len(self.player.played))
        self.assertEqual(6, len(self.player.hand))

        # use the card
        card.use(self.player, self.trash)
        card.augment(self.player)

        # Assert changes made
        self.assertEqual(1, len(self.player.played)) # played 1 card
        self.assertEqual(5 + cards, len(self.player.hand)) # drew 3 cards
        self.assertEqual(1 + actions, self.player.actions) # added 0 actions
        self.assertEqual(1 + buys, self.player.buys) # added 0 buys
Ejemplo n.º 4
0
 def testInitialization(self):
     actionCard = Dominion.Action_card('Test Card', 3, 1, 0, 4, 5)
     self.assertEqual('Test Card', actionCard.name)
     self.assertEqual(3, actionCard.cost)
     self.assertEqual(1, actionCard.actions)
     self.assertEqual(0, actionCard.cards)
     self.assertEqual(4, actionCard.buys)
     self.assertEqual(5, actionCard.coins)
Ejemplo n.º 5
0
 def setupLaboratoryCard(self):
     name = "Laboratory"
     cost = 5
     actions = 1
     cards = 2
     buys = 5
     coins = 4
     return Dominion.Action_card(name, cost, actions, cards, buys, coins)
Ejemplo n.º 6
0
 def setupFestivalCard(self):
     name = "Festival"
     cost = 5
     actions = 2
     cards = 0
     buys = 1
     coins = 2
     return Dominion.Action_card(name, cost, actions, cards, buys, coins)
Ejemplo n.º 7
0
 def test_init(self):
     # test case that each variable is initialized
     ac = Dominion.Action_card('TESTCARD', 0, 1, 2, 3, 4)
     self.assertEqual('TESTCARD', ac.name)
     self.assertEqual(0, ac.cost)
     self.assertEqual(1, ac.actions)
     self.assertEqual(2, ac.cards)
     self.assertEqual(3, ac.buys)
     self.assertEqual(4, ac.coins)
Ejemplo n.º 8
0
 def testActionCardInit(self):
     woodcutter = Dominion.Woodcutter()
     smithy = Dominion.Smithy()
     ac = Dominion.Action_card(self, "Woodcutter", 3, 0,  1, 2)
     ac.cards = [woodcutter, smithy]
     ac.coins = 2
     ac.actions = "Karate Chop"
     assert ac.actions == "Karate Chop"
     assert ac.coins == 2
     assert len(ac.cards) == 2
Ejemplo n.º 9
0
    def test_use(self):
        ac = Dominion.Action_card('TESTCARD', 0, 0, 0, 0, 0)
        player = Dominion.Player('Annie')
        trash = []

        # test case that after use method, action card is moved from hand to played
        player.hand.append(ac)
        ac.use(player, trash)
        self.assertIn(ac, player.played)
        self.assertNotIn(ac, player.hand)
Ejemplo n.º 10
0
 def test_init(self):
     self.setUp()
     card = Dominion.Action_card(self.name, 0, self.actions, 0, 5,
                                 self.coins)
     self.assertEqual("Blueberry", card.name)
     self.assertEqual(0, card.cost)
     self.assertEqual(3, card.actions)
     self.assertEqual(0, card.cards)
     self.assertEqual(5, card.buys)
     self.assertEqual(10, card.coins)
Ejemplo n.º 11
0
 def makeMegaCard(self):
     # for the sake of calculations mega card has a set value of 1 for all and name "mega Card"
     #make variables
     cost = 1
     actions = 1
     cards = 1
     buys = 1
     coins = 1
     #call function
     actionCard = Dominion.Action_card("MegaCard", cost, actions, cards,
                                       buys, coins)
     return actionCard
Ejemplo n.º 12
0
    def test_augment(self):
        ac = Dominion.Action_card('TESTCARD', 1, 1, 1, 1, 1)
        player = Dominion.Player('Annie')
        player.actions = player.buys = player.purse = 1
        pActions = player.actions
        pBuys = player.buys
        pPurse = player.purse

        # test case to show player values have changed and have player has drawn cards
        ac.augment(player)
        self.assertNotEqual(pActions - 1, player.actions)
        self.assertNotEqual(pBuys - 1, player.buys)
        self.assertNotEqual(pPurse - 1, player.purse)
Ejemplo n.º 13
0
 def test_use(self):
     for n in range(TestAction_card.NUM_TRIALS):
         player = Dominion.Player("Bob")
         trash = []
         cost, actions, cards, buys, coins = [
             random.randint(1, 30) for i in range(5)
         ]
         card = Dominion.Action_card("name", cost, actions, cards, buys,
                                     coins)
         player.hand.append(card)
         card.use(player, trash)
         self.assertTrue(card not in player.hand)
         self.assertTrue(card in player.played)
Ejemplo n.º 14
0
 def test_initialization(self):
     for n in range(TestAction_card.NUM_TRIALS):
         cost, actions, cards, buys, coins = [
             random.randint(1, 30) for i in range(5)
         ]
         card = Dominion.Action_card("name", cost, actions, cards, buys,
                                     coins)
         self.assertEqual(card.name, "name")
         self.assertEqual(card.category, "action")
         self.assertEqual(card.cost, cost)
         self.assertEqual(card.actions, actions)
         self.assertEqual(card.cards, cards)
         self.assertEqual(card.buys, buys)
         self.assertEqual(card.coins, coins)
Ejemplo n.º 15
0
 def test_action_balance(self):
     player = Dominion.Player("Bob")
     self.assertEqual(player.action_balance(), 0.0)
     for i in range(TestPlayer.NUM_TRIALS):
         cost, actions, cards, buys, coins = [
             random.randint(1, 30) for i in range(5)
         ]
         card = Dominion.Action_card("name", cost, actions, cards, buys,
                                     coins)
         player.deck.append(card)
         balance = 0
         for c in player.stack():
             if c.category == "action":
                 balance = balance - 1 + c.actions
         balance = 70 * balance / len(player.stack())
         self.assertEqual(player.action_balance(), balance)
Ejemplo n.º 16
0
 def test_use(self):
     self = Dominion.Woodcutter
     player = Dominion.Player("Annie")
     trash = []
     woodcutter = Dominion.Woodcutter()
     smithy = Dominion.Smithy()
     player.hand.append(woodcutter)
     ac = Dominion.Action_card(self, player.name, 3, 0, 1, 2)
     ac.cards = [woodcutter, smithy]
     ac.coins = 2
     ac.actions = "Karate Chop"
     assert ac.actions == "Karate Chop"
     assert ac.coins == 2
     assert len(ac.cards) == 2
     ac = player.hand[1]
     ac.use(self, trash)
     assert len(ac.cards) == 2
Ejemplo n.º 17
0
 def test_augment(self):
     for n in range(TestAction_card.NUM_TRIALS):
         player = Dominion.Player("Bob")
         player.actions = 0
         player.buys = 0
         player.purse = 0
         hand = len(player.hand)
         cost, actions, cards, buys, coins = [
             random.randint(1, 30) for i in range(5)
         ]
         card = Dominion.Action_card("name", cost, actions, cards, buys,
                                     coins)
         card.augment(player)
         self.assertEqual(player.actions, card.actions)
         self.assertEqual(player.buys, card.buys)
         self.assertEqual(player.purse, card.coins)
         self.assertEqual(len(player.hand) - hand, min(card.cards, 5))
Ejemplo n.º 18
0
 def test_use(self):
     self.setUp()
     # Test with feast card
     self.player.hand.insert(0, Dominion.Feast())
     testCard = Dominion.Feast()
     self.assertEqual(testCard.name, self.player.hand[0].name)
     Dominion.Action_card.use(self.player.hand[0], self.player, self.trash)
     self.assertEqual(testCard.name, self.player.played[0].name)
     self.assertEqual(5, len(self.player.hand))
     # test with madeup blueberry card
     card = Dominion.Action_card(self.name, 0, self.actions, 0, 5,
                                 self.coins)
     self.player.hand.insert(0, card)
     self.assertEqual(card.name, self.player.hand[0].name)
     Dominion.Action_card.use(self.player.hand[0], self.player, self.trash)
     self.assertEqual(card.name, self.player.played[1].name)
     self.assertEqual(5, len(self.player.hand))
Ejemplo n.º 19
0
 def test_augment(self):
     self.setUp()
     #add action card to player hand and test intital values
     card = Dominion.Action_card(self.name, 0, self.actions, 10, 5,
                                 self.coins)
     self.player.hand.insert(0, card)
     self.assertEqual(3, self.player.hand[0].actions)
     self.assertEqual(5, self.player.hand[0].buys)
     self.assertEqual(10, self.player.hand[0].coins)
     self.assertEqual(10, self.player.hand[0].cards)
     self.assertEqual(11, len(self.player.stack()))
     self.player.actions = 0
     self.player.buys = 0
     self.player.purse = 0
     Dominion.Action_card.augment(self.player.hand[0], self.player)
     self.assertEqual(3, self.player.actions)
     self.assertEqual(5, self.player.buys)
     self.assertEqual(10, self.player.purse)
Ejemplo n.º 20
0
    def test_init(self):

        #make variables
        cost = 1
        actions = 1
        cards = 1
        buys = 1
        coins = 1
        #call function
        actionCard = Dominion.Action_card("MegaCard",cost,actions,cards,buys,coins)

        # assert
        assert actionCard.name == "MegaCard"
        assert actionCard.cost == 1
        assert actionCard.actions == 1
        assert actionCard.cards == 1
        assert actionCard.buys == 1
        assert actionCard.coins == 1
    def test_init(self):
        #init data
        self.dataSetUp()
        cardName = "Smithy"
        cost = 4
        actions = 0
        cards = 3
        buys = 0
        coins = 0

        #initiate a Smithy action card object
        card = Dominion.Action_card(cardName,cost,actions,cards,buys,coins,)

        #verify that card class variables have the expected values
        self.assertEqual(cardName, card.name)
        self.assertEqual(cost, card.cost)
        self.assertEqual(actions, card.actions)
        self.assertEqual(cards, card.cards)
        self.assertEqual(buys, card.buys)
        self.assertEqual(coins, card.coins)
        self.assertEqual("action", card.category)
Ejemplo n.º 22
0
    def test_augment(self):
        #Think augment as the effect of each action card
        # when played it will alter the player's stats by the level of the card.
        # use it similarly as use.
        player = Dominion.Player("Duke")
        actionCard = Dominion.Action_card("MegaCard",1, 1, 1, 1, 1)
        player.actions = 0
        player.buys = 0
        player.purse = 0
        assert player.actions == 0
        assert player.buys == 0
        assert player.purse == 0
        assert len(player.hand) == 5

        #call function
        actionCard.augment(player)
        #because the cards are all plus 1
        assert player.actions == 1
        assert player.buys == 1
        assert player.purse == 1
        assert len(player.hand) == 6
Ejemplo n.º 23
0
 def setUp(self):
     self.player = Dominion.Player('Annie')
     self.testActionCard = Dominion.Action_card("Run", 50, 10, 0, 5, 10)