def test_player_pick_card_auto(self): deck = a2.Deck() deck.add_cards([ a2.Card(1, a2_support.CardColour.blue), a2.Card(3, a2_support.CardColour.red), a2.Card(2, a2_support.CardColour.green), a2.Card(4, a2_support.CardColour.yellow), a2.Card(6, a2_support.CardColour.yellow), a2.Card(10, a2_support.CardColour.blue) ]) player = a2.ComputerPlayer("Test Player") player.get_deck().add_card(a2.Card(6, a2_support.CardColour.yellow)) picked = player.pick_card(deck) self.assertIsNone( picked, "ComputerPlayer.pick_card should return None if no card can be played" ) cards = [ a2.Card(10, a2_support.CardColour.yellow), a2.Card(3, a2_support.CardColour.red), a2.Card(2, a2_support.CardColour.green), a2.Card(4, a2_support.CardColour.blue), a2.Card(5, a2_support.CardColour.yellow), ] player.get_deck().add_cards(cards) picked = player.pick_card(deck) self.assertIsInstance( picked, a2.Card, "ComputerPlayer.pick_card should return an instance of Card (or a subclass) if it is possible to play a card" )
def loadGame(self): deck = [ a2.Card(1, a2_support.CardColour.red), a2.Card(2, a2_support.CardColour.blue), a2.Card(3, a2_support.CardColour.green), a2.Card(4, a2_support.CardColour.yellow), a2.Card(5, a2_support.CardColour.red), a2.Card(6, a2_support.CardColour.blue), a2.Card(7, a2_support.CardColour.blue), ] self._deck = a2.Deck(starting_cards=deck) self._players = [ a2.HumanPlayer("Anna Truffet"), a2.ComputerPlayer("Ashleigh Richardson"), a2.HumanPlayer("Benjamin Martin"), a2.ComputerPlayer("Brae Webb"), a2.HumanPlayer("Harry Keightly"), a2.ComputerPlayer("Henry O'Brien"), a2.HumanPlayer("Joshua Arnold"), a2.ComputerPlayer("Justin Luong"), a2.HumanPlayer("Luis Woodrow"), a2.ComputerPlayer("Mike Pham"), a2.HumanPlayer("Rudi Scarpa"), a2.ComputerPlayer("Sam Eadie"), a2.HumanPlayer("Steven Summers"), a2.ComputerPlayer("Wilson Kong"), ] self._game = a2_support.UnoGame(self._deck, self._players)
def test_player_playable(self): with self.assertRaises(NotImplementedError): a2.Player("Test Player").is_playable() self.assertIs( a2.HumanPlayer("Test Player").is_playable(), True, "HumanPlayer.is_playable should return True") self.assertIs( a2.ComputerPlayer("Test Player").is_playable(), False, "ComputerPlayer.is_playable should return False")