def test_player_has_an_extra_card_if_there_Are_no_valid_cards(self): players = [Player(name="DSP", cards=[]), Player(name="SPD", cards=[])] game = Game(players, deck, disable_output=True) # Overwriting variables for mocking game.top_card = Card("BLUE", 4) game.discard_pile = [Card("BLUE", 4)] players[1].cards = [Card("RED", 5)] * 7 game.start() self.assertEqual(len(players[1].cards), 8)
def test_pile_has_one_extra_card_after_players_turn(self): players = [Player(name="DSP", cards=[]), Player(name="SPD", cards=[])] game = Game(players, deck, disable_output=True) game.top_card = Card("BLUE", 4) game.discard_pile = [Card("BLUE", 4)] players[1].cards = [ Card("RED", action="REVERSE"), Card("YELLOW", 4), Card("RED", 2), Card("GREEN", 8), Card("BLUE", 8), Card("GREEN", action="DRAW_TWO"), Card("GREEN", action="DRAW_TWO") ] game.start() # Start the game after setup self.assertEqual(len(game.discard_pile), 2)
def test_top_card_should_be_updated_when_a_player_plays(self): players = [Player(name="DSP", cards=[]), Player(name="SPD", cards=[])] game = Game(players, deck, disable_output=True) # Overwriting variables for mocking game.top_card = Card("BLUE", 4) game.discard_pile = [Card("BLUE", 4)] players[1].cards = [ Card("RED", action="REVERSE"), Card("YELLOW", 4), Card("RED", 2), Card("GREEN", 8), Card("BLUE", 8), Card("GREEN", action="DRAW_TWO"), Card("GREEN", action="DRAW_TWO") ] game.start() self.assertEqual(game.top_card, game.discard_pile[-1])
def test_last_player_decision_is_play_if_player_plays(self): players = [Player(name="DSP", cards=[]), Player(name="SPD", cards=[])] game = Game(players, deck, disable_output=True) # Overwriting variables for mocking game.top_card = Card("BLUE", 4) game.discard_pile = [Card("BLUE", 4)] players[1].cards = [ Card("RED", action="REVERSE"), Card("YELLOW", 4), Card("RED", 2), Card("GREEN", 8), Card("BLUE", 8), Card("GREEN", action="DRAW_TWO"), Card("GREEN", action="DRAW_TWO") ] game.start() self.assertEqual(game.last_player_decision, "PLAY")
def test_player_played_a_valid_card(self): players = [Player(name="DSP", cards=[]), Player(name="SPD", cards=[])] game = Game(players, deck, disable_output=True) # Overwriting variables for mocking game.top_card = Card("BLUE", 4) game.discard_pile = [Card("BLUE", 4)] players[1].cards = [ Card("RED", action="REVERSE"), Card("YELLOW", 4), Card("RED", 2), Card("GREEN", 8), Card("BLUE", 8), Card("GREEN", action="DRAW_TWO"), Card("GREEN", action="DRAW_TWO") ] game.start() # Start the game after setup self.assertTrue( is_played_card_valid(game.discard_pile[1], game.discard_pile[0]))
import os import sys module_path = os.path.abspath(os.getcwd()) sys.path.append(module_path) from uno.Game import Game from uno.Deck import Deck from uno.Player import Player cards = Deck().cards # cards = [Card("RED", 5), Card("RED", 5), Card("RED", 5), Card("RED", 5), # Card("RED", 5), Card("RED", 5), Card("RED", 5), Card("RED", 5), # Card("RED", 5), Card("RED", 5), Card("RED", 5), Card("RED", 5), # Card("RED", 5), Card("RED", 5), Card("BLUE", 4)] players = [Player("DSP", []), Player("SPD", [])] # with mock.patch.object(Game, "shuffle_deck") as mock_shuffle: # mock_shuffle.return_value = cards # game = Game(players, cards) game = Game(players, cards) print(players[0].cards) print() print(players[1].cards) # print(players[1].cards) # print(game.top_card) game.start()
def test_last_player_decision_is_take_if_player_takes(self): players = [Player(name="DSP", cards=[]), Player(name="SPD", cards=[])] game = Game(players, deck, disable_output=True) # Overwriting variables for mocking game.top_card = Card("BLUE", 4) game.discard_pile = [Card("BLUE", 4)] players[1].cards = [Card("RED", 5)] * 7 game.start() self.assertEqual(game.last_player_decision, "TAKE")