def move_character(action: str) -> None: """Move character north, south, east, or west. PRECONDITION: direction must be 'n', 's', 'e', or 'w' POSTCONDITION: Modify row/column of character position """ if action == "n": rebel.set_row(rebel.get_row() - 1) elif action == "s": rebel.set_row(rebel.get_row() + 1) elif action == "e": rebel.set_column(rebel.get_column() + 1) elif action == "w": rebel.set_column(rebel.get_column() - 1)
def test_is_valid_move_with_west_invalid_move(self): set_column(0) self.assertFalse(is_valid_move("w"))
def test_is_valid_move_with_west_valid_move(self): for i in range(1, 10): set_column(i) self.assertTrue(is_valid_move("w"))
def test_is_valid_move_with_east_invalid_move(self): set_column(10) self.assertFalse(is_valid_move("e"))
def test_is_valid_move_with_east_valid_move(self): for i in range(0, 9): set_column(i) self.assertTrue(is_valid_move("e"))
def test_get_column_after_modified(self): rebel.set_column(3) self.assertIs(get_column(), rebel.rebel["Column"])
def reset_game() -> None: """Reset character HP and position.""" rebel.set_hp(10) rebel.set_row(5) rebel.set_column(5)
def test_set_column_value_reflects_parameter_passed(self): set_column(9) self.assertIs(rebel["Column"], 9)
def test_set_column_changed_from_original(self): original = rebel["Column"] set_column(6) self.assertIsNot(original, rebel["Column"])