def test_ship_setters(): ship = Ship(4, [(3, 2), (3, 3), (3, ), (3, 5)], 'poziom') ship.set_location([(2, 5), (2, 6), (2, 7)]) ship.set_size(3) ship.set_direction('pion') assert ship.get_location() == [(2, 5), (2, 6), (2, 7)] assert ship.get_size() == 3 assert ship.get_direction() == 'pion'
def test_hit(): dim = 8 matrix = np.zeros((dim, dim), dtype=int) m_obj = Matrix(matrix) ship1 = Ship(4, [(3, 2), (3, 3), (3, 4), (3, 5)], 'poziom') size = ship1.get_size() ship2 = Ship(3, [(2, 6)], 'pion') fleet = Fleet([ship1, ship2]) cords = (3, 2) lifes, m_obj, fleet = hit(m_obj, cords, fleet, dim) assert lifes < size
def test_ship_getters(): ship = Ship(4, [(3, 2), (3, 3), (3, 4), (3, 5)], 'poziom') assert ship.get_location() == [(3, 2), (3, 3), (3, 4), (3, 5)] assert ship.get_size() == 4 assert ship.get_direction() == 'poziom'
def test_ship_hurt(): ship = Ship(4, [(3, 2), (3, 3), (3, 4), (3, 5)], 'poziom') ship.hurt() ship.hurt() assert ship.get_size() == 2