def setUp(self): self.ship = ships.Ship("TestShip", 4, "White") self.field = ships.PlayField(4, 4) self.fleet = Fleet() self.player1 = Player('Bob', self.field, self.fleet) self.computer = ComputerPlayer(self.field, self.fleet) self.baseUI = BaseUI(self.player1._play_field) self.battle = BattleshipGame(self.field, self.baseUI, self.player1, self.computer)
def setUp(self): self.ship = ships.Ship("TestShip", 4, "White") play_field = PlayField(BATTLEFIELD_COLUMNS, BATTLEFIELD_ROWS) self.ui = AsciiUI(play_field) self.playField = ships.PlayField(10, 10) player_fleet = Fleet.standard_fleet() player_fleet.random_positioning(play_field) self.player = Player("Hawk-eyed Human", play_field, player_fleet) computer_fleet = Fleet.standard_fleet() computer_fleet.random_positioning(play_field) self.ship.all_positions.add(Point(1, 2)) self.computer = ComputerPlayer(play_field, computer_fleet)
def setUp(self): self.ship = ships.Ship("TestShip", 4, "White")
def test_overlaps_with(self): self.assertFalse( self.ship.overlaps_with(ships.Ship("TestShip", 4, "White")))
def test_receive_fire2(self): ship2 = ships.Ship("TestShip2", 4, "White") ship2.all_positions.add(Point(1, 2)) ship2.receive_fire(Point(1, 2)) self.fleet.ships.append(ship2) self.assertFalse(self.fleet.receive_fire(Point(1, 2)) == "TestShip2")
def test_receive_fire(self): ship = ships.Ship("TestShip", 4, "Black") self.assertFalse(self.fleet.receive_fire(Point(1, 2)) == ship)
def test_add_ship(self): self.fleet.ships.append(ships.Ship("TestShip", 4, "White")) self.assertTrue(self.fleet.ships.__len__() == 1)