Exemplo n.º 1
0
    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
Exemplo n.º 2
0
 def to_json(self):
     return {
         'randomized_settings': self.randomized_settings,      
         'starting_items': SortedDict({name: record.to_json() for (name, record) in self.starting_items.items()}),
         'dungeons': {name: record.to_json() for (name, record) in self.dungeons.items()},
         'trials': {name: record.to_json() for (name, record) in self.trials.items()},
         'item_pool': SortedDict({name: record.to_json() for (name, record) in self.item_pool.items()}),
         'entrances': {name: record.to_json() for (name, record) in self.entrances.items()},
         'locations': {name: [rec.to_json() for rec in record] if is_pattern(name) else record.to_json() for (name, record) in self.locations.items()},
         ':woth_locations': None if self.woth_locations is None else {name: record.to_json() for (name, record) in self.woth_locations.items()},
         ':barren_regions': self.barren_regions,
         'gossip_stones': SortedDict({name: [rec.to_json() for rec in record] if is_pattern(name) else record.to_json() for (name, record) in self.gossip_stones.items()}),
     }