Пример #1
0
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)
Пример #2
0
 def test_get_row_after_modified(self):
     rebel.set_row(1)
     self.assertIs(get_row(), rebel.rebel["Row"])
Пример #3
0
 def test_is_valid_move_with_north_valid_move(self):
     for i in range(1, 10):
         set_row(i)
         self.assertTrue(is_valid_move("n"))
Пример #4
0
 def test_is_valid_move_with_south_invalid_move(self):
     set_row(10)
     self.assertFalse(is_valid_move("s"))
Пример #5
0
 def test_is_valid_move_with_south_valid_move(self):
     for i in range(0, 9):
         set_row(i)
         self.assertTrue(is_valid_move("s"))
Пример #6
0
 def test_is_valid_move_with_north_invalid_move(self):
     set_row(0)
     self.assertFalse(is_valid_move("n"))
Пример #7
0
def reset_game() -> None:
    """Reset character HP and position."""
    rebel.set_hp(10)
    rebel.set_row(5)
    rebel.set_column(5)
Пример #8
0
 def test_set_row_value_reflects_argument_passed(self):
     set_row(4)
     self.assertEqual(rebel["Row"], 4)
Пример #9
0
 def test_set_row_changed_from_original(self):
     original = rebel["Row"]
     set_row(6)
     self.assertIsNot(original, rebel["Row"])