예제 #1
0
def test_that_status_manager_checks_whether_player_is_dead():
    status_manager = StatusManager(MapManager())

    assert not status_manager.is_dead()

    status_manager.update({"physical_state:dead": True})

    assert status_manager.is_dead()
예제 #2
0
class GameManager:
    def __init__(self):
        self.map_manager = MapManager()
        self.status_manager = StatusManager(self.map_manager)
        self.output_manager = OutputManager()

        self.action_manager = ActionManager(self.status_manager, self.output_manager)
        self.dialog_manager = DialogManager(self.status_manager, self.output_manager)
        self.move_manager = MoveManager(
            self.status_manager, self.output_manager
        )

    def intro(self):
        with open(intro_file, "r") as fp:
            intro = json.load(fp)["intro"]
        self.output_manager.print(intro)

    def start(self):
        self.intro()
        response = input()
        while response.lower() != "quit":
            self.process_response(response)
            if self.status_manager.is_dead():
                break
            response = input()

    def process_response(self, response):
        # find response mapping in dialog or action dictionaries
        if self.dialog_manager.detect_dialog(response):
            self.dialog_manager.process_response(response)
        elif self.move_manager.detect_move(response):
            self.move_manager.process_response(response)
        else:
            self.action_manager.process_response(response)