Exemple #1
0
def load_locations(version='emerald'):
    if version == 'emerald':
        region = 'hoenn'
    locations_index = phs.get_one('region', region)['locations']
    location_names = [l['name'] for l in locations_index]
    del location_names[location_names.index('mirage-forest'):]
    location_names = [
        l for l in location_names if l not in [
            'battle-resort', 'inside-of-truck', 'hoenn-altering-cave',
            'hoenn-safari-zone', 'ss-tidal', 'secret-base', 'sealed-chamber',
            'island-cave', 'desert-ruins', 'mirage-island', 'southern-island',
            'scorched-slab', 'hoenn-battle-tower', 'hoenn-pokemon-league',
            'underwater', 'mt-chimney', 'ancient-tomb', 'team-aqua-hideout',
            'team-magma-hideout', 'sky-pillar', 'mirage-tower', 'shoal-cave',
            'cave-of-origin', 'mt-pyre'
        ]
    ]
    locations = [phs.get_one('location', l) for l in location_names]
    for loc in locations:
        for key in ['names', 'region', 'game_indices']:
            loc.pop(key)
        loc['areas'] = [a['name'] for a in loc['areas']]

    areas = []
    for loc in locations:
        for a_name in loc['areas']:
            area = phs.get_one('location-area', a_name)
            for key in ['encounter_method_rates', 'names', 'game_index']:
                area.pop(key)
            areas.append(area)
            area['location'] = area['location']['name']
            for enc in area['pokemon_encounters']:
                enc['pokemon'] = enc['pokemon']['name']
                for v_details in enc['version_details']:
                    if v_details['version']['name'] == version:
                        for e_details in v_details['encounter_details']:
                            e_details['method'] = e_details['method']['name']
                        enc['encounter_details'] = v_details[
                            'encounter_details']
                        enc.pop('version_details')
                        break
            area['pokemon_encounters'] = list(
                filter(lambda enc: 'version_details' not in enc,
                       area['pokemon_encounters']))

    location_file_url = ds.get_data_directory() + 'emerald_locations.json'
    area_file_url = ds.get_data_directory() + 'emerald_areas.json'
    jds.save_data(location_file_url, locations)
    jds.save_data(area_file_url, areas)
Exemple #2
0
def get_area(area_name):
    path = ds.get_data_directory() + 'emerald_areas.json'
    areas = jds.load_data(path)
    for a in areas:
        if a['name'] == area_name:
            return a
    raise ValueError('Invalid area name: %s' % area_name)
Exemple #3
0
def get_all_locations(version='emerald'):
    path = ds.get_data_directory() + '%s_locations.json' % version
    locations = jds.load_data(path)
    return locations
Exemple #4
0
def get_areas(location_name, version='emerald'):
    path = ds.get_data_directory() + '%s_areas.json' % version
    areas = jds.load_data(path)
    areas_filtered = list(
        filter(lambda a: a['location'] == location_name, areas))
    return areas_filtered
def get_pokemon_data_directory():
    return ds.get_data_directory() + 'pokemon\\'
Exemple #6
0
# loads/saves pokemon data from/to the party_pokemon data file
import os
import auto_trainer.pokemon
import auto_trainer.services.directory_service as ds
import auto_trainer.services.json_data_service as jds
import auto_trainer.services.pokemon_file_service as pfs


def load_party():
    name_id_pairs = get_name_id_pairs()
    party_pokemon = [
        pfs.load_pokemon_from_file(n, i) for (n, i) in name_id_pairs
    ]
    return party_pokemon


def save_party(name_id_pairs):
    jds.save_data(_party_file_url, name_id_pairs)


def get_name_id_pairs():
    data = jds.load_data(_party_file_url)
    #print(data)
    return [(name, fid) for (name, fid) in data]


_party_file_url = '%sparty_pokemon.json' % ds.get_data_directory()