Ejemplo n.º 1
0
 def test_mayor_bonus_refused(self):
     g = Game()
     g[state] = states.mayor_bonus
     g[settler_ship] = 0
     self.assertEqual(sum(g[jobs]), 0)
     g.step(False)
     self.assertEqual(sum(g[jobs]), 0)
Ejemplo n.º 2
0
 def test_mayor_bonus_accepted(self):
     g = Game()
     g[state] = states.mayor_bonus
     g[settler_ship] = 0
     self.assertEqual(sum(g[jobs]), 0)
     g.step(True)
     self.assertEqual(sum(g[jobs]), 1)
Ejemplo n.º 3
0
 def test_quarry_choice_role_user(self):
     g = Game()
     g[active] = 0
     g[role_user] = 0
     g[state] = states.planter_main
     g.step(tile.quarry)
     self.assertEqual(g[0 + island][tile.quarry], 1)
Ejemplo n.º 4
0
    def test_quarry_choice_invalid(self):

        g = Game()
        g[active] = 0
        g[role_user] = 5
        g[state] = states.planter_main
        with self.assertRaises(Exception):
            g.step(tile.quarry)
Ejemplo n.º 5
0
 def test_quarry_choice_construction_hut(self):
     g = Game()
     g[active] = 0
     g[role_user] = 5
     g[state] = states.planter_main
     g[0 + island][building.construction_hut] = 1
     g[0 + jobs][building.construction_hut] = 1
     g.step(tile.quarry)
     self.assertEqual(g[0 + island][tile.quarry], 1)
Ejemplo n.º 6
0
    def test_hacienda_flip(self):

        for active_player in (0, 5):
            for random_tile in range(5):
                g = Game()
                g[active] = active_player
                g[state] = states.hacienda_flip

                start = g[g[active] + island][random_tile]
                g.step(random_tile)
                self.assertEqual(start + 1, g[g[active] + island][random_tile])
Ejemplo n.º 7
0
    def test_role_cards(self):

        for amount in (0, 1, 2, 12):
            for card in range(7):
                g = Game()
                g[state] = states.role_choice
                g[which_role_has_bonus] = card
                g[role_bonus] = amount

                start = g[g[active] + cash]
                g.step(card)
                diff = g[g[active] + cash] - start
                self.assertEqual(amount, diff)
Ejemplo n.º 8
0
    def test_hacienda_choice_branching(self):

        for hacienda_player in (0, 5):
            for hacienda_choice in (False, True):
                g = Game()
                g[active] = hacienda_player
                g[farm_open] = [1, 1, 1, 0, 0, 5]
                g[state] = states.hacienda_choice

                g.step(hacienda_choice)
                if hacienda_choice:
                    self.assertEqual(states.hacienda_flip, g[state])
                else:
                    self.assertEqual(states.planter_main, g[state])
Ejemplo n.º 9
0
    def test_settup(self):
        """
        tile flip
        -> p1_hacienda_choice
        -> -> p1_hacienda_flip
        """

        g = Game()

        self.assertEqual(g[farm_open][tile.corn], 0)

        g.step(tile.corn)
        g.step(tile.corn)
        g.step(tile.corn)

        self.assertEqual(g[state], states.role_choice)
        self.assertEqual(g[farm_open][tile.corn], 3)
        self.assertEqual(g[active], 0)
Ejemplo n.º 10
0
    def test_role_choice_to_planter(self):

        for start_player in (0, 5):
            g = Game()
            g[active] = start_player
            g[farm_open] = [1, 1, 1, 0, 0, 5]
            g[state] = states.role_choice
            g.step(role.planter)
            self.assertEqual(states.planter_main, g[state])

            g = Game()
            g[active] = start_player
            g[farm_open] = [1, 1, 1, 0, 0, 5]
            g[state] = states.role_choice
            g[start_player + island][building.hacienda] = 1
            g[start_player + jobs][building.hacienda] = 1
            g.step(role.planter)
            self.assertEqual(states.hacienda_choice, g[state])
Ejemplo n.º 11
0
 def test_invalid_role_choice(self):
     g = Game()
     with self.assertRaises(Exception):
         g.step('planter')
     with self.assertRaises(Exception):
         g.step(7)
     with self.assertRaises(Exception):
         g.step(1.2)
Ejemplo n.º 12
0
 def test_settup_invalid(self):
     g = Game()
     with self.assertRaises(Exception):
         g.step('planter')
     with self.assertRaises(Exception):
         g.step(6)
     with self.assertRaises(Exception):
         g.step(1.2)
Ejemplo n.º 13
0
    def test_mayor_flow(self):
        g = Game()
        g[state] = states.role_choice
        g.step(role.mayor)
        self.assertEqual(states.mayor_bonus, g[state])

        g.step(True)
        self.assertEqual(states.assign_work, g[state])

        assignments = [0 for _ in range(island_size)]
        assignments[tile.indigo] = 1
        assignments[building.idle] = 1
        g.step(assignments)
        self.assertEqual(states.assign_work, g[state])

        assignments = [0 for _ in range(island_size)]
        assignments[tile.corn] = 1
        g.step(assignments)
        self.assertEqual(states.role_choice, g[state])
Ejemplo n.º 14
0
 def test_mayor_bonus_invalid(self):
     g = Game()
     g[state] = states.mayor_bonus
     with self.assertRaises(Exception):
         g.step(1)
Ejemplo n.º 15
0
def reset():
    global g
    g = Game()
    while g[state] != states.role_choice:
        g.step(randint(0, 4))