def to_json(self, include_output=True, spoiler=True): self_dict = { ':version': __version__, 'file_hash': CollapseList(self.file_hash), ':seed': self.settings.seed, ':settings_string': self.settings.settings_string, 'settings': self.settings.to_json(), } if spoiler: world_dist_dicts = [ world_dist.to_json() for world_dist in self.world_dists ] if self.settings.world_count > 1: for k in per_world_keys: self_dict[k] = {} for id, world_dist_dict in enumerate(world_dist_dicts): self_dict[k]['World %d' % (id + 1)] = world_dist_dict[k] else: self_dict.update( {k: world_dist_dicts[0][k] for k in per_world_keys}) if self.playthrough is not None: self_dict[':playthrough'] = AllignedDict( { sphere_nr: SortedDict({ name: record.to_json() for name, record in sphere.items() }) for (sphere_nr, sphere) in self.playthrough.items() }, depth=2) if self.entrance_playthrough is not None and len( self.entrance_playthrough) > 0: self_dict[':entrance_playthrough'] = AllignedDict( { sphere_nr: SortedDict({ name: record.to_json() for name, record in sphere.items() }) for (sphere_nr, sphere) in self.entrance_playthrough.items() }, depth=2) if not include_output: strip_output_only(self_dict) self_dict['settings'] = dict(self._settings) return self_dict
def to_json(self): if self.colors is not None: self.colors = CollapseList(self.colors) return CollapseDict(super().to_json())