Beispiel #1
0
 def test_game_initialization(self):
     game_instance = monopoly.Monopoly()
     self.assertEqual(40, len(game_instance.board))
     self.assertEqual(0, len(game_instance.players))
     print(game_instance.chance_deck)
     self.assertEqual(16, len(game_instance.chance_deck.cards))
     self.assertEqual(16, len(game_instance.community_deck.cards))
     self.assertEqual(0, game_instance.turns)
Beispiel #2
0
 def test_get_bid_case_1(self, input):
     game_instance = monopoly.Monopoly()
     game_instance.add_player('David')
     game_instance.generate_in_game_players()
     item = cards.HoldableCard(name='Go to BEENUS', action=None, parent_deck='Beenus')
     auc_instance = auction.Auction(game=game_instance, seller=game_instance.players[0], item=item)
     auc_instance.current_bidder = game_instance.players[0]
     auc_instance.highest_bid = 5
     self.assertEqual(10, auc_instance.get_bid())
Beispiel #3
0
 def test_player_removal_at_prior_index(self):
     my_game = monopoly.Monopoly()
     my_game.add_player('David')
     my_game.add_player('Sara')
     my_game.add_player('Alan')
     my_game.add_player('Mark')
     my_game.set_active_player()
     my_game.set_active_player()
     my_game.remove_player(my_game.all_players[0])
     #The next active player should be Alan if David is removed, and the current active player is Sara
     my_game.set_active_player()
     self.assertEqual('Alan', my_game.active_player.name)
Beispiel #4
0
 def test_player_removal_at_last_index_in_players(self):
     my_game = monopoly.Monopoly()
     my_game.add_player('David')
     my_game.add_player('Sara')
     my_game.add_player('Alan')
     my_game.add_player('Mark')
     my_game.set_active_player()
     my_game.remove_player(my_game.all_players[-1])
     my_game.set_active_player()
     self.assertEqual('Sara', my_game.active_player.name)
     my_game.remove_player(my_game.all_players[2])
     my_game.set_active_player()
     self.assertEqual('David', my_game.active_player.name)
Beispiel #5
0
 def test_next_player_removal(self):
     my_game = monopoly.Monopoly()
     my_game.add_player('David')
     my_game.add_player('Sara')
     my_game.add_player('Alan')
     my_game.add_player('Mark')
     my_game.set_active_player()
     self.assertEqual('David', my_game.active_player.name)
     my_game.set_active_player()
     self.assertEqual('Sara', my_game.active_player.name)
     my_game.remove_player(my_game.all_players[2])
     my_game.set_active_player()
     self.assertEqual(3, len(my_game.players))
     self.assertEqual('Mark', my_game.active_player.name)
     my_game.set_active_player()
     self.assertEqual('David', my_game.active_player.name)
Beispiel #6
0
 def test_is_color_group_filled(self):
     """
     This test will verify that ColorTile.is_color_group_filled() will only return True if a Player owns all
     tiles within a color-set.
     :return None:
     """
     game_instance = monopoly.Monopoly()
     game_instance.add_player('Bob')
     game_instance.generate_in_game_players()
     game_instance.active_player = game_instance.players[0]
     game_instance.players[0].property_holdings.append(game_instance.board[37])
     #Case 1:  Player does not have all tiles within a color-set
     self.assertEqual(False, game_instance.board[37].is_color_group_filled(game=game_instance))
     game_instance.players[0].property_holdings.append(game_instance.board[39])
     #Case 2:  Player owns all tiles within a color-set
     self.assertEqual(True, game_instance.board[39].is_color_group_filled(game=game_instance))
Beispiel #7
0
 def test_player_removal_at_arbitrary_forward_index(self):
     my_game = monopoly.Monopoly()
     my_game.add_player('David')
     my_game.add_player('Sara')
     my_game.add_player('Alan')
     my_game.add_player('Mark')
     my_game.add_player('Bill')
     my_game.add_player('Bob')
     my_game.set_active_player()
     my_game.remove_player(my_game.players[3])
     self.assertEqual('David', my_game.active_player.name)
     my_game.set_active_player()
     self.assertEqual('Sara', my_game.active_player.name)
     my_game.set_active_player()
     self.assertEqual('Alan', my_game.active_player.name)
     my_game.set_active_player()
     self.assertEqual('Bill', my_game.active_player.name)
     my_game.set_active_player()
     self.assertEqual('Bob', my_game.active_player.name)
     my_game.set_active_player()
Beispiel #8
0
 def test_assess_rent(self):
     """
     Case 1: The Bank holds a ColorTile, verify that no rent is charged when a Player lands on it.
         -I should not have to test this here, but currently I don't have any tests for OwnableTile.perform_auto_actions()
     Case 2: A Player holds one or more ColorTiles in a color group, but does not hold all the tiles in a color group.
         -Verify that only ColorTile.base_rent is deducted from the Player's liquid holdings
     Case 3: A Player holds all ColorTiles in a color group.
         -Verfiy that double rent is charged
     Case 4:  A Player holds all ColorTiles in color group, but one of them is mortgaged.
         -Verify that if a Player lands on the mortgaged
     :return:
     """
     game_instance = monopoly.Monopoly()
     game_instance.add_player('Bill')
     game_instance.generate_in_game_players()
     game_instance.active_player = game_instance.players[0]
     game_instance.active_player.position = 37
     game_instance.board[37].perform_auto_actions(game=game_instance)
     #Verify Case 1, NOTE that ColorTile.assess_rent() was not called here, I instead had to call OwnableTile.perform_auto_actions()
     self.assertEqual(1500, game_instance.active_player.liquid_holdings)
     game_instance.add_player('Bob')
     game_instance.generate_in_game_players()
     game_instance.players[1].property_holdings.append(game_instance.board[37])
     game_instance.board[37].perform_auto_actions(game=game_instance)
     #Verify Case 2
     self.assertEqual(1465, game_instance.players[0].liquid_holdings)
     self.assertEqual(1535, game_instance.players[1].liquid_holdings)
     game_instance.players[1].property_holdings.append(game_instance.board[39])
     game_instance.board[37].perform_auto_actions(game=game_instance)
     #Verify Case 3
     self.assertEqual(1395, game_instance.players[0].liquid_holdings)
     self.assertEqual(1605, game_instance.players[1].liquid_holdings)
     game_instance.board[39].mortgaged = True
     game_instance.board[37].perform_auto_actions(game=game_instance)
     #Verify Case 4
     self.assertEqual(1325, game_instance.players[0].liquid_holdings)
     self.assertEqual(1675, game_instance.players[1].liquid_holdings)
     game_instance.players[0].position = 39
     self.assertEqual(1325, game_instance.players[0].liquid_holdings)
     self.assertEqual(1675, game_instance.players[1].liquid_holdings)
Beispiel #9
0
 def test_output_of_rungame(self):
     game_instance = monopoly.Monopoly()
     game_instance.add_player('David')
     output = game_instance.run_game()
     self.assertEqual('David', output.name)
Beispiel #10
0
 def test_default_interface(self):
     game_instance = monopoly.Monopoly()
     self.assertEqual(True, isinstance(game_instance.interface, monopoly_cl_interface.CLInterface))
Beispiel #11
0
def generate_locations(countries=['uk', 'usa', 'singapore']):
    for c in countries:
        s = monopoly.Monopoly(c)
        with open(f'locations-{c}.json', 'w') as f:
            f.write(json.dumps(s, cls=monopoly.MonopolyEncoder, indent=2))