def setUp(self): self.game = GameBattleship() input_user = [ '1, 1, 1, vertical', '1, 2, 2, vertical', '1, 3, 3, vertical', '1, 4, 3, vertical', '1, 5, 4, vertical', '1, 6, 5, vertical', ] board = Board() board_table = [ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 31, 32, 4, 5, 0, 0, 0], [0, 0, 2, 31, 32, 4, 5, 0, 0, 0], [0, 0, 0, 31, 32, 4, 5, 0, 0, 0], [0, 0, 0, 0, 0, 0, 4, 5, 0, 0], [0, 0, 0, 0, 0, 0, 0, 5, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ] board.set_board(board_table) self.game.play(1, 1, 1, 'vertical') self.game.play(1, 2, 2, 'vertical') self.game.play(1, 3, 3, 'vertical') self.game.play(1, 4, 3, 'vertical') self.game.play(1, 5, 4, 'vertical') self.game.play(1, 6, 5, 'vertical') # for single_input in input_user: # self.game.play(single_input) self.game.player_cpu.board_own.set_board(board)
def test_turn_war_player_wrong_number(self): game = GameBattleship() result = game.player_human.put_boat_own_board( 10, 1, 1, "vertical", ) self.assertFalse(result)
def test_next_turn_init(self): game = GameBattleship() result = game.next_turn() expected = 'pone el barco (x y boat horizontal/vertical)' self.assertEqual(expected, result)
def test_turn_war_player_wrong_param_letter(self): game = GameBattleship() result = game.play('A', 'B', 1, 'vertical') self.assertEqual(result, 'error')
def test_turn_war_player(self): game = GameBattleship() result = game.set_boat([1, 2, 1, 'vertical']) self.assertTrue(result)
def test_turn_init_player_wrong_param_amount_of(self): game = GameBattleship() result = game.set_boat([1, 1, 1, 'vertical', 'hdgsjhgdashjd']) self.assertEqual(result, 'error, mas parametros de los requeridos (4)')
def test_turn_init_player_boat_not_set_that_position(self): game = GameBattleship() result = game.set_boat([9, 9, 5, 'vertical']) self.assertEqual(result, 'Your boat could not be set in that position')
def test_game_state_init(self): game = GameBattleship() result = game.state self.assertEqual(result, 'init')
def test_game_players(self): game = GameBattleship() result = game.get_players() self.assertEqual(len(result), 2)