예제 #1
0
    def test_complete_building(self):
        """ Complete a building by adding a material.
        """
        statue, temple, fountain, stairway = cm.get_cards(
            ['Statue', 'Temple', 'Fountain', 'Stairway'])
        self.p1.hand.set_content([statue])

        self.p1.buildings = [
            Building(temple, 'Marble', materials=[fountain, stairway])
        ]

        a = message.GameAction(message.CRAFTSMAN, temple, statue, None)
        self.game.handle(a)

        self.assertNotIn(statue, self.p1.hand)
        self.assertIn('Marble', self.p1.influence)
        self.assertTrue(
            self.game._player_has_active_building(self.p1, 'Temple'))

        # The completed building keeps its site. A copy is added to influence.
        self.assertEqual(
            self.p1.buildings[0],
            Building(temple,
                     'Marble',
                     materials=[fountain, stairway, statue],
                     complete=True))
예제 #2
0
파일: zone.py 프로젝트: comat0se/cloaca
    def test_iterating(self):
        l = ['Latrine', 'Latrine', 'Circus', 'Dock', 'Latrine']
        z = Zone(cm.get_cards(l))

        l2 = [c.name for c in z]

        self.assertEqual(l2, l)
예제 #3
0
파일: zone.py 프로젝트: comat0se/cloaca
    def test_iterating(self):
        l = ['Latrine', 'Latrine', 'Circus', 'Dock', 'Latrine']
        z = Zone(cm.get_cards(l))

        l2 = [c.name for c in z]

        self.assertEqual(l2, l)
예제 #4
0
    def test_fountain_add(self):
        """Test using a fountain to look at the top card and then add it as
        a material to a building, completing it.
        """
        bath, atrium, foundry = cm.get_cards(['Bath', 'Atrium', 'Foundry'])
        self.game.library.cards.insert(0, bath)

        self.p1.buildings.append(Building(atrium, 'Brick',
                                          materials=[foundry]))

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

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

        a = message.GameAction(message.FOUNTAIN, atrium, bath, None)
        self.game.handle(a)

        self.assertNotIn(bath, self.p1.hand)
        self.assertIsNone(self.p1.fountain_card)

        self.assertTrue(
            self.game._player_has_active_building(self.p1, 'Atrium'))

        self.assertEqual(self.game.expected_action, message.THINKERORLEAD)
예제 #5
0
파일: misc.py 프로젝트: comat0se/cloaca
    def test_privatize_hands(self):
        """Test hiding opponents' hands.
        """
        g = Game()
        g.add_player(uuid4(), 'p0')
        g.add_player(uuid4(), 'p1')
        gs = g

        p0, p1 = gs.players

        latrine, insula, jack, road = cm.get_cards(['Latrine', 'Insula', 'Jack', 'Road'])
        p0.hand.set_content([latrine, insula])
        p1.hand.set_content([jack, road])

        gs_private = g.privatized_game_state_copy('p0')
        p0, p1 = gs_private.players

        self.assertIn(jack, p1.hand)
        self.assertIn(Card(-1), p1.hand)
        self.assertNotIn(road, p1.hand)

        self.assertIn(latrine, p0.hand)
        self.assertIn(insula, p0.hand)

        self.assertEqual(len(p0.hand), 2)
        self.assertEqual(len(p1.hand), 2)
예제 #6
0
파일: turn.py 프로젝트: mhmurray/cloaca
    def test_petition_with_circus_and_three_cards(self):
        """Tests petition with 3 orders cards despiting having a Circus.
        """
        circus, dock = cm.get_cards(['Circus', 'Dock'])
        self.p1.buildings = [Building(circus, 'Wood', materials=[dock], complete=True)]

        cards = cm.get_cards(['Road']*3)
        self.p1.hand.set_content(cards)

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

        self.assertEqual(self.game.role_led, 'Craftsman')
        self.assertEqual(self.p1.n_camp_actions, 1)
        self.assertTrue(self.p1.camp.contains(cards))
        self.assertNotIn('Road', self.p1.hand)
        self.assertEqual(self.game.expected_action, message.FOLLOWROLE)
예제 #7
0
파일: thinker.py 프로젝트: comat0se/cloaca
    def test_thinker_for_one(self):
        self.p1.hand.set_content(cm.get_cards(['Latrine'] * 5))
        self.assertEqual(len(self.p1.hand), 5)

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

        self.assertEqual(len(self.p1.hand), 6)
        self.assertFalse('Jack' in self.p1.hand)
예제 #8
0
파일: thinker.py 프로젝트: comat0se/cloaca
    def test_thinker_for_one(self):
        self.p1.hand.set_content(cm.get_cards(['Latrine']*5))
        self.assertEqual(len(self.p1.hand), 5)

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

        self.assertEqual(len(self.p1.hand), 6)
        self.assertFalse('Jack' in self.p1.hand)
예제 #9
0
파일: thinker.py 프로젝트: comat0se/cloaca
    def test_thinker_for_jack_from_full(self):
        """ Thinker for Jack with full hand should draw Jack.
        """
        self.p1.hand.set_content(cm.get_cards(['Latrine']*5))

        a = message.GameAction(message.THINKERTYPE, True)
        self.game.handle(a)

        self.assertEqual(len(self.p1.hand), 6)
        self.assertIn('Jack', self.p1.hand)
예제 #10
0
파일: thinker.py 프로젝트: comat0se/cloaca
    def test_thinker_for_four_cards_with_one_orders(self):
        """ Thinker for cards with 1 card in hand should draw 4.
        Test with initial card being a Jack or Latrine
        """
        self.p1.hand.set_content(cm.get_cards(['Latrine']))

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

        self.assertEqual(len(self.p1.hand), 5)
예제 #11
0
파일: thinker.py 프로젝트: comat0se/cloaca
    def test_thinker_for_jack_from_full(self):
        """ Thinker for Jack with full hand should draw Jack.
        """
        self.p1.hand.set_content(cm.get_cards(['Latrine'] * 5))

        a = message.GameAction(message.THINKERTYPE, True)
        self.game.handle(a)

        self.assertEqual(len(self.p1.hand), 6)
        self.assertIn('Jack', self.p1.hand)
예제 #12
0
파일: turn.py 프로젝트: comat0se/cloaca
    def test_petition_with_circus_and_three_cards(self):
        """Tests petition with 3 orders cards despiting having a Circus.
        """
        circus, dock = cm.get_cards(['Circus', 'Dock'])
        self.p1.buildings = [
            Building(circus, 'Wood', materials=[dock], complete=True)
        ]

        cards = cm.get_cards(['Road'] * 3)
        self.p1.hand.set_content(cards)

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

        self.assertEqual(self.game.role_led, 'Craftsman')
        self.assertEqual(self.p1.n_camp_actions, 1)
        self.assertTrue(self.p1.camp.contains(cards))
        self.assertNotIn('Road', self.p1.hand)
        self.assertEqual(self.game.expected_action, message.FOLLOWROLE)
예제 #13
0
파일: thinker.py 프로젝트: comat0se/cloaca
    def test_thinker_for_four_cards_with_one_jack(self):
        """ Thinker for cards with 1 card in hand should draw 4.
        Test with initial card being a Jack or Latrine
        """
        self.p1.hand.set_content(cm.get_cards(['Jack']))

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

        self.assertEqual(len(self.p1.hand), 5)
예제 #14
0
파일: zone.py 프로젝트: comat0se/cloaca
    def test_get_cards(self):
        z = Zone(cm.get_cards(['Latrine', 'Latrine', 'Circus', 'Dock', 'Latrine']))

        l = z.get_cards(['Latrine', 'Latrine', 'Dock'])

        z2 = Zone(l)

        self.assertEqual(z2.count('Latrine'), 2)
        self.assertEqual(z2.count('Dock'), 1)
        self.assertEqual(len(l), 3)
예제 #15
0
파일: misc.py 프로젝트: comat0se/cloaca
    def test_resolve_tie(self):
        g = Game()
        g.add_player(uuid4(), 'p1')
        g.add_player(uuid4(), 'p2')
        g.add_player(uuid4(), 'p3')

        gs = g
        gs.library.set_content(cm.get_cards(
            ['Circus', 'Circus', 'Circus', 'Circus Maximus', 'Circus', 'Circus',
             'Ludus Magna', 'Ludus Magna', 'Statue', 'Coliseum',
             ]))


        first = g._init_pool(len(gs.players))

        self.assertEqual(first, 2)
        z = Zone(cm.get_cards(
                ['Circus', 'Circus', 'Circus', 'Circus Maximus', 'Circus',
                 'Circus', 'Ludus Magna', 'Ludus Magna', 'Statue', 'Coliseum']))
        self.assertTrue(z.equal_contents(gs.pool))
예제 #16
0
파일: zone.py 프로젝트: comat0se/cloaca
    def test_get_cards(self):
        z = Zone(
            cm.get_cards(['Latrine', 'Latrine', 'Circus', 'Dock', 'Latrine']))

        l = z.get_cards(['Latrine', 'Latrine', 'Dock'])

        z2 = Zone(l)

        self.assertEqual(z2.count('Latrine'), 2)
        self.assertEqual(z2.count('Dock'), 1)
        self.assertEqual(len(l), 3)
예제 #17
0
파일: turn.py 프로젝트: comat0se/cloaca
    def test_petition(self):
        """Tests petition with 3 orders cards.
        """
        cards = cm.get_cards(['Road'] * 3)
        self.p1.hand.set_content(cards)

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

        self.assertEqual(self.game.role_led, 'Craftsman')
        self.assertEqual(self.p1.n_camp_actions, 1)
        self.assertTrue(self.p1.camp.contains(cards))
        self.assertNotIn('Road', self.p1.hand)
        self.assertEqual(self.game.expected_action, message.FOLLOWROLE)
예제 #18
0
파일: turn.py 프로젝트: mhmurray/cloaca
    def test_petition(self):
        """Tests petition with 3 orders cards.
        """
        cards = cm.get_cards(['Road']*3)
        self.p1.hand.set_content(cards)

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

        self.assertEqual(self.game.role_led, 'Craftsman')
        self.assertEqual(self.p1.n_camp_actions, 1)
        self.assertTrue(self.p1.camp.contains(cards))
        self.assertNotIn('Road', self.p1.hand)
        self.assertEqual(self.game.expected_action, message.FOLLOWROLE)
예제 #19
0
파일: misc.py 프로젝트: comat0se/cloaca
    def test_two_player(self):

        g = Game()
        g.add_player(uuid4(), 'p1')
        g.add_player(uuid4(), 'p2')

        gs = g
        gs.library.set_content(cm.get_cards(['Bar', 'Circus']))

        first = g._init_pool(len(gs.players))

        self.assertEqual(first, 0)
        self.assertIn('Bar', gs.pool)
        self.assertIn('Circus', gs.pool)
예제 #20
0
파일: turn.py 프로젝트: comat0se/cloaca
    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))
예제 #21
0
파일: patron.py 프로젝트: comat0se/cloaca
    def test_patron_with_higher_clientele_limit(self):
        """ Patron a card after a higher vault limit has been achieved.

        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])
        self.p1.influence.append('Wood')

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

        self.assertNotIn('Atrium', self.game.pool)
        self.assertIn('Atrium', self.p1.clientele)
예제 #22
0
파일: turn.py 프로젝트: mhmurray/cloaca
    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))
예제 #23
0
파일: turn.py 프로젝트: mhmurray/cloaca
    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))
예제 #24
0
파일: turn.py 프로젝트: mhmurray/cloaca
    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))
예제 #25
0
파일: turn.py 프로젝트: comat0se/cloaca
    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))
예제 #26
0
파일: turn.py 프로젝트: comat0se/cloaca
    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))
예제 #27
0
    def test_patron_with_higher_clientele_limit(self):
        """ Patron a card after a higher vault limit has been achieved.

        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])
        self.p1.influence.append('Wood')

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

        self.assertNotIn('Atrium', self.game.pool)
        self.assertIn('Atrium', self.p1.clientele)
예제 #28
0
파일: turn.py 프로젝트: comat0se/cloaca
    def test_petition_for_same_role(self):
        """Tests petition with 3 orders cards that match the role
        selected for the Petition. eg. 3 Road cards to Petition for Laborer.
        """
        cards = cm.get_cards(['Road'] * 3)
        self.p1.hand.set_content(cards)

        a = message.GameAction(message.LEADROLE, 'Laborer', 1, *cards)
        self.game.handle(a)

        self.assertEqual(self.game.role_led, 'Laborer')
        self.assertEqual(self.p1.n_camp_actions, 1)
        self.assertTrue(self.p1.camp.contains(cards))
        self.assertNotIn('Road', self.p1.hand)
        self.assertEqual(self.game.expected_action, message.FOLLOWROLE)
예제 #29
0
파일: turn.py 프로젝트: mhmurray/cloaca
    def test_petition_for_same_role(self):
        """Tests petition with 3 orders cards that match the role
        selected for the Petition. eg. 3 Road cards to Petition for Laborer.
        """
        cards = cm.get_cards(['Road']*3)
        self.p1.hand.set_content(cards)

        a = message.GameAction(message.LEADROLE, 'Laborer', 1, *cards)
        self.game.handle(a)

        self.assertEqual(self.game.role_led, 'Laborer')
        self.assertEqual(self.p1.n_camp_actions, 1)
        self.assertTrue(self.p1.camp.contains(cards))
        self.assertNotIn('Road', self.p1.hand)
        self.assertEqual(self.game.expected_action, message.FOLLOWROLE)
예제 #30
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))
예제 #31
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))
예제 #32
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))
예제 #33
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))
예제 #34
0
파일: turn.py 프로젝트: mhmurray/cloaca
    def test_follow_role_with_petition_of_same_role(self):
        """ Follow Laborer by petition of Laborer role cards.
        """
        cards = latrine, insula1, insula2 = cm.get_cards(['Latrine', 'Insula', 'Insula'])
        self.p2.hand.set_content(cards)
        
        a = message.GameAction(message.FOLLOWROLE, 1, *cards)

        self.game.handle(a)

        self.assertEqual(self.game.expected_action, message.LABORER)
        self.assertIn(latrine, self.p2.camp)
        self.assertIn(insula1, self.p2.camp)
        self.assertIn(insula2, self.p2.camp)
        self.assertEqual(self.p2.camp.count('Insula'), 2)
        self.assertEqual(len(self.p2.hand), 0)
예제 #35
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))
예제 #36
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))
예제 #37
0
파일: turn.py 프로젝트: mhmurray/cloaca
    def test_follow_role_with_petition_of_different_role(self):
        """ Follow Laborer by petition of non-Laborer role cards.
        """
        cards = atrium, school1, school2 = cm.get_cards(['Atrium', 'School', 'School'])
        self.p2.hand.set_content(cards)
        
        a = message.GameAction(message.FOLLOWROLE, 1, *cards)
        
        self.game.handle(a)

        self.assertEqual(self.game.expected_action, message.LABORER)
        self.assertIn(atrium, self.p2.camp)
        self.assertIn(school1, self.p2.camp)
        self.assertIn(school2, self.p2.camp)
        self.assertEqual(self.p2.camp.count('School'), 2)
        self.assertEqual(len(self.p2.hand), 0)
예제 #38
0
파일: patron.py 프로젝트: comat0se/cloaca
    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))
예제 #39
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))
예제 #40
0
파일: turn.py 프로젝트: comat0se/cloaca
    def test_follow_role_with_petition_of_different_role(self):
        """ Follow Laborer by petition of non-Laborer role cards.
        """
        cards = atrium, school1, school2 = cm.get_cards(
            ['Atrium', 'School', 'School'])
        self.p2.hand.set_content(cards)

        a = message.GameAction(message.FOLLOWROLE, 1, *cards)

        self.game.handle(a)

        self.assertEqual(self.game.expected_action, message.LABORER)
        self.assertIn(atrium, self.p2.camp)
        self.assertIn(school1, self.p2.camp)
        self.assertIn(school2, self.p2.camp)
        self.assertEqual(self.p2.camp.count('School'), 2)
        self.assertEqual(len(self.p2.hand), 0)
예제 #41
0
파일: patron.py 프로젝트: comat0se/cloaca
    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))
예제 #42
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))
예제 #43
0
    def test_start_and_add(self):
        """Start a building and add a material.
        """
        wall, tower = cm.get_cards(['Wall', 'Tower'])
        self.p1.stockpile.set_content([wall])
        self.p1.hand.set_content([tower])

        a = message.GameAction(message.ARCHITECT, tower, None, 'Concrete')
        self.game.handle(a)

        self.assertEqual(self.p1.buildings[0], Building(tower, 'Concrete'))

        a = message.GameAction(message.ARCHITECT, tower, wall, None)
        self.game.handle(a)

        self.assertEqual(self.p1.buildings[0],
                Building(tower, 'Concrete', materials=[wall]))
예제 #44
0
파일: misc.py 프로젝트: comat0se/cloaca
    def test_privatize_fountain_card(self):
        """Test hiding the card revealed with the fountain.
        """
        g = Game()
        g.add_player(uuid4(), 'p0')
        g.add_player(uuid4(), 'p1')

        gs = g
        p0, p1 = gs.players

        latrine, insula, statue, road = cm.get_cards(['Latrine', 'Insula', 'Statue', 'Road'])
        p0.fountain_card = latrine

        gs_private = g.privatized_game_state_copy('p1')
        p0, p1 = gs_private.players

        self.assertEqual(p0.fountain_card, Card(-1))
예제 #45
0
    def test_add_to_empty_building(self):
        """ Add a valid material to a building with no materials.
        """
        atrium, foundry = cm.get_cards(['Atrium', 'Foundry'])
        self.p1.hand.set_content([atrium])

        self.p1.buildings = [Building(foundry, 'Brick')]

        a = message.GameAction(message.CRAFTSMAN, foundry, atrium, None)
        self.game.handle(a)

        self.assertNotIn(atrium, self.p1.hand)

        self.assertEqual(self.p1.buildings[0],
                Building(foundry, 'Brick', materials=[atrium]))

        self.assertFalse(self.game._player_has_active_building(self.p1, 'Foundry'))
예제 #46
0
파일: misc.py 프로젝트: comat0se/cloaca
    def test_privatize_library(self):
        """Test hiding the library.
        """
        g = Game()
        g.add_player(uuid4(), 'p1')
        g.add_player(uuid4(), 'p2')
        gs = g

        gs.library.set_content(cm.get_cards(
            ['Circus', 'Circus', 'Circus', 'Circus Maximus', 'Circus', 'Circus',
             'Ludus Magna', 'Ludus Magna', 'Statue', 'Coliseum',
             ]))

        gs_private = g.privatized_game_state_copy('p1')

        self.assertFalse(gs_private.library.contains('Circus'))
        self.assertEqual(gs_private.library, Zone([Card(-1)]*len(gs_private.library), name='library'))
예제 #47
0
파일: turn.py 프로젝트: comat0se/cloaca
    def test_follow_role_with_petition_of_same_role(self):
        """ Follow Laborer by petition of Laborer role cards.
        """
        cards = latrine, insula1, insula2 = cm.get_cards(
            ['Latrine', 'Insula', 'Insula'])
        self.p2.hand.set_content(cards)

        a = message.GameAction(message.FOLLOWROLE, 1, *cards)

        self.game.handle(a)

        self.assertEqual(self.game.expected_action, message.LABORER)
        self.assertIn(latrine, self.p2.camp)
        self.assertIn(insula1, self.p2.camp)
        self.assertIn(insula2, self.p2.camp)
        self.assertEqual(self.p2.camp.count('Insula'), 2)
        self.assertEqual(len(self.p2.hand), 0)
예제 #48
0
    def test_start_and_add(self):
        """Start a building and add a material.
        """
        wall, tower = cm.get_cards(['Wall', 'Tower'])
        self.p1.stockpile.set_content([wall])
        self.p1.hand.set_content([tower])

        a = message.GameAction(message.ARCHITECT, tower, None, 'Concrete')
        self.game.handle(a)

        self.assertEqual(self.p1.buildings[0], Building(tower, 'Concrete'))

        a = message.GameAction(message.ARCHITECT, tower, wall, None)
        self.game.handle(a)

        self.assertEqual(self.p1.buildings[0],
                         Building(tower, 'Concrete', materials=[wall]))
예제 #49
0
파일: turn.py 프로젝트: mhmurray/cloaca
    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))
예제 #50
0
    def test_add_to_empty_building(self):
        """ Add a valid material to a building with no materials.
        """
        atrium, foundry = cm.get_cards(['Atrium', 'Foundry'])
        self.p1.hand.set_content([atrium])

        self.p1.buildings = [Building(foundry, 'Brick')]

        a = message.GameAction(message.CRAFTSMAN, foundry, atrium, None)
        self.game.handle(a)

        self.assertNotIn(atrium, self.p1.hand)

        self.assertEqual(self.p1.buildings[0],
                         Building(foundry, 'Brick', materials=[atrium]))

        self.assertFalse(
            self.game._player_has_active_building(self.p1, 'Foundry'))
예제 #51
0
파일: patron.py 프로젝트: comat0se/cloaca
    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))
예제 #52
0
파일: misc.py 프로젝트: comat0se/cloaca
    def test_five_player(self):
        g = Game()
        g.add_player(uuid4(), 'p1')
        g.add_player(uuid4(), 'p2')
        g.add_player(uuid4(), 'p3')
        g.add_player(uuid4(), 'p4')
        g.add_player(uuid4(), 'p5')

        gs = g
        gs.library.set_content(cm.get_cards(['Statue', 'Circus', 'Dock', 'Dock', 'Ludus Magna']))

        first = g._init_pool(len(gs.players))

        self.assertEqual(first, 1)
        self.assertIn('Statue', gs.pool)
        self.assertIn('Circus', gs.pool)
        self.assertIn('Ludus Magna', gs.pool)
        self.assertEqual(gs.pool.count('Dock'), 2)
예제 #53
0
파일: turn.py 프로젝트: comat0se/cloaca
    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))
예제 #54
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))
예제 #55
0
    def test_add_to_nonempty_building(self):
        """ Add a valid material to a building with one material, but this
        does not complete it.
        """
        statue, temple, fountain, stairway = cm.get_cards(
                ['Statue', 'Temple', 'Fountain', 'Stairway'])
        self.p1.hand.set_content([statue])

        self.p1.buildings = [Building(temple, 'Marble', materials=[fountain])]

        a = message.GameAction(message.CRAFTSMAN, temple, statue, None)
        self.game.handle(a)

        self.assertNotIn(statue, self.p1.hand)

        self.assertEqual(self.p1.buildings[0],
                Building(temple, 'Marble', materials=[fountain, statue]))

        self.assertFalse(self.game._player_has_active_building(self.p1, 'Temple'))
예제 #56
0
    def test_follower_client(self):
        """ Add materials with subsequent architect client, even after thinking.
        """
        tower, wall, storeroom = cm.get_cards(['Tower', 'Wall', 'Storeroom'])
        self.p2.stockpile.set_content([wall, storeroom])
        self.p2.buildings = [Building(tower, 'Concrete')]

        # Skip p1 architects
        a = message.GameAction(message.ARCHITECT, None, None, None)
        self.game.handle(a)
        self.game.handle(a)

        a = message.GameAction(message.ARCHITECT, tower, wall, None)
        self.game.handle(a)

        self.assertEqual(self.p2.buildings[0],
                         Building(tower, 'Concrete', materials=[wall]))

        self.assertEqual(self.game.expected_action, message.THINKERORLEAD)
        self.assertEqual(self.game.leader_index, 1)
예제 #57
0
    def test_start_two_buildings(self):
        """Start two buildings.
        """
        tower, bridge = cm.get_cards(['Tower', 'Bridge'])
        self.p1.hand.set_content([tower, bridge])

        a = message.GameAction(message.ARCHITECT, tower, None, 'Concrete')
        self.game.handle(a)

        self.assertEqual(self.p1.buildings[0], Building(tower, 'Concrete'))
        self.assertEqual(self.game.expected_action, message.ARCHITECT)

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

        self.assertEqual(self.p1.buildings[1], Building(bridge, 'Concrete'))

        self.assertEqual(len(self.p1.hand), 0)
        self.assertNotIn('Concrete', self.game.in_town_sites)

        self.assertEqual(self.game.active_player, self.p2)
예제 #58
0
    def test_add_to_nonempty_building(self):
        """ Add a valid material to a building with one material, but this
        does not complete it.
        """
        statue, temple, fountain, stairway = cm.get_cards(
            ['Statue', 'Temple', 'Fountain', 'Stairway'])
        self.p1.hand.set_content([statue])

        self.p1.buildings = [Building(temple, 'Marble', materials=[fountain])]

        a = message.GameAction(message.CRAFTSMAN, temple, statue, None)
        self.game.handle(a)

        self.assertNotIn(statue, self.p1.hand)

        self.assertEqual(
            self.p1.buildings[0],
            Building(temple, 'Marble', materials=[fountain, statue]))

        self.assertFalse(
            self.game._player_has_active_building(self.p1, 'Temple'))
예제 #59
0
    def test_add_two_materials(self):
        """ Add materials with subsequent architect actions.
        """
        wall, storeroom = cm.get_cards(['Wall', 'Storeroom'])
        tower = cm.get_card('Tower')
        self.p1.stockpile.set_content([wall, storeroom])
        self.p1.buildings = [Building(tower, 'Concrete')]

        a = message.GameAction(message.ARCHITECT, tower, wall, None)
        self.game.handle(a)

        self.assertEqual(self.p1.buildings[0],
                         Building(tower, 'Concrete', materials=[wall]))

        a = message.GameAction(message.ARCHITECT, tower, storeroom, None)
        self.game.handle(a)

        self.assertEqual(
            self.p1.buildings[0],
            Building(tower,
                     'Concrete',
                     materials=[wall, storeroom],
                     complete=True))
예제 #60
0
    def test_complete_building(self):
        """ Complete a building.
        """
        statue, temple, fountain, stairway = cm.get_cards(
            ['Statue', 'Temple', 'Fountain', 'Stairway'])
        self.p1.stockpile.set_content([statue])
        self.p1.buildings = [
            Building(temple, 'Marble', materials=[fountain, stairway])
        ]

        a = message.GameAction(message.ARCHITECT, temple, statue, None)
        self.game.handle(a)

        self.assertNotIn(statue, self.p1.stockpile)
        self.assertIn('Marble', self.p1.influence)
        self.assertTrue(
            self.game._player_has_active_building(self.p1, 'Temple'))

        self.assertEqual(
            self.p1.buildings[0],
            Building(temple,
                     'Marble',
                     materials=[fountain, stairway, statue],
                     complete=True))