def test_process_input_matching_multiple_commands_ignored(self): location_one = Location('L1') location_two = Location('L2') location_one.add_one_way_exit(Direction('quick'), location_two) game = Game([location_one, location_two]) game.process_input('q')
def test_movement(self): location_one = Location('L1') location_two = Location('L2') location_one.add_one_way_exit(Direction('west'), location_two) game = Game([location_one, location_two]) game.process_input('w') self.assertEqual('L2', game.character.current_location.name)
def test_render_with_one_exit(self): location = Location(self.arbitrary_name) location.add_one_way_exit(Direction('north'), location) game = Game([location]) self.assertEqual(self.arbitrary_name + " (exits: north)", self.render(game, location))
def test_add_exit_with_no_opposite_raises(self): direction = Direction('up') location1 = Location(self.arbitrary_name) location2 = Location(self.arbitrary_name + '2') try: location1.add_exit(direction, location2) self.fail() except ValueError: # Success pass
# Use case: Run a procedurally defined game # Example: from vengeance.directions import DOWN, IN, WEST from vengeance.game import Direction from vengeance.game import Game from vengeance.game import Location church = Location('A Church', 'Tiny place of worship') crypt = Location('The Crypt', 'Dusty tomb filled with empty sarcophagi') coffin = Location('A Coffin', 'A tight squeeze and pitch dark') cave = Location('A Cave') church.add_exit(DOWN, crypt) crypt.add_one_way_exit(IN, coffin) crypt.add_exit(WEST, cave) game = Game([church, crypt, coffin, cave]) game.run()