def testRunBuyPrivateCompanyWithBid(self): private_company_purchase_move = self._getMove() game_context = self._getContext() game_context.private_companies[0].bid(game_context.players[1], 1000) minigame = BuyPrivateCompany() self.assertFalse( minigame.run(private_company_purchase_move, game_context)) self.assertIn("You cannot buy something that has a bid on it.", minigame.errors()) self.assertEqual(private_company_purchase_move.player.cash, 500, "Don't pay if you get things wrong.")
def testRunBuyPrivateCompanyMinigameWeenieBoi(self): private_company_purchase_move = self._getMove() private_company_purchase_move.bid_amount = 250 game_context = self._getContext() minigame = BuyPrivateCompany() self.assertFalse( minigame.run(private_company_purchase_move, game_context)) self.assertIn( "Your bid is too small weenieboi. {} (Minimum Bid: {})".format( 250, 255), minigame.errors()) self.assertEqual(private_company_purchase_move.player.cash, 500, "Don't pay if you get things wrong.")
def testRunBuyPrivateCompanyMinigameAlreadyHasOwner(self): private_company_purchase_move = self._getMove() game_context = self._getContext() game_context.private_companies[0].belongs_to = game_context.players[0] minigame = BuyPrivateCompany() self.assertFalse( minigame.run(private_company_purchase_move, game_context)) self.assertIn( "Someone already owns this cheatingboi Fake company 0 / A", minigame.errors()) self.assertEqual(private_company_purchase_move.player.cash, 500, "Don't pay if you get things wrong.")
def testRunBuyPrivateCompanyMinigamePoorboiBoi(self): private_company_purchase_move = self._getMove() private_company_purchase_move.bid_amount = 13000 game_context = self._getContext() game_context.private_companies[1].cost = 12000 game_context.private_companies[1].actual_cost = 10000 minigame = BuyPrivateCompany() self.assertFalse( minigame.run(private_company_purchase_move, game_context)) self.assertIn( "You cannot afford poorboi. {} (You have: {})".format(13000, 500), minigame.errors()) self.assertEqual(private_company_purchase_move.player.cash, 500, "Don't pay if you get things wrong.")
def testRunBuyPrivateCompanyMinigameFirstHasBeenBought(self): private_company_purchase_move = self._getMove() private_company_purchase_move.private_company_order = 1 game_context = self._getContext() game_context.private_companies[0].belongs_to = game_context.players[0] minigame = BuyPrivateCompany() self.assertTrue( minigame.run(private_company_purchase_move, game_context)) self.assertEqual( private_company_purchase_move.private_company.belongs_to, private_company_purchase_move.player) self.assertEqual(private_company_purchase_move.player.cash, 500 - 250, "Player is not paying for the company")
def testRunBuyPrivateCompanyMinigameWrongOrder(self): """You cannot bid on something which is up for sale.""" private_company_purchase_move = self._getMove() private_company_purchase_move.private_company_order = 0 game_context = self._getContext() minigame = BuyPrivateCompany() self.assertFalse( minigame.run(private_company_purchase_move, game_context)) self.assertIn("You can't bid on this, it's currently for sale", minigame.errors()) self.assertEqual(private_company_purchase_move.player, game_context.players[0]) self.assertEqual(private_company_purchase_move.private_company, game_context.private_companies[0]) self.assertEqual(private_company_purchase_move.player.cash, 500, "Player shouldn't have to pay if there is an error.")
def testBuyPrivateCompanyMinigamePassNormal(self): private_company_purchase_move = self._getMove() game_context = self._getContext() minigame = BuyPrivateCompany() self.assertTrue( minigame.run(private_company_purchase_move, game_context)) self.assertEqual(private_company_purchase_move.player.cash, 500, "No cash loss for a pass action") self.assertTrue( game_context.private_companies[0].pass_count == 1, "Pass count is: {}".format( game_context.private_companies[0].pass_count)) # All players haven't passed so the cost should not go up. self.assertTrue(game_context.private_companies[0].cost == game_context.private_companies[0].actual_cost)
def testRunBuyPrivateCompanyMinigameWrongOrder(self): private_company_purchase_move = self._getMove() private_company_purchase_move.private_company_order = 1 game_context = self._getContext() minigame = BuyPrivateCompany() self.assertFalse( minigame.run(private_company_purchase_move, game_context)) self.assertIn( "You can't buy this yet. Fake company 0 needs to be sold first.", minigame.errors()) self.assertEqual(private_company_purchase_move.player, game_context.players[0]) self.assertEqual(private_company_purchase_move.private_company, game_context.private_companies[1]) self.assertEqual(private_company_purchase_move.player.cash, 500, "Player shouldn't have to pay if there is an error.")
def testRunBuyPrivateCompanyMinigamePriceDown(self): private_company_purchase_move = self._getMove() private_company_purchase_move.bid_amount = 255 game_context = self._getContext() minigame = BuyPrivateCompany() self.assertTrue( minigame.run(private_company_purchase_move, game_context)) self.assertEqual( private_company_purchase_move.player.cash, 500 - 255, "Player is not paying for bidding on the company (Money should be kept in trust)" ) private_company_purchase_move = self._getMove() private_company_purchase_move.player = game_context.players[1] private_company_purchase_move.player_id = game_context.players[1].id private_company_purchase_move.bid_amount = 260 self.assertEqual(private_company_purchase_move.player.cash, 500, "Player 2 should still have his cash..") minigame = BuyPrivateCompany() self.assertTrue( minigame.run(private_company_purchase_move, game_context), minigame.error_list) self.assertTrue( game_context.private_companies[0].pass_count == 2, "Pass count is: {}".format( game_context.private_companies[0].pass_count)) self.assertTrue(game_context.private_companies[0].cost == game_context.private_companies[0].actual_cost + 5)
def testBuyPrivateCompanyMinigamePassFreeCompany(self): private_company_purchase_move = self._getMove() game_context = self._getContext() game_context.private_companies[0].actual_cost = 0 minigame = BuyPrivateCompany() self.assertFalse( minigame.run(private_company_purchase_move, game_context)) self.assertEqual( private_company_purchase_move.player.cash, 500, "You must purchase the private company if its price has been reduced to zero. ({})" .format(0)) self.assertTrue( game_context.private_companies[0].pass_count == 0, "Pass count is: {}".format( game_context.private_companies[0].pass_count)) # All players haven't passed so the cost should not go up. self.assertTrue(game_context.private_companies[0].cost != game_context.private_companies[0].actual_cost)
def testRunBuyPrivateCompanyMinigame(self): """Tests that a bid is taken out of hte player's account and that the bid is listed on the private company""" private_company_purchase_move = self._getMove() game_context = self._getContext() minigame = BuyPrivateCompany() self.assertTrue( minigame.run(private_company_purchase_move, game_context)) self.assertEqual(private_company_purchase_move.player, game_context.players[0]) self.assertEqual(private_company_purchase_move.private_company, game_context.private_companies[1]) self.assertTrue( private_company_purchase_move.private_company.hasNoOwner) self.assertEqual( private_company_purchase_move.player.cash, 500 - 255, "Player is not paying for bidding on the company (Money should be kept in trust)" ) self.assertTrue( private_company_purchase_move.private_company.hasBids())