Пример #1
0
 def test_purchase_shares_in_one_hotel(self):
     self.zeta["tiles"] = ["9C", "9D"]
     self.make_purchase_the_next_action()
     self.assertEqual(self.player["shares"]["zeta"], 0)
     gametools.purchase(self.game, self.player, {"zeta": 3})
     self.assertEqual(self.player["shares"]["zeta"], 3)
     self.assertEqual(self.player["cash"], 5400)
Пример #2
0
 def test_unaffordable_purchase(self):
     self.sackson["tiles"] = ["11A", "11C", "12A", "12B", "12C"]
     self.zeta["tiles"] = ["12H", "12I"]
     self.player["cash"] = 200
     self.make_purchase_the_next_action()
     with self.assertRaises(gametools.GamePlayNotAllowedError):
         gametools.purchase(self.game, self.player, {"sackson": 3})
Пример #3
0
 def test_turn_rotates_after_creating_hotel(self):
     self.game["lonely_tiles"] = ["1A"]
     tile = self.player["rack"][0] = "1B"
     gametools.play_tile(self.game, self.player, tile)
     gametools.create_hotel(self.game, self.player, self.zeta)
     gametools.purchase(self.game, self.player, {})
     self.assertEqual(gametools.active_player(self.game), self.game["players"][1])
Пример #4
0
 def test_create_hotel_already_on_board(self):
     self.force_active_player_to_create_hotel()
     gametools.create_hotel(self.game, self.player, self.hydra)
     gametools.purchase(self.game, self.player, {})
     self.force_active_player_to_create_hotel()
     with self.assertRaises(gametools.GamePlayNotAllowedError):
         gametools.create_hotel(self.game, self.player, self.hydra)
Пример #5
0
 def test_bonuses_awarded_at_game_end(self):
     self.sackson["tiles"] = [str(i) + "A" for i in xrange(1, 13)]
     self.player["shares"]["sackson"] = 1
     tile = self.player["rack"][0] = "1D"
     self.remember_cash()
     gametools.play_tile(self.game, self.player, tile)
     gametools.purchase(self.game, self.player, {}, end_game=True)
     self.assertEqual(self.cash_difference(), [11200, 0, 0])
Пример #6
0
 def test_many_tiles_added_to_hotel(self):
     for tile in ["2D", "1B", "1A", "2A"]:
         player = gametools.active_player(self.game)
         player["rack"][0] = tile
         gametools.play_tile(self.game, player, tile)
         gametools.purchase(self.game, player, {})
         self.assertEqual(gametools.where_is_tile(self.game, tile), "phoenix")
     self.assertEqual(len(self.phoenix["tiles"]), 6)
Пример #7
0
 def test_discard_and_replenish_unplayable_rack_tiles(self):
     blank_board(self.game)
     self.zeta["tiles"] = [str(i) + "A" for i in xrange(1, 13)]
     self.america["tiles"] = [str(i) + "C" for i in xrange(1, 13)]
     unplayable = [str(i) + "B" for i in xrange(1, 6)]
     self.player["rack"][1:6] = unplayable
     for tile in unplayable:
         if tile in self.game["tilebag"]:
             self.game["tilebag"].remove(tile)
     tile = self.player["rack"][0] = "10D"
     gametools.play_tile(self.game, self.player, tile)
     gametools.purchase(self.game, self.player, {})
     for tile in unplayable:
         self.assertTrue(tile not in self.player["rack"])
     self.assertEqual(len(self.player["rack"]), 6)
Пример #8
0
 def purchase_message(self, message):
     """Someone bought some shares and maybe ended the game."""
     player_name = message['player']
     game = self.game_for_player(player_name)
     if not game:
         return
     order = message['order']
     try:
         player = gametools.player_named(game, player_name)
         stock_market_shares = gametools.purchase(game, player, order, 
                                                  message['end_game'])
     except gametools.GamePlayNotAllowedError, e:
         self.send_error(player_name, 'Cannot complete purchase', e)
         return
Пример #9
0
 def test_appropriate_game_end(self):
     self.sackson["tiles"] = [str(i) + "A" for i in xrange(1, 13)]
     tile = self.player["rack"][0] = "1D"
     gametools.play_tile(self.game, self.player, tile)
     gametools.purchase(self.game, self.player, {}, end_game=True)
     self.assertTrue(self.game["ended"])
Пример #10
0
 def test_inappropriate_game_end(self):
     self.sackson["tiles"] = ["1A", "2A"]
     gametools.play_tile(self.game, self.player, self.player["rack"][0])
     gametools.purchase(self.game, self.player, {}, end_game=True)
     self.assertFalse(self.game["ended"])
Пример #11
0
 def test_purchase_more_shares_than_in_bank(self):
     self.quantum["tiles"] = ["1A", "2A"]
     self.game["players"][1]["shares"]["quantum"] = 24
     self.make_purchase_the_next_action()
     with self.assertRaises(gametools.GamePlayNotAllowedError):
         gametools.purchase(self.game, self.player, {"quantum": 2})
Пример #12
0
 def test_purchase_shares_in_nonexistant_hotel(self):
     self.phoenix["tiles"] = ["8G", "8H", "8I"]
     self.make_purchase_the_next_action()
     gametools.purchase(self.game, self.player, {"febtober": 2})
     self.assertTrue("febtober" not in self.player["shares"])
Пример #13
0
 def test_purchase_shares_in_off_board_hotels(self):
     self.america["tiles"] = ["3E", "3D", "4D", "4C"]
     self.make_purchase_the_next_action()
     gametools.purchase(self.game, self.player, {"fusion": 1})
     self.assertEqual(self.player["shares"]["fusion"], 0)
Пример #14
0
 def test_purchase_too_many_shares(self):
     self.make_purchase_the_next_action()
     with self.assertRaises(gametools.GamePlayNotAllowedError):
         gametools.purchase(self.game, self.player, {"sackson": 4})