示例#1
0
    def test_terminar_partida_gana_humano_por_truco(self):
        game = Game()
        for i in range(8):
            game.hand.hidden_cards = [
                [Card(SWORD, 1), Card(CUP, 3),
                 Card(CUP, 2)],
                [Card(COARSE, 4),
                 Card(COARSE, 4),
                 Card(COARSE, 4)],
            ]
            with unittest.mock.patch("truco.player.CPUPlayer.ask_trucos",
                                     return_value='ACCEPTED'):
                game.play("TRUCO")
            with unittest.mock.patch("truco.player.CPUPlayer.cpu_play",
                                     return_value='PLAY'):
                game.play("0")
            with unittest.mock.patch("truco.player.CPUPlayer.cpu_play",
                                     return_value='PLAY'):
                game.play("0")

        self.assertEqual(game.players[0].score, 16)
        self.assertEqual(game.players[1].score, 0)
        self.assertEqual(game.is_playing, False)
        result = game.next_turn()
        self.assertEqual(result, "\nGame Over!")
示例#2
0
    def test_terminar_partida_gana_pc_por_envido(self):
        game = Game()
        for i in range(5):
            game.hand.hidden_cards = [
                [Card(SWORD, 4),
                 Card(SWORD, 4),
                 Card(SWORD, 4)],
                [Card(CUP, 1), Card(CUP, 7),
                 Card(CUP, 6)],
            ]
            with unittest.mock.patch("truco.player.CPUPlayer.ask_envido",
                                     return_value='ACCEPTED'):
                game.play("ENVIDO")
            with unittest.mock.patch("truco.player.CPUPlayer.cpu_play",
                                     return_value='PLAY'):
                game.play("0")
            with unittest.mock.patch("truco.player.CPUPlayer.cpu_play",
                                     return_value='PLAY'):
                game.play("0")

        self.assertEqual(game.players[1].score, 15)
        self.assertEqual(game.players[0].score, 0)
        self.assertEqual(game.is_playing, False)
        result = game.next_turn()
        self.assertEqual(result, "\nGame Over!")
示例#3
0
 def test_mensaje_next_turn_truco_accepted(self, mock_ask_envido):
     game = Game()
     game.play('TRUCO')
     game.hand.hidden_cards = [
         [Card(SWORD, 3), Card(SWORD, 12),
          Card(GOLD, 10)],
         [Card(COARSE, 4),
          Card(COARSE, 4),
          Card(COARSE, 4)],
     ]
     expected = ('0 to play 3 espada\n'
                 '1 to play 12 espada\n'
                 '2 to play 10 oro\n'
                 'DECK: Go to the Deck \n')
     result = game.next_turn()
     self.assertEqual(expected, result)
示例#4
0
 def test_mensaje_next_turn_init(self):
     game = Game()
     game.hand.hidden_cards = [
         [Card(CUP, 1), Card(COARSE, 7),
          Card(CUP, 12)],
         [Card(COARSE, 4),
          Card(COARSE, 4),
          Card(COARSE, 4)],
     ]
     result = game.next_turn()
     expected = ('0 to play 1 copa\n'
                 '1 to play 7 basto\n'
                 '2 to play 12 copa\n'
                 'ENVIDO, REAL_ENVIDO, FALTA_ENVIDO: Sing envido \n'
                 'DECK: Go to the Deck \n'
                 'TRUCO: Sing truco \n')
     self.assertEqual(result, expected)
示例#5
0
 def test_mensaje_next_turn_envido_accepted(self, mock_ask_envido):
     game = Game()
     game.play('ENVIDO')
     game.hand.hidden_cards = [
         [Card(COARSE, 4),
          Card(COARSE, 5),
          Card(COARSE, 6)],
         [Card(COARSE, 4),
          Card(COARSE, 4),
          Card(COARSE, 4)],
     ]
     expected = ('0 to play 4 basto\n'
                 '1 to play 5 basto\n'
                 '2 to play 6 basto\n'
                 'DECK: Go to the Deck \n'
                 'TRUCO: Sing truco \n')
     result = game.next_turn()
     self.assertEqual(expected, result)