Exemplo n.º 1
0
 def to_file(self, path):
     if self.version == 14:
         RawSaveFile(version=14,
                     save_data={
                         'version': self.version,
                         'location': self.location,
                         'runs': self.runs,
                         'active_meta_points': self.active_meta_points,
                         'active_shrine_points': self.active_shrine_points,
                         'god_mode_enabled': self.god_mode_enabled,
                         'hell_mode_enabled': self.hell_mode_enabled,
                         'lua_keys': self.lua_keys,
                         'current_map_name': self.current_map_name,
                         'start_next_map': self.start_next_map,
                         'lua_state': self.lua_state.to_bytes(),
                     }).to_file(path)
     elif self.version == 15:
         RawSaveFile(version=15,
                     save_data={
                         'version': self.version,
                         'location': self.location,
                         'runs': self.runs,
                         'active_meta_points': self.active_meta_points,
                         'active_shrine_points': self.active_shrine_points,
                         'god_mode_enabled': self.god_mode_enabled,
                         'hell_mode_enabled': self.hell_mode_enabled,
                         'lua_keys': self.lua_keys,
                         'current_map_name': self.current_map_name,
                         'start_next_map': self.start_next_map,
                         'lua_state': self.lua_state.to_bytes(),
                     }).to_file(path)
     else:
         raise Exception(f"Unsupported version {self.version}")
Exemplo n.º 2
0
    def from_file(cls, path):
        raw_save_file = RawSaveFile.from_file(path)
        lua_state = LuaState.from_bytes(
            version=raw_save_file.version,
            input_bytes=bytes(raw_save_file.lua_state_bytes)
        )

        # Unused, for debugging
        lua_state.raw_save_file = raw_save_file

        if raw_save_file.version < 16:
            return HadesSaveFile(
                version=raw_save_file.version,
                location=raw_save_file.save_data['location'],
                runs=raw_save_file.save_data['runs'],
                active_meta_points=raw_save_file.save_data['active_meta_points'],
                active_shrine_points=raw_save_file.save_data['active_shrine_points'],
                god_mode_enabled=raw_save_file.save_data['god_mode_enabled'],
                hell_mode_enabled=raw_save_file.save_data['hell_mode_enabled'],
                lua_keys=raw_save_file.save_data['lua_keys'],
                current_map_name=raw_save_file.save_data['current_map_name'],
                start_next_map=raw_save_file.save_data['start_next_map'],
                lua_state=lua_state,
                raw_save_file=raw_save_file
            )
        else:
            return HadesSaveFile(
                version=raw_save_file.version,
                timestamp=raw_save_file.save_data['timestamp'],
                location=raw_save_file.save_data['location'],
                runs=raw_save_file.save_data['runs'],
                active_meta_points=raw_save_file.save_data['active_meta_points'],
                active_shrine_points=raw_save_file.save_data['active_shrine_points'],
                god_mode_enabled=raw_save_file.save_data['god_mode_enabled'],
                hell_mode_enabled=raw_save_file.save_data['hell_mode_enabled'],
                lua_keys=raw_save_file.save_data['lua_keys'],
                current_map_name=raw_save_file.save_data['current_map_name'],
                start_next_map=raw_save_file.save_data['start_next_map'],
                lua_state=lua_state,
                raw_save_file=raw_save_file
            )