Esempio n. 1
0
    def test_fountain_fail_to_start_out_of_town(self):
        """Try to start out of town with Fountain card when we don't
        have enough Craftsman actions.
        """
        d = TestDeck()

        game = test_setup.two_player_lead('Craftsman',
                buildings=[['Fountain'],[]],
                deck=d)

        p1, p2 = game.players

        game.in_town_sites = ['Rubble']
        game.out_of_town_sites = ['Rubble', 'Wood']

        game.library.set_content([d.dock0, d.dock1])

        a = message.GameAction(message.USEFOUNTAIN, True)
        game.handle(a)

        self.assertEqual(p1.fountain_card, d.dock0)
        self.assertEqual(game.expected_action, message.FOUNTAIN)

        mon = Monitor()
        mon.modified(game)

        a = message.GameAction(message.FOUNTAIN, d.dock0, None, 'Wood')

        with self.assertRaises(GTRError):
            game.handle(a)

        self.assertFalse(mon.modified(game))
Esempio n. 2
0
    def test_fountain_fail_to_start_out_of_town(self):
        """Try to start out of town with Fountain card when we don't
        have enough Craftsman actions.
        """
        d = TestDeck()

        game = test_setup.two_player_lead('Craftsman',
                                          buildings=[['Fountain'], []],
                                          deck=d)

        p1, p2 = game.players

        game.in_town_sites = ['Rubble']
        game.out_of_town_sites = ['Rubble', 'Wood']

        game.library.set_content([d.dock0, d.dock1])

        a = message.GameAction(message.USEFOUNTAIN, True)
        game.handle(a)

        self.assertEqual(p1.fountain_card, d.dock0)
        self.assertEqual(game.expected_action, message.FOUNTAIN)

        mon = Monitor()
        mon.modified(game)

        a = message.GameAction(message.FOUNTAIN, d.dock0, None, 'Wood')

        with self.assertRaises(GTRError):
            game.handle(a)

        self.assertFalse(mon.modified(game))
Esempio n. 3
0
    def test_bath_reveal_same_card_twice(self):
        d = self.deck

        a = message.GameAction(message.PATRONFROMPOOL, d.shrine0)
        self.game.handle(a)

        a = message.GameAction(message.LEGIONARY, d.dock0)
        self.game.handle(a)

        a = message.GameAction(message.TAKEPOOLCARDS)
        self.game.handle(a)

        a = message.GameAction(message.GIVECARDS)
        self.game.handle(a)

        self.assertIn(d.dock0, self.p1.revealed)

        a = message.GameAction(message.PATRONFROMPOOL, d.road0)
        self.game.handle(a)

        a = message.GameAction(message.LABORER)
        self.game.handle(a)

        a = message.GameAction(message.PATRONFROMPOOL, d.shrine1)
        self.game.handle(a)

        a = message.GameAction(message.LEGIONARY, d.dock0)

        mon = Monitor()
        mon.modified(self.game)

        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 4
0
    def test_bath_reveal_same_card_twice(self):
        d = self.deck

        a = message.GameAction(message.PATRONFROMPOOL, d.shrine0)
        self.game.handle(a)

        a = message.GameAction(message.LEGIONARY, d.dock0)
        self.game.handle(a)

        a = message.GameAction(message.TAKEPOOLCARDS)
        self.game.handle(a)

        a = message.GameAction(message.GIVECARDS)
        self.game.handle(a)

        self.assertIn(d.dock0, self.p1.revealed)

        a = message.GameAction(message.PATRONFROMPOOL, d.road0)
        self.game.handle(a)

        a = message.GameAction(message.LABORER)
        self.game.handle(a)

        a = message.GameAction(message.PATRONFROMPOOL, d.shrine1)
        self.game.handle(a)

        a = message.GameAction(message.LEGIONARY, d.dock0)

        mon = Monitor()
        mon.modified(self.game)

        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 5
0
    def test_merchant_non_existent_card(self):
        """ Take a non-existent card from the stockpile with merchant action.

        This invalid game action should leave the game state unchanged.
        """
        d = self.deck
        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.MERCHANT, False, d.atrium0)
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 6
0
    def test_demand_non_existent_card(self):
        """Demand card that we don't have.
        """
        d = self.deck
        self.p1.hand.set_content([d.atrium0])

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.LEGIONARY, d.latrine0)
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 7
0
    def test_demand_non_existent_card(self):
        """Demand card that we don't have.
        """
        d = self.deck
        self.p1.hand.set_content([d.atrium0])

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.LEGIONARY, d.latrine0)
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 8
0
    def test_merchant_non_existent_card(self):
        """ Take a non-existent card from the stockpile with merchant action.

        This invalid game action should leave the game state unchanged.
        """
        d = self.deck
        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.MERCHANT, False, d.atrium0)
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 9
0
    def test_follow_role_with_nonexistent_card(self):
        """Follow Laborer specifying a non-existent card.

        This bad action should not change anything about the game state.
        """
        latrine = cm.get_card('Latrine')
        self.p2.hand.set_content([])

        a = message.GameAction(message.FOLLOWROLE, 1, latrine)

        # Monitor the gamestate for any changes
        mon = Monitor()
        mon.modified(self.game)

        self.assertFalse(mon.modified(self.game))
Esempio n. 10
0
    def test_petition_with_nonexistent_cards(self):
        """Tests petition with cards not in players hand. This illegal
        action should leave the game state unchanged.
        """
        cards = cm.get_cards(['Road', 'Road', 'Road'])
        #self.p1.hand.set_content(cards)

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.LEADROLE, 'Craftsman', 1, *cards)
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 11
0
    def test_petition_with_nonmatching_cards(self):
        """Tests petition with 3 orders cards of different roles. This illegal
        action should leave the game state unchanged.
        """
        cards = cm.get_cards(['Road', 'Insula', 'Atrium'])
        self.p1.hand.set_content(cards)

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.LEADROLE, 'Craftsman', 1, *cards)
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 12
0
    def test_petition_with_too_few_cards(self):
        """Tests petition with 2 orders cards without a circus. This illegal
        action should leave the game state unchanged.
        """
        cards = cm.get_cards(['Road'] * 2)
        self.p1.hand.set_content(cards)

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.LEADROLE, 'Craftsman', 1, *cards)
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 13
0
    def test_thinker_from_empty_jack_pile(self):
        """Raise GTRError if thinker from empty Jack pile is requested.
        """
        d = self.deck

        self.game.jacks.set_content([])
        a = message.GameAction(message.THINKERTYPE, True)

        mon = Monitor()
        mon.modified(self.game)

        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 14
0
    def test_petition_with_too_few_cards(self):
        """Tests petition with 2 orders cards without a circus. This illegal
        action should leave the game state unchanged.
        """
        cards = cm.get_cards(['Road']*2)
        self.p1.hand.set_content(cards)

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.LEADROLE, 'Craftsman', 1, *cards)
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 15
0
    def test_petition_with_nonexistent_cards(self):
        """Tests petition with cards not in players hand. This illegal
        action should leave the game state unchanged.
        """
        cards = cm.get_cards(['Road', 'Road', 'Road'])
        #self.p1.hand.set_content(cards)

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.LEADROLE, 'Craftsman', 1, *cards)
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 16
0
    def test_demand_jack(self):
        """Demand Jack illegally. This should not change the game state.
        """
        d = self.deck
        self.p1.hand.set_content([d.atrium0, d.jack1])
        self.p2.hand.set_content([d.latrine0])

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.LEGIONARY, d.jack1)
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 17
0
    def test_demand_jack(self):
        """Demand Jack illegally. This should not change the game state.
        """
        d = self.deck
        self.p1.hand.set_content([d.atrium0, d.jack1])
        self.p2.hand.set_content([d.latrine0])

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.LEGIONARY, d.jack1)
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 18
0
    def test_thinker_from_empty_jack_pile(self):
        """Raise GTRError if thinker from empty Jack pile is requested.
        """
        d = self.deck

        self.game.jacks.set_content([])
        a = message.GameAction(message.THINKERTYPE, True)

        mon = Monitor()
        mon.modified(self.game)

        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 19
0
    def test_petition_with_nonmatching_cards(self):
        """Tests petition with 3 orders cards of different roles. This illegal
        action should leave the game state unchanged.
        """
        cards = cm.get_cards(['Road', 'Insula', 'Atrium'])
        self.p1.hand.set_content(cards)

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.LEADROLE, 'Craftsman', 1, *cards)
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 20
0
    def test_follow_role_with_nonexistent_card(self):
        """Follow Laborer specifying a non-existent card.

        This bad action should not change anything about the game state.
        """
        latrine = cm.get_card('Latrine')
        self.p2.hand.set_content([])
        
        a = message.GameAction(message.FOLLOWROLE, 1, latrine)
        
        # Monitor the gamestate for any changes
        mon = Monitor()
        mon.modified(self.game)

        self.assertFalse(mon.modified(self.game))
Esempio n. 21
0
    def test_non_existent_card(self):
        """ Use a non-existent card.

        This invalid game action should leave the game state unchanged.
        """
        atrium, latrine = cm.get_cards(['Atrium', 'Latrine'])
        self.p1.hand.set_content([atrium])

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.CRAFTSMAN, latrine, None, 'Rubble')
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 22
0
    def test_laborer_non_existent_card(self):
        """Take a non-existent card from the pool with laborer action.

        This invalid game action should leave the game state unchanged.
        """
        d = self.deck
        self.game.pool.set_content([d.atrium0])

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.LABORER, d.dock0)
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 23
0
    def test_wrong_site(self):
        """ Use the wrong site to start a building.

        This invalid game action should leave the game state unchanged.
        """
        atrium = cm.get_card('Atrium')
        self.p1.hand.set_content([atrium])

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.CRAFTSMAN, atrium, None, 'Rubble')
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 24
0
    def test_non_existent_card(self):
        """ Use a non-existent card.

        This invalid game action should leave the game state unchanged.
        """
        atrium, latrine = cm.get_cards(['Atrium', 'Latrine'])
        self.p1.hand.set_content([atrium])

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.CRAFTSMAN, latrine, None, 'Rubble')
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 25
0
    def test_add_to_nonexistent_building(self):
        """ Add a valid material to a building that the player doesn't own.

        This invalid game action should leave the game state unchanged.
        """
        atrium, foundry = cm.get_cards(['Atrium', 'Foundry'])
        self.p1.hand.set_content([atrium])

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.CRAFTSMAN, foundry, atrium, None)
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 26
0
    def test_specifying_material_and_site(self):
        """ Invalid craftsman action specifying both a material and a site.

        This invalid game action should leave the game state unchanged.
        """
        atrium, foundry = cm.get_cards(['Atrium', 'Foundry'])
        self.p1.hand.set_content([atrium])

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.CRAFTSMAN, foundry, atrium, 'Brick')
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 27
0
    def test_specifying_material_and_site(self):
        """ Invalid craftsman action specifying both a material and a site.

        This invalid game action should leave the game state unchanged.
        """
        atrium, foundry = cm.get_cards(['Atrium', 'Foundry'])
        self.p1.hand.set_content([atrium])

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.CRAFTSMAN, foundry, atrium, 'Brick')
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 28
0
    def test_add_to_nonexistent_building(self):
        """ Add a valid material to a building that the player doesn't own.

        This invalid game action should leave the game state unchanged.
        """
        atrium, foundry = cm.get_cards(['Atrium', 'Foundry'])
        self.p1.hand.set_content([atrium])

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.CRAFTSMAN, foundry, atrium, None)
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 29
0
    def test_patron_non_existent_card(self):
        """ Take a non-existent card from the pool with patron action.

        This invalid game action should leave the game state unchanged.
        """
        atrium, dock = cm.get_cards(['Atrium', 'Dock'])
        self.game.pool.set_content([atrium])

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.PATRONFROMPOOL, dock)
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 30
0
    def test_wrong_site(self):
        """ Use the wrong site to start a building.

        This invalid game action should leave the game state unchanged.
        """
        atrium = cm.get_card('Atrium')
        self.p1.hand.set_content([atrium])

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.CRAFTSMAN, atrium, None, 'Rubble')
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 31
0
    def test_patron_non_existent_card(self):
        """ Take a non-existent card from the pool with patron action.

        This invalid game action should leave the game state unchanged.
        """
        atrium, dock = cm.get_cards(['Atrium', 'Dock'])
        self.game.pool.set_content([atrium])

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.PATRONFROMPOOL, dock)
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 32
0
    def test_merchant_at_vault_limit(self):
        """ Merchant a card when the vault limit has been reached.

        This invalid game action should leave the game state unchanged.
        """
        d = self.deck
        self.p1.stockpile.set_content([d.atrium0])
        self.p1.vault.set_content([d.insula, d.dock])

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.MERCHANT, False, d.atrium0)
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 33
0
    def test_merchant_at_vault_limit(self):
        """ Merchant a card when the vault limit has been reached.

        This invalid game action should leave the game state unchanged.
        """
        d = self.deck
        self.p1.stockpile.set_content([d.atrium0])
        self.p1.vault.set_content([d.insula, d.dock])

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.MERCHANT, False, d.atrium0)
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 34
0
    def test_patron_at_clientele_limit(self):
        """ Patron a card when the vault limit has been reached.

        This invalid game action should leave the game state unchanged.
        """
        atrium, insula, dock = cm.get_cards(['Atrium', 'Insula', 'Dock'])
        self.game.pool.set_content([atrium])
        self.p1.clientele.set_content([insula, dock])

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.PATRONFROMPOOL, atrium)
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 35
0
    def test_patron_at_clientele_limit(self):
        """ Patron a card when the vault limit has been reached.

        This invalid game action should leave the game state unchanged.
        """
        atrium, insula, dock = cm.get_cards(['Atrium', 'Insula', 'Dock'])
        self.game.pool.set_content([atrium])
        self.p1.clientele.set_content([insula, dock])

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.PATRONFROMPOOL, atrium)
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 36
0
    def test_use_card_that_started_in_hand(self):
        """Using a card that was in your hand but is no longer is an error.
        """
        d = self.deck = TestDeck()
        self.game = test_setup.two_player_lead('Patron', deck=self.deck,
                buildings=[['Bath', 'Aqueduct'],[]],
                clientele=[['Temple', 'Temple', 'Temple'],[]])

        self.game.pool.set_content([d.atrium0, d.atrium1, d.atrium2, d.foundry0])
        self.p1, self.p2 = self.game.players
        self.p1.influence = ['Stone', 'Stone']

        self.p1.hand.set_content([d.villa0, d.garden0])

        a = message.GameAction(message.PATRONFROMPOOL, d.atrium0)
        self.game.handle(a)

        a = message.GameAction(message.LEGIONARY, d.villa0)
        self.game.handle(a)

        a = message.GameAction(message.TAKEPOOLCARDS)
        self.game.handle(a)

        a = message.GameAction(message.GIVECARDS)
        self.game.handle(a)

        a = message.GameAction(message.PATRONFROMHAND, d.garden0)
        self.game.handle(a)

        a = message.GameAction(message.MERCHANT, False)
        self.game.handle(a)

        a = message.GameAction(message.PATRONFROMPOOL, d.atrium1)
        self.game.handle(a)

        self.assertEqual(self.game.expected_action, message.LEGIONARY)

        a = message.GameAction(message.LEGIONARY, d.garden0)

        mon = Monitor()
        mon.modified(self.game)

        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 37
0
    def test_illegal_out_of_town(self):
        """ Start a building and add a material.
        """
        bridge = cm.get_card('Bridge')
        self.p1.hand.set_content([bridge])

        # Empty the in-town sites of Concrete
        self.game.in_town_sites = ['Rubble']

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.ARCHITECT, bridge, None, 'Concrete')
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 38
0
    def test_illegal_out_of_town(self):
        """ Start a building and add a material.
        """
        bridge = cm.get_card('Bridge')
        self.p1.hand.set_content([bridge])

        # Empty the in-town sites of Concrete
        self.game.in_town_sites = ['Rubble']

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.ARCHITECT, bridge, None, 'Concrete')
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 39
0
    def test_not_enough_cards_and_actions(self):
        """Lead a role without enough cards.
        """
        d = self.deck

        a = message.GameAction(message.LEADROLE, 'Laborer', 0, d.latrine0)

        mon = Monitor()
        mon.modified(self.game)
        with self.assertRaises(GTRError) as cm:
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))

        a = message.GameAction(message.LEADROLE, 'Laborer', 1)
        with self.assertRaises(GTRError) as cm:
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))

        a = message.GameAction(message.LEADROLE, 'Laborer', 0)
        with self.assertRaises(GTRError) as cm:
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 40
0
    def test_merchant_past_higher_vault_limit(self):
        """ Merchant a card above a higher vault limit.

        This invalid game action should leave the game state unchanged.
        """
        d = self.deck
        self.p1.stockpile.set_content([d.atrium0])
        self.p1.vault.set_content([d.insula, d.dock, d.palisade])
        self.p1.influence.append('Wood')

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.MERCHANT, False, d.atrium0)
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 41
0
    def test_patron_past_higher_clientele_limit(self):
        """ Patron a card above a higher vault limit.

        This invalid game action should leave the game state unchanged.
        """
        atrium, insula, dock, palisade = cm.get_cards(['Atrium', 'Insula', 'Dock', 'Palisade'])
        self.game.pool.set_content([atrium])
        self.p1.clientele.set_content([insula, dock, palisade])
        self.p1.influence.append('Wood')

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.PATRONFROMPOOL, atrium)
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 42
0
    def test_follow_role_with_illegal_petition(self):
        """ Follow Laborer by petition of the wrong number of Laborer cards.

        This bad action should not change anything about the game state.
        """
        cards = latrine, road, insula = cm.get_cards(['Latrine', 'Road', 'Insula'])
        self.p2.hand.set_content(cards)
        
        a = message.GameAction(message.FOLLOWROLE, 1, latrine, insula)

        # Monitor the gamestate for any changes
        mon = Monitor()
        mon.modified(self.game)

        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 43
0
    def test_demand_more_than_allowed(self):
        """Demand more cards than p1 has legionary actions.
        """
        d = self.deck
        self.p1.hand.set_content([d.atrium0, d.shrine0, d.road0])
        self.p2.hand.set_content([d.foundry0])

        self.assertEqual(self.game.legionary_count, 2)

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.LEGIONARY, d.atrium0, d.shrine0, d.road0)

        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 44
0
    def test_illegal_out_of_town(self):
        """Try to start a building out of town without two actions.

        This invalid game action should leave the game state unchanged.
        """
        atrium = cm.get_card('Atrium')
        self.p1.hand.set_content([atrium])

        self.game.in_town_sites = ['Rubble']

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.CRAFTSMAN, atrium, None, 'Brick')
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 45
0
    def test_illegal_out_of_town(self):
        """Try to start a building out of town without two actions.

        This invalid game action should leave the game state unchanged.
        """
        atrium = cm.get_card('Atrium')
        self.p1.hand.set_content([atrium])

        self.game.in_town_sites = ['Rubble']

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.CRAFTSMAN, atrium, None, 'Brick')
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 46
0
    def test_follow_role_with_card_of_different_role(self):
        """ Follow Laborer specifying a card of the wrong role.

        This bad action should not change anything about the game state.
        """
        atrium = cm.get_card('Atrium')
        self.p2.hand.set_content([atrium])
        
        a = message.GameAction(message.FOLLOWROLE, 1, atrium)
        
        # Monitor the gamestate for any changes
        mon = Monitor()
        mon.modified(self.game)

        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 47
0
    def test_merchant_past_higher_vault_limit(self):
        """ Merchant a card above a higher vault limit.

        This invalid game action should leave the game state unchanged.
        """
        d = self.deck
        self.p1.stockpile.set_content([d.atrium0])
        self.p1.vault.set_content([d.insula, d.dock, d.palisade])
        self.p1.influence.append('Wood')

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.MERCHANT, False, d.atrium0)
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 48
0
    def test_follow_role_with_card_of_different_role(self):
        """ Follow Laborer specifying a card of the wrong role.

        This bad action should not change anything about the game state.
        """
        atrium = cm.get_card('Atrium')
        self.p2.hand.set_content([atrium])

        a = message.GameAction(message.FOLLOWROLE, 1, atrium)

        # Monitor the gamestate for any changes
        mon = Monitor()
        mon.modified(self.game)

        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 49
0
    def test_follow_with_too_few_cards_and_actions(self):
        """Follow with not enough cards or action specified
        """
        d = self.deck
        self.p2.hand.set_content([d.latrine0])

        a = message.GameAction(message.FOLLOWROLE, 0, d.latrine0)
        mon = Monitor()
        mon.modified(self.game)
        with self.assertRaises(GTRError) as cm:
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))

        a = message.GameAction(message.FOLLOWROLE, 1)
        with self.assertRaises(GTRError) as cm:
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 50
0
    def test_follow_role_with_illegal_petition(self):
        """ Follow Laborer by petition of the wrong number of Laborer cards.

        This bad action should not change anything about the game state.
        """
        cards = latrine, road, insula = cm.get_cards(
            ['Latrine', 'Road', 'Insula'])
        self.p2.hand.set_content(cards)

        a = message.GameAction(message.FOLLOWROLE, 1, latrine, insula)

        # Monitor the gamestate for any changes
        mon = Monitor()
        mon.modified(self.game)

        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 51
0
    def test_demand_more_than_allowed(self):
        """Demand more cards than p1 has legionary actions.
        """
        d = self.deck
        self.p1.hand.set_content([d.atrium0, d.shrine0, d.road0])
        self.p2.hand.set_content([d.foundry0])

        self.assertEqual(self.game.legionary_count, 2)

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.LEGIONARY, d.atrium0, d.shrine0,
                               d.road0)

        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 52
0
    def test_patron_past_higher_clientele_limit(self):
        """ Patron a card above a higher vault limit.

        This invalid game action should leave the game state unchanged.
        """
        atrium, insula, dock, palisade = cm.get_cards(
            ['Atrium', 'Insula', 'Dock', 'Palisade'])
        self.game.pool.set_content([atrium])
        self.p1.clientele.set_content([insula, dock, palisade])
        self.p1.influence.append('Wood')

        mon = Monitor()
        mon.modified(self.game)

        a = message.GameAction(message.PATRONFROMPOOL, atrium)
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 53
0
    def test_thinker_for_too_many_jacks(self):
        """ Thinker for a Jack with an empty Jack pile

        This bad action should not change anything about the game state.
        """
        a = message.GameAction(message.THINKERORLEAD, True)
        b = message.GameAction(message.THINKERTYPE, True)

        self.game.jacks.set_content([])

        self.game.handle(a)

        # Monitor the gamestate for any changes
        mon = Monitor()
        mon.modified(self.game)

        # Player 1
        with self.assertRaises(GTRError):
            self.game.handle(b)

        self.assertFalse(mon.modified(self.game))
Esempio n. 54
0
    def test_thinker_for_too_many_jacks(self):
        """ Thinker for a Jack with an empty Jack pile

        This bad action should not change anything about the game state.
        """
        a = message.GameAction(message.THINKERORLEAD, True)
        b = message.GameAction(message.THINKERTYPE, True)

        self.game.jacks.set_content([])

        self.game.handle(a)

        # Monitor the gamestate for any changes
        mon = Monitor()
        mon.modified(self.game)

        # Player 1
        with self.assertRaises(GTRError):
            self.game.handle(b)

        self.assertFalse(mon.modified(self.game))
Esempio n. 55
0
    def test_coliseum_at_vault_limit_illegal_actions(self):
        """TAKECLIENTS misapplied.
        """
        d = self.deck

        self.assertEqual(self.game.expected_action, message.TAKECLIENTS)
        self.assertEqual(self.game.active_player, self.p1)

        mon = Monitor()
        mon.modified(self.game)

        # too many clients taken
        a = message.GameAction(message.TAKECLIENTS, d.road1, d.latrine0)
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))

        # non-given cards
        a = message.GameAction(message.TAKECLIENTS, d.dock0, d.atrium1)
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))

        # not enough clients taken
        a = message.GameAction(message.TAKECLIENTS)
        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 56
0
    def test_not_enough_cards_and_actions(self):
        """Lead a role without enough cards.
        """
        d = self.deck

        a = message.GameAction(message.LEADROLE, 'Laborer', 0, d.latrine0)

        mon = Monitor()
        mon.modified(self.game)
        with self.assertRaises(GTRError) as cm:
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))

        a = message.GameAction(message.LEADROLE, 'Laborer', 1)
        with self.assertRaises(GTRError) as cm:
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))

        a = message.GameAction(message.LEADROLE, 'Laborer', 0)
        with self.assertRaises(GTRError) as cm:
            self.game.handle(a)


        self.assertFalse(mon.modified(self.game))
Esempio n. 57
0
    def test_illegal_give_cards(self):
        """A GIVECARDS action with too few cards will raise GTRError.
        """
        d = self.deck

        self.p1.hand.set_content([d.atrium0])
        self.p2.hand.set_content([d.foundry0])

        a = message.GameAction(message.LEGIONARY, d.atrium0)
        self.game.handle(a)

        a = message.GameAction(message.TAKEPOOLCARDS)
        self.game.handle(a)

        a = message.GameAction(message.GIVECARDS)

        mon = Monitor()
        mon.modified(self.game)

        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 58
0
    def test_give_cards_not_in_hand(self):
        """A GIVECARDS action with cards not in the player's hand.
        """
        d = self.deck

        self.p1.hand.set_content([d.atrium0])
        self.p2.hand.set_content([d.foundry0])

        a = message.GameAction(message.LEGIONARY, d.atrium0)
        self.game.handle(a)

        a = message.GameAction(message.TAKEPOOLCARDS)
        self.game.handle(a)

        a = message.GameAction(message.GIVECARDS, d.shrine0)

        mon = Monitor()
        mon.modified(self.game)

        with self.assertRaises(GTRError):
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))
Esempio n. 59
0
    def test_follow_with_too_few_cards_and_actions(self):
        """Follow with not enough cards or action specified
        """
        d = self.deck
        self.p2.hand.set_content([d.latrine0])

        a = message.GameAction(message.FOLLOWROLE, 0, d.latrine0)
        mon = Monitor()
        mon.modified(self.game)
        with self.assertRaises(GTRError) as cm:
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))

        a = message.GameAction(message.FOLLOWROLE, 1)
        with self.assertRaises(GTRError) as cm:
            self.game.handle(a)

        self.assertFalse(mon.modified(self.game))