Пример #1
0
 def setUp(self):
     self.scenario = ScenarioGenerator("seed for testing")
     npc1 = self.scenario.npcs[0]
     npc2 = self.scenario.npcs[1]
     note1 = Notes(npc1, self.scenario)
     note2 = Notes(npc2, self.scenario)
     self.notes = {npc1.name: note1, npc2.name: note2}
Пример #2
0
    def load_from_file(self, name):
        """Loads a scenario from a specific file.

        Args:
            name: The name of the file from which to load a scenario.
        """

        # Open the given save file (may fail, change this!)
        file = open(f"src/data/saves/{name}", "r")
        # Convert file content to base64 data
        data = file.read().encode("ascii")
        # Decode base64 to JSON string
        content = base64.b64decode(data).decode("utf-8")
        # Convert JSON string to JSON data
        json_data = json.loads(content)
        # Get seed and difficulty, generate the scenario from given seed
        # and difficulty
        seed = json_data['seed']
        difficulty = json_data['difficulty']
        scenario = ScenarioGenerator(seed, difficulty)
        # Return the notes to the state they were in at the time of saving
        notes = {}
        for npc in scenario.npcs:
            note = Notes(npc, scenario)
            note.routine = json_data[npc.name]['routine']
            note.company = json_data[npc.name]['company']
            note.npc_location_at_time = json_data[npc.name]['npc_locations']
            notes[npc.name] = note
        # Return the re-generated scenario and notes
        return scenario, notes
Пример #3
0
 def start_game(self):
     self.new_game_menu.disable()
     self.load_game_menu.disable()
     self.menu.disable()
     self.surface.fill((0,0,0))
     scenario = ScenarioGenerator(self.seed, self.difficulty)
     notes = {}
     for npc in scenario.npcs:
         notes[npc.name] = Notes(npc,scenario)
     intro = Intro(scenario, notes, self.surface, self.clock)
     intro.start()
     # This is run if the player returns from the game without terminating the process
     self.new_game_menu.enable()
     self.load_game_menu.enable()
     self.return_to_main_menu()
Пример #4
0
 def test_same_seed_gives_same_npcs(self):
     scen1 = ScenarioGenerator(self.seed)
     scen2 = ScenarioGenerator(self.seed)
     self.assertEqual(scen1.npcs, scen2.npcs)
Пример #5
0
 def test_same_seed_gives_same_murderer_despite_difficulty(self):
     scen1 = ScenarioGenerator(self.seed)
     scen2 = ScenarioGenerator(self.seed, 2)
     self.assertEqual(scen1.murderer, scen2.murderer)
Пример #6
0
 def test_same_seed_gives_same_murderer(self):
     scen1 = ScenarioGenerator(self.seed)
     scen2 = ScenarioGenerator(self.seed)
     self.assertEqual(scen1.murderer, scen2.murderer)
 def setUp(self):
     self.scenario = ScenarioGenerator("seed for testing")
     self.time = Time(36)
     self.interrogation = Interrogation(self.time, self.scenario)