2015-04-21 03:31:59 +00:00
|
|
|
# To build out the data you'll need to jump into the Django shell
|
|
|
|
#
|
|
|
|
# $ python manage.py shell
|
|
|
|
#
|
|
|
|
# and run the build script with
|
|
|
|
#
|
2015-12-07 20:29:39 +00:00
|
|
|
# $ from data.v2.build import build_all
|
|
|
|
# $ build_all()
|
2015-04-21 03:31:59 +00:00
|
|
|
#
|
|
|
|
# Each time the build script is run it will iterate over each table in the database,
|
2016-03-05 12:25:50 +00:00
|
|
|
# wipe it and rewrite each row using the data found in data/v2/csv.
|
2015-12-07 20:17:33 +00:00
|
|
|
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2015-04-02 12:21:39 +00:00
|
|
|
import csv
|
|
|
|
import os
|
2015-12-05 11:13:46 +00:00
|
|
|
import os.path
|
2015-12-27 05:42:41 +00:00
|
|
|
import re
|
2016-02-16 06:31:19 +00:00
|
|
|
import json
|
2016-03-05 11:40:41 +00:00
|
|
|
from django.db import connection
|
2018-10-20 00:05:10 +00:00
|
|
|
from pokemon_v2.models import *
|
2015-04-02 12:21:39 +00:00
|
|
|
|
2015-04-06 04:27:59 +00:00
|
|
|
|
2015-12-05 11:13:46 +00:00
|
|
|
# why this way? how about use `__file__`
|
2018-10-20 00:05:10 +00:00
|
|
|
DATA_LOCATION = "data/v2/csv/"
|
|
|
|
DATA_LOCATION2 = os.path.join(os.path.dirname(__file__), "csv")
|
2015-12-27 05:42:41 +00:00
|
|
|
GROUP_RGX = r"\[(.*?)\]\{(.*?)\}"
|
|
|
|
SUB_RGX = r"\[.*?\]\{.*?\}"
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
DB_CURSOR = connection.cursor()
|
2015-12-05 11:13:46 +00:00
|
|
|
DB_VENDOR = connection.vendor
|
|
|
|
|
2015-12-27 05:42:41 +00:00
|
|
|
|
2022-08-08 13:49:09 +00:00
|
|
|
MEDIA_DIR = "{prefix}{{file_name}}".format(
|
|
|
|
prefix=os.environ.get("POKEAPI_SPRITES_PREFIX", "/media/sprites/")
|
|
|
|
)
|
2020-07-10 06:58:11 +00:00
|
|
|
IMAGE_DIR = os.getcwd() + "/data/v2/sprites/sprites/"
|
2018-10-20 00:05:10 +00:00
|
|
|
RESOURCE_IMAGES = []
|
2015-12-27 05:42:41 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
for root, dirs, files in os.walk(IMAGE_DIR):
|
|
|
|
for file in files:
|
|
|
|
image_path = os.path.join(root.replace(IMAGE_DIR, ""), file)
|
|
|
|
image_path = image_path.replace("\\", "/") # convert Windows-style path to Unix
|
|
|
|
RESOURCE_IMAGES.append(image_path)
|
2016-03-05 11:40:41 +00:00
|
|
|
|
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
def file_path_or_none(file_name):
|
2022-08-08 13:49:09 +00:00
|
|
|
return (
|
|
|
|
MEDIA_DIR.format(file_name=file_name) if file_name in RESOURCE_IMAGES else None
|
|
|
|
)
|
2016-02-16 06:31:19 +00:00
|
|
|
|
|
|
|
|
2015-12-05 11:13:46 +00:00
|
|
|
def with_iter(context, iterable=None):
|
|
|
|
if iterable is None:
|
|
|
|
iterable = context
|
|
|
|
with context:
|
|
|
|
for value in iterable:
|
|
|
|
yield value
|
|
|
|
|
2015-12-27 05:42:41 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
def load_data(file_name):
|
2015-12-05 11:13:46 +00:00
|
|
|
# with_iter closes the file when it has finished
|
2018-10-20 00:05:10 +00:00
|
|
|
return csv.reader(
|
|
|
|
with_iter(open(DATA_LOCATION + file_name, "rt", encoding="utf8")), delimiter=","
|
|
|
|
)
|
2015-12-05 11:13:46 +00:00
|
|
|
|
2015-12-27 05:42:41 +00:00
|
|
|
|
2015-12-05 11:13:46 +00:00
|
|
|
def clear_table(model):
|
|
|
|
table_name = model._meta.db_table
|
|
|
|
model.objects.all().delete()
|
2018-10-20 00:05:10 +00:00
|
|
|
print("building " + table_name)
|
2015-12-05 11:13:46 +00:00
|
|
|
# Reset DB auto increments to start at 1
|
2018-10-20 00:05:10 +00:00
|
|
|
if DB_VENDOR == "sqlite":
|
|
|
|
DB_CURSOR.execute(
|
|
|
|
"DELETE FROM sqlite_sequence WHERE name = " + "'" + table_name + "'"
|
|
|
|
)
|
2015-12-05 11:13:46 +00:00
|
|
|
else:
|
2018-10-20 00:05:10 +00:00
|
|
|
DB_CURSOR.execute(
|
|
|
|
"SELECT setval(pg_get_serial_sequence("
|
|
|
|
+ "'"
|
|
|
|
+ table_name
|
|
|
|
+ "'"
|
|
|
|
+ ",'id'), 1, false);"
|
|
|
|
)
|
2015-12-05 11:13:46 +00:00
|
|
|
|
2015-12-27 05:42:41 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def build_generic(model_classes, file_name, csv_record_to_objects):
|
|
|
|
batches = {}
|
2018-09-06 20:00:41 +00:00
|
|
|
for model_class in model_classes:
|
|
|
|
clear_table(model_class)
|
2018-10-20 00:05:10 +00:00
|
|
|
batches[model_class] = [] # one batch per model class
|
2018-09-06 20:00:41 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
csv_data = load_data(file_name)
|
|
|
|
next(csv_data, None) # skip header
|
2018-09-06 20:00:41 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
for csv_record in csv_data:
|
|
|
|
for obj in csv_record_to_objects(csv_record):
|
|
|
|
model_class = type(obj)
|
|
|
|
batches[model_class].append(obj)
|
2015-12-05 11:13:46 +00:00
|
|
|
|
2018-09-06 20:00:41 +00:00
|
|
|
# Limit the batch size
|
2018-09-08 22:42:24 +00:00
|
|
|
if len(batches[model_class]) > 200:
|
|
|
|
model_class.objects.bulk_create(batches[model_class])
|
|
|
|
batches[model_class] = []
|
2015-12-27 05:42:41 +00:00
|
|
|
|
2018-10-18 22:56:38 +00:00
|
|
|
for model_class, batch in batches.items():
|
2018-09-08 22:42:24 +00:00
|
|
|
model_class.objects.bulk_create(batch)
|
2015-04-06 04:27:59 +00:00
|
|
|
|
2015-12-27 05:42:41 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
def scrub_str(string):
|
2015-12-27 05:42:41 +00:00
|
|
|
"""
|
2016-03-05 11:40:41 +00:00
|
|
|
The purpose of this function is to scrub the weird template mark-up out of strings
|
2015-12-27 05:42:41 +00:00
|
|
|
that Veekun is using for their pokedex.
|
|
|
|
Example:
|
|
|
|
[]{move:dragon-tail} will effect the opponents [HP]{mechanic:hp}.
|
|
|
|
Becomes:
|
|
|
|
dragon tail will effect the opponents HP.
|
|
|
|
|
|
|
|
If you find this results in weird strings please take a stab at improving or re-writing.
|
|
|
|
"""
|
2018-10-20 00:05:10 +00:00
|
|
|
groups = re.findall(GROUP_RGX, string)
|
2015-12-27 05:42:41 +00:00
|
|
|
for group in groups:
|
|
|
|
if group[0]:
|
|
|
|
sub = group[0]
|
|
|
|
else:
|
2019-12-17 16:25:50 +00:00
|
|
|
sub = group[1].split(":")
|
|
|
|
if len(sub) >= 2:
|
|
|
|
sub = sub[1]
|
|
|
|
else:
|
|
|
|
sub = sub[0]
|
2015-12-27 05:42:41 +00:00
|
|
|
sub = sub.replace("-", " ")
|
2018-10-20 00:05:10 +00:00
|
|
|
string = re.sub(SUB_RGX, sub, string, 1)
|
|
|
|
return string
|
2015-12-27 05:42:41 +00:00
|
|
|
|
|
|
|
|
2015-04-06 04:27:59 +00:00
|
|
|
##############
|
|
|
|
# LANGUAGE #
|
|
|
|
##############
|
|
|
|
|
2018-09-07 19:06:34 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
def _build_languages():
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2016-03-05 11:40:41 +00:00
|
|
|
yield Language(
|
|
|
|
id=int(info[0]),
|
|
|
|
iso639=info[1],
|
|
|
|
iso3166=info[2],
|
|
|
|
name=info[3],
|
|
|
|
official=bool(int(info[4])),
|
|
|
|
order=info[5],
|
2015-12-05 11:13:46 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((Language,), "languages.csv", csv_record_to_objects)
|
2015-04-06 04:27:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield LanguageName(
|
2018-10-20 00:05:10 +00:00
|
|
|
language_id=int(info[0]), local_language_id=int(info[1]), name=info[2]
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
build_generic((LanguageName,), "language_names.csv", csv_record_to_objects)
|
2015-04-06 04:27:59 +00:00
|
|
|
|
|
|
|
|
2015-10-29 17:45:58 +00:00
|
|
|
############
|
|
|
|
# REGION #
|
|
|
|
############
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-07 19:06:34 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
def _build_regions():
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield Region(id=int(info[0]), name=info[1])
|
|
|
|
|
|
|
|
build_generic((Region,), "regions.csv", csv_record_to_objects)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield RegionName(region_id=int(info[0]), language_id=int(info[1]), name=info[2])
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
build_generic((RegionName,), "region_names.csv", csv_record_to_objects)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2015-04-06 04:27:59 +00:00
|
|
|
|
2015-10-29 17:45:58 +00:00
|
|
|
################
|
|
|
|
# GENERATION #
|
|
|
|
################
|
2015-04-06 04:27:59 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
|
2018-09-07 19:06:34 +00:00
|
|
|
def _build_generations():
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2021-07-19 18:00:40 +00:00
|
|
|
yield Generation(id=int(info[0]), region_id=int(info[1]), name=info[2])
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((Generation,), "generations.csv", csv_record_to_objects)
|
2015-04-06 04:27:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield GenerationName(
|
2018-10-20 00:05:10 +00:00
|
|
|
generation_id=int(info[0]), language_id=int(info[1]), name=info[2]
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2015-04-06 04:27:59 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
build_generic((GenerationName,), "generation_names.csv", csv_record_to_objects)
|
2015-04-06 04:27:59 +00:00
|
|
|
|
|
|
|
|
2015-10-29 17:45:58 +00:00
|
|
|
#############
|
|
|
|
# VERSION #
|
|
|
|
#############
|
2015-04-06 04:27:59 +00:00
|
|
|
|
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
def _build_versions():
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield VersionGroup(
|
2018-10-20 00:05:10 +00:00
|
|
|
id=int(info[0]),
|
|
|
|
name=info[1],
|
|
|
|
generation_id=int(info[2]),
|
|
|
|
order=int(info[3]),
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((VersionGroup,), "version_groups.csv", csv_record_to_objects)
|
2015-04-06 04:27:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield VersionGroupRegion(version_group_id=int(info[0]), region_id=int(info[1]))
|
|
|
|
|
|
|
|
build_generic(
|
|
|
|
(VersionGroupRegion,), "version_group_regions.csv", csv_record_to_objects
|
|
|
|
)
|
2015-04-06 04:27:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield Version(id=int(info[0]), version_group_id=int(info[1]), name=info[2])
|
|
|
|
|
|
|
|
build_generic((Version,), "versions.csv", csv_record_to_objects)
|
2015-04-06 04:27:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield VersionName(
|
2018-10-20 00:05:10 +00:00
|
|
|
version_id=int(info[0]), language_id=int(info[1]), name=info[2]
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2015-04-06 04:27:59 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
build_generic((VersionName,), "version_names.csv", csv_record_to_objects)
|
2015-04-07 12:14:31 +00:00
|
|
|
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2015-10-29 17:45:58 +00:00
|
|
|
##################
|
|
|
|
# DAMAGE CLASS #
|
|
|
|
##################
|
2015-04-09 04:45:23 +00:00
|
|
|
|
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
def _build_damage_classes():
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield MoveDamageClass(id=int(info[0]), name=info[1])
|
|
|
|
|
|
|
|
build_generic((MoveDamageClass,), "move_damage_classes.csv", csv_record_to_objects)
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield MoveDamageClassName(
|
2018-10-20 00:05:10 +00:00
|
|
|
move_damage_class_id=int(info[0]), language_id=int(info[1]), name=info[2]
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
|
|
|
yield MoveDamageClassDescription(
|
2018-10-20 00:05:10 +00:00
|
|
|
move_damage_class_id=int(info[0]),
|
|
|
|
language_id=int(info[1]),
|
|
|
|
description=info[3],
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
2018-09-06 20:00:41 +00:00
|
|
|
build_generic(
|
|
|
|
(MoveDamageClassName, MoveDamageClassDescription),
|
2018-10-20 00:05:10 +00:00
|
|
|
"move_damage_class_prose.csv",
|
|
|
|
csv_record_to_objects,
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2015-04-09 04:45:23 +00:00
|
|
|
|
|
|
|
|
2015-10-29 17:45:58 +00:00
|
|
|
###########
|
|
|
|
# STATS #
|
|
|
|
###########
|
2015-04-07 12:14:31 +00:00
|
|
|
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
def _build_stats():
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield Stat(
|
2018-10-20 00:05:10 +00:00
|
|
|
id=int(info[0]),
|
|
|
|
move_damage_class_id=int(info[1]) if info[1] != "" else None,
|
|
|
|
name=info[2],
|
|
|
|
is_battle_only=bool(int(info[3])),
|
|
|
|
game_index=int(info[4]) if info[4] else 0,
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((Stat,), "stats.csv", csv_record_to_objects)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield StatName(stat_id=int(info[0]), language_id=int(info[1]), name=info[2])
|
|
|
|
|
|
|
|
build_generic((StatName,), "stat_names.csv", csv_record_to_objects)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield PokeathlonStat(id=int(info[0]), name=info[1])
|
|
|
|
|
|
|
|
build_generic((PokeathlonStat,), "pokeathlon_stats.csv", csv_record_to_objects)
|
2015-04-07 12:14:31 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield PokeathlonStatName(
|
2018-10-20 00:05:10 +00:00
|
|
|
pokeathlon_stat_id=int(info[0]), language_id=int(info[1]), name=info[2]
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2015-04-07 12:14:31 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
build_generic(
|
|
|
|
(PokeathlonStatName,), "pokeathlon_stat_names.csv", csv_record_to_objects
|
|
|
|
)
|
2015-04-07 12:14:31 +00:00
|
|
|
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2015-11-08 21:26:02 +00:00
|
|
|
# ###############
|
|
|
|
# # ABILITIES #
|
|
|
|
# ###############
|
2015-04-06 04:27:59 +00:00
|
|
|
|
2015-11-08 21:26:02 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
def _build_abilities():
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield Ability(
|
2018-10-20 00:05:10 +00:00
|
|
|
id=int(info[0]),
|
|
|
|
name=info[1],
|
|
|
|
generation_id=int(info[2]),
|
|
|
|
is_main_series=bool(int(info[3])),
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((Ability,), "abilities.csv", csv_record_to_objects)
|
2015-11-08 21:26:02 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield AbilityName(
|
2018-10-20 00:05:10 +00:00
|
|
|
ability_id=int(info[0]), language_id=int(info[1]), name=info[2]
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((AbilityName,), "ability_names.csv", csv_record_to_objects)
|
2015-04-06 04:27:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield AbilityChange(
|
2018-10-20 00:05:10 +00:00
|
|
|
id=int(info[0]), ability_id=int(info[1]), version_group_id=int(info[2])
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((AbilityChange,), "ability_changelog.csv", csv_record_to_objects)
|
2018-09-06 20:00:41 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield AbilityEffectText(
|
2018-10-20 00:05:10 +00:00
|
|
|
ability_id=int(info[0]),
|
|
|
|
language_id=int(info[1]),
|
|
|
|
short_effect=scrub_str(info[2]),
|
|
|
|
effect=scrub_str(info[3]),
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((AbilityEffectText,), "ability_prose.csv", csv_record_to_objects)
|
2015-04-06 04:27:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield AbilityChangeEffectText(
|
2018-10-20 00:05:10 +00:00
|
|
|
ability_change_id=int(info[0]),
|
|
|
|
language_id=int(info[1]),
|
|
|
|
effect=scrub_str(info[2]),
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic(
|
|
|
|
(AbilityChangeEffectText,), "ability_changelog_prose.csv", csv_record_to_objects
|
|
|
|
)
|
2018-09-06 20:00:41 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield AbilityFlavorText(
|
2018-10-20 00:05:10 +00:00
|
|
|
ability_id=int(info[0]),
|
|
|
|
version_group_id=int(info[1]),
|
|
|
|
language_id=int(info[2]),
|
|
|
|
flavor_text=info[3],
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2015-04-06 04:27:59 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
build_generic(
|
|
|
|
(AbilityFlavorText,), "ability_flavor_text.csv", csv_record_to_objects
|
|
|
|
)
|
2015-04-06 04:27:59 +00:00
|
|
|
|
2015-04-07 12:14:31 +00:00
|
|
|
|
2015-10-29 17:45:58 +00:00
|
|
|
####################
|
|
|
|
# CHARACTERISTIC #
|
|
|
|
####################
|
2015-04-07 12:14:31 +00:00
|
|
|
|
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
def _build_characteristics():
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield Characteristic(
|
2018-10-20 00:05:10 +00:00
|
|
|
id=int(info[0]), stat_id=int(info[1]), gene_mod_5=int(info[2])
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((Characteristic,), "characteristics.csv", csv_record_to_objects)
|
2015-04-07 12:14:31 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield CharacteristicDescription(
|
2018-10-20 00:05:10 +00:00
|
|
|
characteristic_id=int(info[0]),
|
|
|
|
language_id=int(info[1]),
|
|
|
|
description=info[2],
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2015-04-07 12:14:31 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
build_generic(
|
|
|
|
(CharacteristicDescription,), "characteristic_text.csv", csv_record_to_objects
|
|
|
|
)
|
2015-04-07 12:14:31 +00:00
|
|
|
|
|
|
|
|
2015-10-29 17:45:58 +00:00
|
|
|
###############
|
|
|
|
# EGG GROUP #
|
|
|
|
###############
|
2015-04-07 12:14:31 +00:00
|
|
|
|
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
def _build_egg_groups():
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield EggGroup(id=int(info[0]), name=info[1])
|
|
|
|
|
|
|
|
build_generic((EggGroup,), "egg_groups.csv", csv_record_to_objects)
|
2015-04-07 12:14:31 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield EggGroupName(
|
2018-10-20 00:05:10 +00:00
|
|
|
egg_group_id=int(info[0]), language_id=int(info[1]), name=info[2]
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2015-04-07 12:14:31 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
build_generic((EggGroupName,), "egg_group_prose.csv", csv_record_to_objects)
|
2015-04-07 12:14:31 +00:00
|
|
|
|
|
|
|
|
2015-10-29 17:45:58 +00:00
|
|
|
#################
|
|
|
|
# GROWTH RATE #
|
|
|
|
#################
|
2015-04-07 12:14:31 +00:00
|
|
|
|
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
def _build_growth_rates():
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield GrowthRate(id=int(info[0]), name=info[1], formula=info[2])
|
|
|
|
|
|
|
|
build_generic((GrowthRate,), "growth_rates.csv", csv_record_to_objects)
|
2015-04-07 12:14:31 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield GrowthRateDescription(
|
2018-10-20 00:05:10 +00:00
|
|
|
growth_rate_id=int(info[0]), language_id=int(info[1]), description=info[2]
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2015-04-07 12:14:31 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
build_generic(
|
|
|
|
(GrowthRateDescription,), "growth_rate_prose.csv", csv_record_to_objects
|
|
|
|
)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2015-04-20 02:24:14 +00:00
|
|
|
|
2016-02-13 04:44:08 +00:00
|
|
|
# ###########
|
|
|
|
# # ITEMS #
|
|
|
|
# ###########
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
def _build_items():
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield ItemPocket(id=int(info[0]), name=info[1])
|
|
|
|
|
|
|
|
build_generic((ItemPocket,), "item_pockets.csv", csv_record_to_objects)
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield ItemPocketName(
|
2018-10-20 00:05:10 +00:00
|
|
|
item_pocket_id=int(info[0]), language_id=int(info[1]), name=info[2]
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((ItemPocketName,), "item_pocket_names.csv", csv_record_to_objects)
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield ItemFlingEffect(id=int(info[0]), name=info[1])
|
|
|
|
|
|
|
|
build_generic((ItemFlingEffect,), "item_fling_effects.csv", csv_record_to_objects)
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield ItemFlingEffectEffectText(
|
2018-10-20 00:05:10 +00:00
|
|
|
item_fling_effect_id=int(info[0]),
|
|
|
|
language_id=int(info[1]),
|
|
|
|
effect=scrub_str(info[2]),
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic(
|
|
|
|
(ItemFlingEffectEffectText,),
|
|
|
|
"item_fling_effect_prose.csv",
|
|
|
|
csv_record_to_objects,
|
|
|
|
)
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield ItemCategory(id=int(info[0]), item_pocket_id=int(info[1]), name=info[2])
|
|
|
|
|
|
|
|
build_generic((ItemCategory,), "item_categories.csv", csv_record_to_objects)
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield ItemCategoryName(
|
2018-10-20 00:05:10 +00:00
|
|
|
item_category_id=int(info[0]), language_id=int(info[1]), name=info[2]
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((ItemCategoryName,), "item_category_prose.csv", csv_record_to_objects)
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield Item(
|
2018-10-20 00:05:10 +00:00
|
|
|
id=int(info[0]),
|
|
|
|
name=info[1],
|
|
|
|
item_category_id=int(info[2]),
|
|
|
|
cost=int(info[3]),
|
|
|
|
fling_power=int(info[4]) if info[4] != "" else None,
|
|
|
|
item_fling_effect_id=int(info[5]) if info[5] != "" else None,
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((Item,), "items.csv", csv_record_to_objects)
|
2018-09-06 20:00:41 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
if re.search(r"^data-card", info[1]):
|
2018-10-20 00:05:10 +00:00
|
|
|
file_name = "data-card.png"
|
2018-09-06 20:00:41 +00:00
|
|
|
elif re.search(r"^tm[0-9]", info[1]):
|
2018-10-20 00:05:10 +00:00
|
|
|
file_name = "tm-normal.png"
|
2018-09-06 20:00:41 +00:00
|
|
|
elif re.search(r"^hm[0-9]", info[1]):
|
2018-10-20 00:05:10 +00:00
|
|
|
file_name = "hm-normal.png"
|
2018-09-06 20:00:41 +00:00
|
|
|
else:
|
2018-10-20 00:05:10 +00:00
|
|
|
file_name = "%s.png" % info[1]
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
item_sprites = "items/{0}"
|
|
|
|
sprites = {"default": file_path_or_none(item_sprites.format(file_name))}
|
2018-09-06 20:00:41 +00:00
|
|
|
yield ItemSprites(
|
2018-10-20 00:05:10 +00:00
|
|
|
id=int(info[0]), item_id=int(info[0]), sprites=json.dumps(sprites)
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((ItemSprites,), "items.csv", csv_record_to_objects)
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield ItemName(item_id=int(info[0]), language_id=int(info[1]), name=info[2])
|
|
|
|
|
|
|
|
build_generic((ItemName,), "item_names.csv", csv_record_to_objects)
|
2018-09-06 20:00:41 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield ItemEffectText(
|
2018-10-20 00:05:10 +00:00
|
|
|
item_id=int(info[0]),
|
|
|
|
language_id=int(info[1]),
|
|
|
|
short_effect=scrub_str(info[2]),
|
|
|
|
effect=scrub_str(info[3]),
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((ItemEffectText,), "item_prose.csv", csv_record_to_objects)
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield ItemGameIndex(
|
2018-10-20 00:05:10 +00:00
|
|
|
item_id=int(info[0]), generation_id=int(info[1]), game_index=int(info[2])
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((ItemGameIndex,), "item_game_indices.csv", csv_record_to_objects)
|
2018-09-06 20:00:41 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield ItemFlavorText(
|
2018-10-20 00:05:10 +00:00
|
|
|
item_id=int(info[0]),
|
|
|
|
version_group_id=int(info[1]),
|
|
|
|
language_id=int(info[2]),
|
|
|
|
flavor_text=info[3],
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((ItemFlavorText,), "item_flavor_text.csv", csv_record_to_objects)
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield ItemAttribute(id=int(info[0]), name=info[1])
|
|
|
|
|
|
|
|
build_generic((ItemAttribute,), "item_flags.csv", csv_record_to_objects)
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield ItemAttributeName(
|
2018-10-20 00:05:10 +00:00
|
|
|
item_attribute_id=int(info[0]), language_id=int(info[1]), name=info[2]
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
|
|
|
yield ItemAttributeDescription(
|
2018-10-20 00:05:10 +00:00
|
|
|
item_attribute_id=int(info[0]),
|
|
|
|
language_id=int(info[1]),
|
|
|
|
description=info[3],
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
2018-09-06 20:00:41 +00:00
|
|
|
build_generic(
|
|
|
|
(ItemAttributeName, ItemAttributeDescription),
|
2018-10-20 00:05:10 +00:00
|
|
|
"item_flag_prose.csv",
|
|
|
|
csv_record_to_objects,
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield ItemAttributeMap(item_id=int(info[0]), item_attribute_id=int(info[1]))
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
build_generic((ItemAttributeMap,), "item_flag_map.csv", csv_record_to_objects)
|
2015-04-09 04:45:23 +00:00
|
|
|
|
|
|
|
|
2018-09-06 20:00:41 +00:00
|
|
|
###########
|
|
|
|
# TYPES #
|
|
|
|
###########
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
def _build_types():
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield Type(
|
2018-10-20 00:05:10 +00:00
|
|
|
id=int(info[0]),
|
|
|
|
name=info[1],
|
|
|
|
generation_id=int(info[2]),
|
|
|
|
move_damage_class_id=int(info[3]) if info[3] != "" else None,
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((Type,), "types.csv", csv_record_to_objects)
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield TypeName(type_id=int(info[0]), language_id=int(info[1]), name=info[2])
|
|
|
|
|
|
|
|
build_generic((TypeName,), "type_names.csv", csv_record_to_objects)
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield TypeGameIndex(
|
2018-10-20 00:05:10 +00:00
|
|
|
type_id=int(info[0]), generation_id=int(info[1]), game_index=int(info[2])
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((TypeGameIndex,), "type_game_indices.csv", csv_record_to_objects)
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield TypeEfficacy(
|
2018-10-20 00:05:10 +00:00
|
|
|
damage_type_id=int(info[0]),
|
|
|
|
target_type_id=int(info[1]),
|
|
|
|
damage_factor=int(info[2]),
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
build_generic((TypeEfficacy,), "type_efficacy.csv", csv_record_to_objects)
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2019-12-01 12:39:30 +00:00
|
|
|
def csv_record_to_objects(info):
|
|
|
|
yield TypeEfficacyPast(
|
|
|
|
damage_type_id=int(info[0]),
|
|
|
|
target_type_id=int(info[1]),
|
|
|
|
damage_factor=int(info[2]),
|
|
|
|
generation_id=int(info[3]),
|
|
|
|
)
|
|
|
|
|
|
|
|
build_generic((TypeEfficacyPast,), "type_efficacy_past.csv", csv_record_to_objects)
|
|
|
|
|
|
|
|
|
2018-09-06 20:00:41 +00:00
|
|
|
#############
|
|
|
|
# CONTEST #
|
|
|
|
#############
|
2015-04-09 04:45:23 +00:00
|
|
|
|
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
def _build_contests():
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield ContestType(id=int(info[0]), name=info[1])
|
|
|
|
|
|
|
|
build_generic((ContestType,), "contest_types.csv", csv_record_to_objects)
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield ContestTypeName(
|
2018-10-20 00:05:10 +00:00
|
|
|
contest_type_id=int(info[0]),
|
|
|
|
language_id=int(info[1]),
|
|
|
|
name=info[2],
|
|
|
|
flavor=info[3],
|
|
|
|
color=info[4],
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((ContestTypeName,), "contest_type_names.csv", csv_record_to_objects)
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield ContestEffect(id=int(info[0]), appeal=int(info[1]), jam=int(info[2]))
|
|
|
|
|
|
|
|
build_generic((ContestEffect,), "contest_effects.csv", csv_record_to_objects)
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield ContestEffectEffectText(
|
2018-10-20 00:05:10 +00:00
|
|
|
contest_effect_id=int(info[0]), language_id=int(info[1]), effect=info[3]
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
|
|
|
yield ContestEffectFlavorText(
|
2018-10-20 00:05:10 +00:00
|
|
|
contest_effect_id=int(info[0]),
|
|
|
|
language_id=int(info[1]),
|
|
|
|
flavor_text=info[2],
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
2018-09-06 20:00:41 +00:00
|
|
|
build_generic(
|
|
|
|
(ContestEffectEffectText, ContestEffectFlavorText),
|
2018-10-20 00:05:10 +00:00
|
|
|
"contest_effect_prose.csv",
|
|
|
|
csv_record_to_objects,
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield SuperContestEffect(id=int(info[0]), appeal=int(info[1]))
|
|
|
|
|
|
|
|
build_generic(
|
|
|
|
(SuperContestEffect,), "super_contest_effects.csv", csv_record_to_objects
|
|
|
|
)
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield SuperContestEffectFlavorText(
|
2018-10-20 00:05:10 +00:00
|
|
|
super_contest_effect_id=int(info[0]),
|
|
|
|
language_id=int(info[1]),
|
|
|
|
flavor_text=info[2],
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
build_generic(
|
2018-10-20 00:05:10 +00:00
|
|
|
(SuperContestEffectFlavorText,),
|
|
|
|
"super_contest_effect_prose.csv",
|
|
|
|
csv_record_to_objects,
|
2018-09-08 22:42:24 +00:00
|
|
|
)
|
2015-04-09 04:45:23 +00:00
|
|
|
|
|
|
|
|
2018-09-06 20:00:41 +00:00
|
|
|
###########
|
|
|
|
# MOVES #
|
|
|
|
###########
|
2015-04-09 04:45:23 +00:00
|
|
|
|
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
def _build_moves():
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield MoveEffect(id=int(info[0]))
|
|
|
|
|
|
|
|
build_generic((MoveEffect,), "move_effects.csv", csv_record_to_objects)
|
2018-09-06 20:00:41 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield MoveEffectEffectText(
|
2018-10-20 00:05:10 +00:00
|
|
|
move_effect_id=int(info[0]),
|
|
|
|
language_id=int(info[1]),
|
|
|
|
short_effect=scrub_str(info[2]),
|
|
|
|
effect=scrub_str(info[3]),
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic(
|
|
|
|
(MoveEffectEffectText,), "move_effect_prose.csv", csv_record_to_objects
|
|
|
|
)
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield MoveEffectChange(
|
2018-10-20 00:05:10 +00:00
|
|
|
id=int(info[0]), move_effect_id=int(info[1]), version_group_id=int(info[2])
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic(
|
|
|
|
(MoveEffectChange,), "move_effect_changelog.csv", csv_record_to_objects
|
|
|
|
)
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield MoveEffectChangeEffectText(
|
2018-10-20 00:05:10 +00:00
|
|
|
move_effect_change_id=int(info[0]),
|
|
|
|
language_id=int(info[1]),
|
|
|
|
effect=scrub_str(info[2]),
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
build_generic(
|
2018-10-20 00:05:10 +00:00
|
|
|
(MoveEffectChangeEffectText,),
|
|
|
|
"move_effect_changelog_prose.csv",
|
|
|
|
csv_record_to_objects,
|
2018-09-08 22:42:24 +00:00
|
|
|
)
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield MoveLearnMethod(id=int(info[0]), name=info[1])
|
|
|
|
|
|
|
|
build_generic((MoveLearnMethod,), "pokemon_move_methods.csv", csv_record_to_objects)
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield VersionGroupMoveLearnMethod(
|
2018-10-20 00:05:10 +00:00
|
|
|
version_group_id=int(info[0]), move_learn_method_id=int(info[1])
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
2018-09-06 20:00:41 +00:00
|
|
|
build_generic(
|
2018-09-08 22:42:24 +00:00
|
|
|
(VersionGroupMoveLearnMethod,),
|
2018-10-20 00:05:10 +00:00
|
|
|
"version_group_pokemon_move_methods.csv",
|
|
|
|
csv_record_to_objects,
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield MoveLearnMethodName(
|
2018-10-20 00:05:10 +00:00
|
|
|
move_learn_method_id=int(info[0]), language_id=int(info[1]), name=info[2]
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
|
|
|
yield MoveLearnMethodDescription(
|
2018-10-20 00:05:10 +00:00
|
|
|
move_learn_method_id=int(info[0]),
|
|
|
|
language_id=int(info[1]),
|
|
|
|
description=info[3],
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
2018-09-06 20:00:41 +00:00
|
|
|
build_generic(
|
|
|
|
(MoveLearnMethodName, MoveLearnMethodDescription),
|
2018-10-20 00:05:10 +00:00
|
|
|
"pokemon_move_method_prose.csv",
|
|
|
|
csv_record_to_objects,
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield MoveTarget(id=int(info[0]), name=info[1])
|
|
|
|
|
|
|
|
build_generic((MoveTarget,), "move_targets.csv", csv_record_to_objects)
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield MoveTargetName(
|
2018-10-20 00:05:10 +00:00
|
|
|
move_target_id=int(info[0]), language_id=int(info[1]), name=info[2]
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
|
|
|
yield MoveTargetDescription(
|
2018-10-20 00:05:10 +00:00
|
|
|
move_target_id=int(info[0]), language_id=int(info[1]), description=info[3]
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
build_generic(
|
2018-10-20 00:05:10 +00:00
|
|
|
(MoveTargetName, MoveTargetDescription),
|
|
|
|
"move_target_prose.csv",
|
|
|
|
csv_record_to_objects,
|
2018-09-08 22:42:24 +00:00
|
|
|
)
|
2015-04-09 04:45:23 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield Move(
|
2018-10-20 00:05:10 +00:00
|
|
|
id=int(info[0]),
|
|
|
|
name=info[1],
|
|
|
|
generation_id=int(info[2]),
|
|
|
|
type_id=int(info[3]),
|
|
|
|
power=int(info[4]) if info[4] != "" else None,
|
|
|
|
pp=int(info[5]) if info[5] != "" else None,
|
|
|
|
accuracy=int(info[6]) if info[6] != "" else None,
|
|
|
|
priority=int(info[7]) if info[7] != "" else None,
|
2020-09-02 17:57:00 +00:00
|
|
|
move_target_id=int(info[8]) if info[8] != "" else None,
|
|
|
|
move_damage_class_id=int(info[9]) if info[9] != "" else None,
|
|
|
|
move_effect_id=int(info[10]) if info[10] != "" else None,
|
2018-10-20 00:05:10 +00:00
|
|
|
move_effect_chance=int(info[11]) if info[11] != "" else None,
|
|
|
|
contest_type_id=int(info[12]) if info[12] != "" else None,
|
|
|
|
contest_effect_id=int(info[13]) if info[13] != "" else None,
|
|
|
|
super_contest_effect_id=int(info[14]) if info[14] != "" else None,
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((Move,), "moves.csv", csv_record_to_objects)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield MoveName(move_id=int(info[0]), language_id=int(info[1]), name=info[2])
|
|
|
|
|
|
|
|
build_generic((MoveName,), "move_names.csv", csv_record_to_objects)
|
2018-09-06 20:00:41 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield MoveFlavorText(
|
2018-10-20 00:05:10 +00:00
|
|
|
move_id=int(info[0]),
|
|
|
|
version_group_id=int(info[1]),
|
|
|
|
language_id=int(info[2]),
|
|
|
|
flavor_text=info[3],
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((MoveFlavorText,), "move_flavor_text.csv", csv_record_to_objects)
|
2018-09-06 20:00:41 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
_move_effect = None
|
|
|
|
try:
|
2018-10-20 00:05:10 +00:00
|
|
|
_move_effect = (
|
|
|
|
MoveEffect.objects.get(pk=int(info[6])) if info[6] != "" else None
|
|
|
|
)
|
2018-09-06 20:00:41 +00:00
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
yield MoveChange(
|
2018-10-20 00:05:10 +00:00
|
|
|
move_id=int(info[0]),
|
|
|
|
version_group_id=int(info[1]),
|
|
|
|
type_id=int(info[2]) if info[2] != "" else None,
|
|
|
|
power=int(info[3]) if info[3] != "" else None,
|
|
|
|
pp=int(info[4]) if info[4] != "" else None,
|
|
|
|
accuracy=int(info[5]) if info[5] != "" else None,
|
|
|
|
move_effect_id=_move_effect.pk if _move_effect else None,
|
|
|
|
move_effect_chance=int(info[7]) if info[7] != "" else None,
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((MoveChange,), "move_changelog.csv", csv_record_to_objects)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield MoveBattleStyle(id=int(info[0]), name=info[1])
|
|
|
|
|
|
|
|
build_generic((MoveBattleStyle,), "move_battle_styles.csv", csv_record_to_objects)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield MoveBattleStyleName(
|
2018-10-20 00:05:10 +00:00
|
|
|
move_battle_style_id=int(info[0]), language_id=int(info[1]), name=info[2]
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic(
|
|
|
|
(MoveBattleStyleName,), "move_battle_style_prose.csv", csv_record_to_objects
|
|
|
|
)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield MoveAttribute(id=int(info[0]), name=info[1])
|
|
|
|
|
|
|
|
build_generic((MoveAttribute,), "move_flags.csv", csv_record_to_objects)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield MoveAttributeMap(move_id=int(info[0]), move_attribute_id=int(info[1]))
|
|
|
|
|
|
|
|
build_generic((MoveAttributeMap,), "move_flag_map.csv", csv_record_to_objects)
|
2015-12-05 11:13:46 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield MoveAttributeName(
|
2018-10-20 00:05:10 +00:00
|
|
|
move_attribute_id=int(info[0]), language_id=int(info[1]), name=info[2]
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
|
|
|
yield MoveAttributeDescription(
|
2018-10-20 00:05:10 +00:00
|
|
|
move_attribute_id=int(info[0]),
|
|
|
|
language_id=int(info[1]),
|
|
|
|
description=scrub_str(info[3]),
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
2018-09-06 20:00:41 +00:00
|
|
|
build_generic(
|
2018-10-20 00:05:10 +00:00
|
|
|
(MoveAttributeName, MoveAttributeDescription),
|
|
|
|
"move_flag_prose.csv",
|
|
|
|
csv_record_to_objects,
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield MoveMetaAilment(id=int(info[0]), name=info[1])
|
|
|
|
|
|
|
|
build_generic((MoveMetaAilment,), "move_meta_ailments.csv", csv_record_to_objects)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield MoveMetaAilmentName(
|
2018-10-20 00:05:10 +00:00
|
|
|
move_meta_ailment_id=int(info[0]), language_id=int(info[1]), name=info[2]
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic(
|
|
|
|
(MoveMetaAilmentName,), "move_meta_ailment_names.csv", csv_record_to_objects
|
|
|
|
)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield MoveMetaCategory(id=int(info[0]), name=info[1])
|
|
|
|
|
|
|
|
build_generic(
|
|
|
|
(MoveMetaCategory,), "move_meta_categories.csv", csv_record_to_objects
|
|
|
|
)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield MoveMetaCategoryDescription(
|
2018-10-20 00:05:10 +00:00
|
|
|
move_meta_category_id=int(info[0]),
|
|
|
|
language_id=int(info[1]),
|
|
|
|
description=info[2],
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
build_generic(
|
2018-10-20 00:05:10 +00:00
|
|
|
(MoveMetaCategoryDescription,),
|
|
|
|
"move_meta_category_prose.csv",
|
|
|
|
csv_record_to_objects,
|
2018-09-08 22:42:24 +00:00
|
|
|
)
|
2018-09-06 20:00:41 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield MoveMeta(
|
2018-10-20 00:05:10 +00:00
|
|
|
move_id=int(info[0]),
|
|
|
|
move_meta_category_id=int(info[1]),
|
|
|
|
move_meta_ailment_id=int(info[2]),
|
|
|
|
min_hits=int(info[3]) if info[3] != "" else None,
|
|
|
|
max_hits=int(info[4]) if info[4] != "" else None,
|
|
|
|
min_turns=int(info[5]) if info[5] != "" else None,
|
|
|
|
max_turns=int(info[6]) if info[6] != "" else None,
|
|
|
|
drain=int(info[7]) if info[7] != "" else None,
|
|
|
|
healing=int(info[8]) if info[8] != "" else None,
|
|
|
|
crit_rate=int(info[9]) if info[9] != "" else None,
|
|
|
|
ailment_chance=int(info[10]) if info[10] != "" else None,
|
|
|
|
flinch_chance=int(info[11]) if info[11] != "" else None,
|
|
|
|
stat_chance=int(info[12]) if info[12] != "" else None,
|
|
|
|
)
|
|
|
|
|
|
|
|
build_generic((MoveMeta,), "move_meta.csv", csv_record_to_objects)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-06 20:00:41 +00:00
|
|
|
yield MoveMetaStatChange(
|
2018-10-20 00:05:10 +00:00
|
|
|
move_id=int(info[0]), stat_id=int(info[1]), change=int(info[2])
|
2018-09-06 20:00:41 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic(
|
|
|
|
(MoveMetaStatChange,), "move_meta_stat_changes.csv", csv_record_to_objects
|
|
|
|
)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield ContestCombo(first_move_id=int(info[0]), second_move_id=int(info[1]))
|
|
|
|
|
|
|
|
build_generic((ContestCombo,), "contest_combos.csv", csv_record_to_objects)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield SuperContestCombo(first_move_id=int(info[0]), second_move_id=int(info[1]))
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
build_generic(
|
|
|
|
(SuperContestCombo,), "super_contest_combos.csv", csv_record_to_objects
|
|
|
|
)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
|
|
|
|
2015-10-29 17:45:58 +00:00
|
|
|
#############
|
|
|
|
# BERRIES #
|
|
|
|
#############
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
def _build_berries():
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield BerryFirmness(id=int(info[0]), name=info[1])
|
|
|
|
|
|
|
|
build_generic((BerryFirmness,), "berry_firmness.csv", csv_record_to_objects)
|
2016-02-13 04:44:08 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield BerryFirmnessName(
|
2018-10-20 00:05:10 +00:00
|
|
|
berry_firmness_id=int(info[0]), language_id=int(info[1]), name=info[2]
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic(
|
|
|
|
(BerryFirmnessName,), "berry_firmness_names.csv", csv_record_to_objects
|
|
|
|
)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
item = Item.objects.get(pk=int(info[1]))
|
2018-09-07 19:06:34 +00:00
|
|
|
yield Berry(
|
2018-10-20 00:05:10 +00:00
|
|
|
id=int(info[0]),
|
|
|
|
item_id=int(info[1]),
|
|
|
|
name=item.name[: item.name.index("-")],
|
|
|
|
berry_firmness_id=int(info[2]),
|
|
|
|
natural_gift_power=int(info[3]),
|
|
|
|
natural_gift_type_id=int(info[4]),
|
|
|
|
size=int(info[5]),
|
|
|
|
max_harvest=int(info[6]),
|
|
|
|
growth_time=int(info[7]),
|
|
|
|
soil_dryness=int(info[8]),
|
|
|
|
smoothness=int(info[9]),
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((Berry,), "berries.csv", csv_record_to_objects)
|
2018-09-07 19:06:34 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
# Get the english name for this contest type
|
2018-10-20 00:05:10 +00:00
|
|
|
contest_type_name = ContestTypeName.objects.get(
|
|
|
|
contest_type_id=int(info[0]), language_id=9
|
|
|
|
)
|
2018-09-07 19:06:34 +00:00
|
|
|
yield BerryFlavor(
|
2018-10-20 00:05:10 +00:00
|
|
|
id=int(info[0]),
|
|
|
|
name=contest_type_name.flavor.lower(),
|
|
|
|
contest_type=ContestType.objects.get(pk=int(info[0])),
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
# This is not an error
|
2018-10-20 00:05:10 +00:00
|
|
|
build_generic((BerryFlavor,), "contest_types.csv", csv_record_to_objects)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield BerryFlavorName(
|
2018-10-20 00:05:10 +00:00
|
|
|
berry_flavor_id=int(info[0]), language_id=int(info[1]), name=info[3]
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
# This is not an error
|
2018-10-20 00:05:10 +00:00
|
|
|
build_generic((BerryFlavorName,), "contest_type_names.csv", csv_record_to_objects)
|
2015-12-05 11:13:46 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield BerryFlavorMap(
|
2018-10-20 00:05:10 +00:00
|
|
|
berry_id=int(info[0]), berry_flavor_id=int(info[1]), potency=int(info[2])
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2016-02-13 04:44:08 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
# This is not an error
|
|
|
|
build_generic((BerryFlavorMap,), "berry_flavors.csv", csv_record_to_objects)
|
2016-02-13 04:44:08 +00:00
|
|
|
|
|
|
|
|
2015-10-29 17:45:58 +00:00
|
|
|
############
|
|
|
|
# NATURE #
|
|
|
|
############
|
2016-02-13 04:44:08 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
def _build_natures():
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
decreased_stat = None
|
|
|
|
increased_stat = None
|
|
|
|
hates_flavor = None
|
|
|
|
likes_flavor = None
|
2015-12-05 11:13:46 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
if info[2] != info[3]:
|
|
|
|
decreased_stat = Stat.objects.get(pk=int(info[2]))
|
|
|
|
increased_stat = Stat.objects.get(pk=int(info[3]))
|
2016-03-05 11:40:41 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
if info[4] != info[5]:
|
|
|
|
hates_flavor = BerryFlavor.objects.get(pk=int(info[4]))
|
|
|
|
likes_flavor = BerryFlavor.objects.get(pk=int(info[5]))
|
2015-12-05 11:13:46 +00:00
|
|
|
|
2018-09-07 19:06:34 +00:00
|
|
|
yield Nature(
|
2018-10-20 00:05:10 +00:00
|
|
|
id=int(info[0]),
|
|
|
|
name=info[1],
|
|
|
|
decreased_stat=decreased_stat,
|
|
|
|
increased_stat=increased_stat,
|
|
|
|
hates_flavor=hates_flavor,
|
|
|
|
likes_flavor=likes_flavor,
|
|
|
|
game_index=info[6],
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((Nature,), "natures.csv", csv_record_to_objects)
|
2015-12-05 11:13:46 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield NatureName(nature_id=int(info[0]), language_id=int(info[1]), name=info[2])
|
|
|
|
|
|
|
|
build_generic((NatureName,), "nature_names.csv", csv_record_to_objects)
|
2015-12-05 11:13:46 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield NaturePokeathlonStat(
|
2018-10-20 00:05:10 +00:00
|
|
|
nature_id=(info[0]), pokeathlon_stat_id=(info[1]), max_change=info[2]
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic(
|
|
|
|
(NaturePokeathlonStat,), "nature_pokeathlon_stats.csv", csv_record_to_objects
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield NatureBattleStylePreference(
|
2018-10-20 00:05:10 +00:00
|
|
|
nature_id=int(info[0]),
|
|
|
|
move_battle_style_id=int(info[1]),
|
|
|
|
low_hp_preference=info[2],
|
|
|
|
high_hp_preference=info[3],
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
build_generic(
|
2018-10-20 00:05:10 +00:00
|
|
|
(NatureBattleStylePreference,),
|
|
|
|
"nature_battle_style_preferences.csv",
|
|
|
|
csv_record_to_objects,
|
2018-09-08 22:42:24 +00:00
|
|
|
)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
|
|
|
|
2015-10-29 17:45:58 +00:00
|
|
|
###########
|
|
|
|
# GENDER #
|
|
|
|
###########
|
2015-04-21 03:31:59 +00:00
|
|
|
|
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
def _build_genders():
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield Gender(id=int(info[0]), name=info[1])
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
build_generic((Gender,), "genders.csv", csv_record_to_objects)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
|
|
|
|
2015-10-29 17:45:58 +00:00
|
|
|
################
|
|
|
|
# EXPERIENCE #
|
|
|
|
################
|
2015-04-21 03:31:59 +00:00
|
|
|
|
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
def _build_experiences():
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield Experience(
|
2018-10-20 00:05:10 +00:00
|
|
|
growth_rate_id=int(info[0]), level=int(info[1]), experience=int(info[2])
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
build_generic((Experience,), "experience.csv", csv_record_to_objects)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
|
|
|
|
2015-10-29 17:45:58 +00:00
|
|
|
##############
|
|
|
|
# MACHINES #
|
|
|
|
##############
|
2015-04-21 03:31:59 +00:00
|
|
|
|
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
def _build_machines():
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield Machine(
|
2018-10-20 00:05:10 +00:00
|
|
|
machine_number=int(info[0]),
|
|
|
|
version_group_id=int(info[1]),
|
|
|
|
item_id=int(info[2]),
|
|
|
|
move_id=int(info[3]),
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
build_generic((Machine,), "machines.csv", csv_record_to_objects)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
|
|
|
|
2015-10-29 17:45:58 +00:00
|
|
|
###############
|
|
|
|
# EVOLUTION #
|
|
|
|
###############
|
2015-04-21 03:31:59 +00:00
|
|
|
|
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
def _build_evolutions():
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield EvolutionChain(
|
2018-10-20 00:05:10 +00:00
|
|
|
id=int(info[0]),
|
|
|
|
baby_trigger_item_id=int(info[1]) if info[1] != "" else None,
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((EvolutionChain,), "evolution_chains.csv", csv_record_to_objects)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield EvolutionTrigger(id=int(info[0]), name=info[1])
|
|
|
|
|
|
|
|
build_generic((EvolutionTrigger,), "evolution_triggers.csv", csv_record_to_objects)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield EvolutionTriggerName(
|
2018-10-20 00:05:10 +00:00
|
|
|
evolution_trigger_id=int(info[0]), language_id=int(info[1]), name=info[2]
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
build_generic(
|
|
|
|
(EvolutionTriggerName,), "evolution_trigger_prose.csv", csv_record_to_objects
|
|
|
|
)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
|
|
|
|
2016-02-16 06:47:05 +00:00
|
|
|
#############
|
|
|
|
# POKEDEX #
|
|
|
|
#############
|
2015-04-21 03:31:59 +00:00
|
|
|
|
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
def _build_pokedexes():
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield Pokedex(
|
2018-10-20 00:05:10 +00:00
|
|
|
id=int(info[0]),
|
|
|
|
region_id=int(info[1]) if info[1] != "" else None,
|
|
|
|
name=info[2],
|
|
|
|
is_main_series=bool(int(info[3])),
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((Pokedex,), "pokedexes.csv", csv_record_to_objects)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield PokedexName(
|
2018-10-20 00:05:10 +00:00
|
|
|
pokedex_id=int(info[0]), language_id=int(info[1]), name=info[2]
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
|
|
|
yield PokedexDescription(
|
2018-10-20 00:05:10 +00:00
|
|
|
pokedex_id=int(info[0]), language_id=int(info[1]), description=info[3]
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic(
|
|
|
|
(PokedexName, PokedexDescription), "pokedex_prose.csv", csv_record_to_objects
|
|
|
|
)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield PokedexVersionGroup(
|
2018-10-20 00:05:10 +00:00
|
|
|
pokedex_id=int(info[0]), version_group_id=int(info[1])
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
build_generic(
|
|
|
|
(PokedexVersionGroup,), "pokedex_version_groups.csv", csv_record_to_objects
|
|
|
|
)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
|
|
|
|
2016-02-16 06:47:05 +00:00
|
|
|
##############
|
|
|
|
# LOCATION #
|
|
|
|
##############
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2015-12-05 11:13:46 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
def _build_locations():
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield Location(
|
2018-10-20 00:05:10 +00:00
|
|
|
id=int(info[0]),
|
|
|
|
region_id=int(info[1]) if info[1] != "" else None,
|
|
|
|
name=info[2],
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((Location,), "locations.csv", csv_record_to_objects)
|
2016-02-13 04:44:08 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield LocationName(
|
2018-10-20 00:05:10 +00:00
|
|
|
location_id=int(info[0]), language_id=int(info[1]), name=info[2]
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((LocationName,), "location_names.csv", csv_record_to_objects)
|
2016-02-13 04:44:08 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield LocationGameIndex(
|
2018-10-20 00:05:10 +00:00
|
|
|
location_id=int(info[0]),
|
|
|
|
generation_id=int(info[1]),
|
|
|
|
game_index=int(info[2]),
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic(
|
|
|
|
(LocationGameIndex,), "location_game_indices.csv", csv_record_to_objects
|
|
|
|
)
|
2016-02-13 04:44:08 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
location = Location.objects.get(pk=int(info[1]))
|
2018-09-07 19:06:34 +00:00
|
|
|
yield LocationArea(
|
2018-10-20 00:05:10 +00:00
|
|
|
id=int(info[0]),
|
|
|
|
location_id=int(info[1]),
|
|
|
|
game_index=int(info[2]),
|
|
|
|
name="{}-{}".format(location.name, info[3])
|
|
|
|
if info[3]
|
|
|
|
else "{}-{}".format(location.name, "area"),
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((LocationArea,), "location_areas.csv", csv_record_to_objects)
|
2016-02-13 04:44:08 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield LocationAreaName(
|
2018-10-20 00:05:10 +00:00
|
|
|
location_area_id=int(info[0]), language_id=int(info[1]), name=info[2]
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
build_generic((LocationAreaName,), "location_area_prose.csv", csv_record_to_objects)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
|
2015-10-29 17:45:58 +00:00
|
|
|
#############
|
|
|
|
# POKEMON #
|
|
|
|
#############
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
def _build_pokemons():
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield PokemonColor(id=int(info[0]), name=info[1])
|
|
|
|
|
|
|
|
build_generic((PokemonColor,), "pokemon_colors.csv", csv_record_to_objects)
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield PokemonColorName(
|
2018-10-20 00:05:10 +00:00
|
|
|
pokemon_color_id=int(info[0]), language_id=int(info[1]), name=info[2]
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((PokemonColorName,), "pokemon_color_names.csv", csv_record_to_objects)
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield PokemonShape(id=int(info[0]), name=info[1])
|
|
|
|
|
|
|
|
build_generic((PokemonShape,), "pokemon_shapes.csv", csv_record_to_objects)
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield PokemonShapeName(
|
2018-10-20 00:05:10 +00:00
|
|
|
pokemon_shape_id=int(info[0]),
|
|
|
|
language_id=int(info[1]),
|
|
|
|
name=info[2],
|
|
|
|
awesome_name=info[3],
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((PokemonShapeName,), "pokemon_shape_prose.csv", csv_record_to_objects)
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield PokemonHabitat(id=int(info[0]), name=info[1])
|
|
|
|
|
|
|
|
build_generic((PokemonHabitat,), "pokemon_habitats.csv", csv_record_to_objects)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield PokemonSpecies(
|
2018-10-20 00:05:10 +00:00
|
|
|
id=int(info[0]),
|
|
|
|
name=info[1],
|
2020-08-01 10:00:09 +00:00
|
|
|
generation_id=int(info[2]) if info[2] != "" else None,
|
2018-10-20 00:05:10 +00:00
|
|
|
evolves_from_species=None,
|
2020-08-01 10:00:09 +00:00
|
|
|
evolution_chain_id=int(info[4]) if info[4] != "" else None,
|
|
|
|
pokemon_color_id=int(info[5]) if info[5] != "" else None,
|
2020-08-01 10:24:38 +00:00
|
|
|
pokemon_shape_id=int(info[6]) if info[6] != "" else None,
|
2018-10-20 00:05:10 +00:00
|
|
|
pokemon_habitat_id=int(info[7]) if info[7] != "" else None,
|
2020-08-01 10:00:09 +00:00
|
|
|
gender_rate=int(info[8]) if info[8] != "" else None,
|
|
|
|
capture_rate=int(info[9]) if info[9] != "" else None,
|
|
|
|
base_happiness=int(info[10]) if info[10] != "" else None,
|
|
|
|
is_baby=bool(int(info[11])) if info[11] != "" else None,
|
|
|
|
hatch_counter=int(info[12]) if info[12] != "" else None,
|
2020-08-01 10:57:57 +00:00
|
|
|
has_gender_differences=bool(int(info[13])) if info[13] != "" else False,
|
2020-08-01 10:00:09 +00:00
|
|
|
growth_rate_id=int(info[14]) if info[14] != "" else None,
|
|
|
|
forms_switchable=bool(int(info[15])) if info[15] != "" else None,
|
2020-08-15 19:32:56 +00:00
|
|
|
is_legendary=bool(int(info[16])) if info[16] != "" else None,
|
|
|
|
is_mythical=bool(int(info[17])) if info[17] != "" else None,
|
2020-08-10 18:05:39 +00:00
|
|
|
order=int(info[18]) if info[18] != "" else None,
|
2018-10-20 00:05:10 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
build_generic((PokemonSpecies,), "pokemon_species.csv", csv_record_to_objects)
|
2018-09-07 19:06:34 +00:00
|
|
|
|
|
|
|
# PokemonSpecies.evolves_from_species can't be set until all the species are created
|
2018-10-20 00:05:10 +00:00
|
|
|
data = load_data("pokemon_species.csv")
|
2016-02-16 06:47:05 +00:00
|
|
|
for index, info in enumerate(data):
|
|
|
|
if index > 0:
|
2018-10-20 00:05:10 +00:00
|
|
|
evolves = (
|
|
|
|
PokemonSpecies.objects.get(pk=int(info[3])) if info[3] != "" else None
|
|
|
|
)
|
2016-02-16 06:47:05 +00:00
|
|
|
if evolves:
|
2018-10-20 00:05:10 +00:00
|
|
|
species = PokemonSpecies.objects.get(pk=int(info[0]))
|
2016-02-16 06:47:05 +00:00
|
|
|
species.evolves_from_species = evolves
|
|
|
|
species.save()
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield PokemonSpeciesName(
|
2018-10-20 00:05:10 +00:00
|
|
|
pokemon_species_id=int(info[0]),
|
|
|
|
language_id=int(info[1]),
|
|
|
|
name=info[2],
|
|
|
|
genus=info[3],
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic(
|
|
|
|
(PokemonSpeciesName,), "pokemon_species_names.csv", csv_record_to_objects
|
|
|
|
)
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield PokemonSpeciesDescription(
|
2018-10-20 00:05:10 +00:00
|
|
|
pokemon_species_id=int(info[0]),
|
|
|
|
language_id=int(info[1]),
|
|
|
|
description=scrub_str(info[2]),
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic(
|
|
|
|
(PokemonSpeciesDescription,), "pokemon_species_prose.csv", csv_record_to_objects
|
|
|
|
)
|
2018-09-06 20:00:41 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield PokemonSpeciesFlavorText(
|
2018-10-20 00:05:10 +00:00
|
|
|
pokemon_species_id=int(info[0]),
|
|
|
|
version_id=int(info[1]),
|
|
|
|
language_id=int(info[2]),
|
|
|
|
flavor_text=info[3],
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
build_generic(
|
2018-10-20 00:05:10 +00:00
|
|
|
(PokemonSpeciesFlavorText,),
|
|
|
|
"pokemon_species_flavor_text.csv",
|
|
|
|
csv_record_to_objects,
|
2018-09-08 22:42:24 +00:00
|
|
|
)
|
2016-02-16 06:47:05 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield Pokemon(
|
2018-10-20 00:05:10 +00:00
|
|
|
id=int(info[0]),
|
|
|
|
name=info[1],
|
2020-07-25 19:18:10 +00:00
|
|
|
pokemon_species_id=int(info[2]) if info[2] != "" else None,
|
|
|
|
height=int(info[3]) if info[3] != "" else None,
|
|
|
|
weight=int(info[4]) if info[4] != "" else None,
|
|
|
|
base_experience=int(info[5]) if info[5] != "" else None,
|
2020-08-01 10:00:09 +00:00
|
|
|
order=int(info[6]) if info[6] != "" else -1,
|
2020-07-25 19:18:10 +00:00
|
|
|
is_default=bool(int(info[7])) if info[7] != "" else None,
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((Pokemon,), "pokemon.csv", csv_record_to_objects)
|
2016-02-16 06:47:05 +00:00
|
|
|
|
2021-02-05 21:57:00 +00:00
|
|
|
def try_image_names(path, info, extension):
|
|
|
|
# poke_sprites = "pokemon/{0}"
|
|
|
|
pokemon_id = info[0]
|
|
|
|
identifier = info[1]
|
|
|
|
species_id = info[2]
|
|
|
|
if "-" in identifier:
|
2021-02-08 18:56:35 +00:00
|
|
|
form_file_name = "%s.%s" % (
|
2021-02-05 21:57:00 +00:00
|
|
|
species_id + "-" + identifier.split("-", 1)[1],
|
|
|
|
extension,
|
|
|
|
)
|
2021-02-08 18:56:35 +00:00
|
|
|
id_file_name = "%s.%s" % (pokemon_id, extension)
|
2021-02-05 21:57:00 +00:00
|
|
|
file_name = (
|
2021-02-08 18:56:35 +00:00
|
|
|
id_file_name
|
|
|
|
if file_path_or_none(path + id_file_name)
|
|
|
|
else form_file_name
|
2021-01-29 21:18:05 +00:00
|
|
|
)
|
|
|
|
else:
|
2021-02-05 21:57:00 +00:00
|
|
|
file_name = "%s.%s" % (info[0], extension)
|
|
|
|
return file_path_or_none(path + file_name)
|
|
|
|
|
|
|
|
def csv_record_to_objects(info):
|
|
|
|
poke_sprites = "pokemon/"
|
|
|
|
dream_world = "other/dream-world/"
|
2021-10-04 18:53:15 +00:00
|
|
|
home = "other/home/"
|
2021-02-05 21:57:00 +00:00
|
|
|
official_art = "other/official-artwork/"
|
|
|
|
gen_i = "versions/generation-i/"
|
|
|
|
gen_ii = "versions/generation-ii/"
|
|
|
|
gen_iii = "versions/generation-iii/"
|
|
|
|
gen_iv = "versions/generation-iv/"
|
|
|
|
gen_v = "versions/generation-v/"
|
|
|
|
gen_vi = "versions/generation-vi/"
|
|
|
|
gen_vii = "versions/generation-vii/"
|
|
|
|
gen_viii = "versions/generation-viii/"
|
2018-09-07 19:06:34 +00:00
|
|
|
sprites = {
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_default": try_image_names(poke_sprites, info, "png"),
|
|
|
|
"front_female": try_image_names(poke_sprites + "female/", info, "png"),
|
|
|
|
"front_shiny": try_image_names(poke_sprites + "shiny/", info, "png"),
|
|
|
|
"front_shiny_female": try_image_names(
|
|
|
|
poke_sprites + "shiny/female/", info, "png"
|
2018-10-20 00:05:10 +00:00
|
|
|
),
|
2021-02-05 21:57:00 +00:00
|
|
|
"back_default": try_image_names(poke_sprites + "back/", info, "png"),
|
|
|
|
"back_female": try_image_names(poke_sprites + "back/female/", info, "png"),
|
|
|
|
"back_shiny": try_image_names(poke_sprites + "back/shiny/", info, "png"),
|
|
|
|
"back_shiny_female": try_image_names(
|
|
|
|
poke_sprites + "back/shiny/female/", info, "png"
|
2018-10-20 00:05:10 +00:00
|
|
|
),
|
2020-07-10 06:58:11 +00:00
|
|
|
"other": {
|
|
|
|
"dream_world": {
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_default": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + dream_world, info, "svg"
|
2020-07-10 09:59:05 +00:00
|
|
|
),
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_female": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + dream_world + "female/", info, "svg"
|
2020-07-10 09:59:05 +00:00
|
|
|
),
|
2020-08-04 10:17:48 +00:00
|
|
|
},
|
2021-10-04 18:53:15 +00:00
|
|
|
"home": {
|
2021-10-25 17:27:41 +00:00
|
|
|
"front_default": try_image_names(poke_sprites + home, info, "png"),
|
2021-10-04 18:53:15 +00:00
|
|
|
"front_female": try_image_names(
|
|
|
|
poke_sprites + home + "female/", info, "png"
|
|
|
|
),
|
|
|
|
"front_shiny": try_image_names(
|
|
|
|
poke_sprites + home + "shiny/", info, "png"
|
|
|
|
),
|
|
|
|
"front_shiny_female": try_image_names(
|
|
|
|
poke_sprites + home + "shiny/female/", info, "png"
|
|
|
|
),
|
|
|
|
},
|
2020-08-04 10:17:48 +00:00
|
|
|
"official-artwork": {
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_default": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + official_art, info, "png"
|
2020-08-04 10:17:48 +00:00
|
|
|
)
|
|
|
|
},
|
2020-07-10 09:59:05 +00:00
|
|
|
},
|
2020-07-28 00:22:15 +00:00
|
|
|
"versions": {
|
|
|
|
"generation-i": {
|
|
|
|
"red-blue": {
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_default": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_i + "red-blue/", info, "png"
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"front_gray": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_i + "red-blue/gray/", info, "png"
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"back_default": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_i + "red-blue/back/", info, "png"
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"back_gray": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_i + "red-blue/back/gray/", info, "png"
|
2020-07-28 09:48:01 +00:00
|
|
|
),
|
2021-11-16 01:57:00 +00:00
|
|
|
"front_transparent": try_image_names(
|
|
|
|
poke_sprites + gen_i + "red-blue/transparent/", info, "png"
|
|
|
|
),
|
|
|
|
"back_transparent": try_image_names(
|
|
|
|
poke_sprites + gen_i + "red-blue/transparent/back/",
|
|
|
|
info,
|
|
|
|
"png",
|
|
|
|
),
|
2020-07-28 00:22:15 +00:00
|
|
|
},
|
|
|
|
"yellow": {
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_default": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_i + "yellow/", info, "png"
|
2020-07-28 00:22:15 +00:00
|
|
|
),
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_gray": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_i + "yellow/gray/", info, "png"
|
2020-07-28 09:48:01 +00:00
|
|
|
),
|
2021-02-05 21:57:00 +00:00
|
|
|
"back_default": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_i + "yellow/back/", info, "png"
|
2020-07-28 00:22:15 +00:00
|
|
|
),
|
2021-02-05 21:57:00 +00:00
|
|
|
"back_gray": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_i + "yellow/back/gray/", info, "png"
|
2020-07-28 09:48:01 +00:00
|
|
|
),
|
2021-11-16 01:57:00 +00:00
|
|
|
"front_transparent": try_image_names(
|
|
|
|
poke_sprites + gen_i + "yellow/transparent/", info, "png"
|
|
|
|
),
|
|
|
|
"back_transparent": try_image_names(
|
|
|
|
poke_sprites + gen_i + "yellow/transparent/back/",
|
|
|
|
info,
|
|
|
|
"png",
|
|
|
|
),
|
2020-07-28 00:22:15 +00:00
|
|
|
},
|
2020-08-04 10:17:48 +00:00
|
|
|
},
|
|
|
|
"generation-ii": {
|
|
|
|
"crystal": {
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_default": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_ii + "crystal/", info, "png"
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"front_shiny": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_ii + "crystal/shiny/", info, "png"
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"back_default": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_ii + "crystal/back/", info, "png"
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"back_shiny": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_ii + "crystal/back/shiny/", info, "png"
|
2020-08-04 10:17:48 +00:00
|
|
|
),
|
2021-11-16 01:57:00 +00:00
|
|
|
"front_transparent": try_image_names(
|
|
|
|
poke_sprites + gen_ii + "crystal/transparent/", info, "png"
|
|
|
|
),
|
|
|
|
"front_shiny_transparent": try_image_names(
|
|
|
|
poke_sprites + gen_ii + "crystal/transparent/shiny/",
|
|
|
|
info,
|
|
|
|
"png",
|
|
|
|
),
|
|
|
|
"back_transparent": try_image_names(
|
|
|
|
poke_sprites + gen_ii + "crystal/transparent/back/",
|
|
|
|
info,
|
|
|
|
"png",
|
|
|
|
),
|
|
|
|
"back_shiny_transparent": try_image_names(
|
|
|
|
poke_sprites + gen_ii + "crystal/transparent/back/shiny/",
|
|
|
|
info,
|
|
|
|
"png",
|
|
|
|
),
|
2020-08-04 10:17:48 +00:00
|
|
|
},
|
|
|
|
"gold": {
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_default": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_ii + "gold/", info, "png"
|
2020-08-04 10:17:48 +00:00
|
|
|
),
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_shiny": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_ii + "gold/shiny/", info, "png"
|
2020-08-04 10:17:48 +00:00
|
|
|
),
|
2021-02-05 21:57:00 +00:00
|
|
|
"back_default": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_ii + "gold/back/", info, "png"
|
2020-08-04 10:17:48 +00:00
|
|
|
),
|
2021-02-05 21:57:00 +00:00
|
|
|
"back_shiny": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_ii + "gold/back/shiny/", info, "png"
|
2020-08-04 10:17:48 +00:00
|
|
|
),
|
2021-11-16 01:57:00 +00:00
|
|
|
"front_transparent": try_image_names(
|
|
|
|
poke_sprites + gen_ii + "gold/transparent/", info, "png"
|
|
|
|
),
|
2020-08-04 10:17:48 +00:00
|
|
|
},
|
|
|
|
"silver": {
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_default": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_ii + "silver/", info, "png"
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"front_shiny": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_ii + "silver/shiny/", info, "png"
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"back_default": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_ii + "silver/back/", info, "png"
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"back_shiny": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_ii + "silver/back/shiny/", info, "png"
|
2020-08-04 10:17:48 +00:00
|
|
|
),
|
2021-11-16 01:57:00 +00:00
|
|
|
"front_transparent": try_image_names(
|
|
|
|
poke_sprites + gen_ii + "silver/transparent/", info, "png"
|
|
|
|
),
|
2020-08-04 10:17:48 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"generation-iii": {
|
|
|
|
"emerald": {
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_default": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_iii + "emerald/", info, "png"
|
2020-08-04 10:17:48 +00:00
|
|
|
),
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_shiny": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_iii + "emerald/shiny/", info, "png"
|
2020-08-04 10:17:48 +00:00
|
|
|
),
|
|
|
|
},
|
|
|
|
"firered-leafgreen": {
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_default": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_iii + "firered-leafgreen/", info, "png"
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"front_shiny": try_image_names(
|
|
|
|
poke_sprites + gen_iii + "firered-leafgreen/shiny/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"back_default": try_image_names(
|
|
|
|
poke_sprites + gen_iii + "firered-leafgreen/back/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"back_shiny": try_image_names(
|
|
|
|
poke_sprites + gen_iii + "firered-leafgreen/back/shiny/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2020-08-04 10:17:48 +00:00
|
|
|
),
|
|
|
|
},
|
|
|
|
"ruby-sapphire": {
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_default": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_iii + "ruby-sapphire/", info, "png"
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"front_shiny": try_image_names(
|
|
|
|
poke_sprites + gen_iii + "ruby-sapphire/shiny/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"back_default": try_image_names(
|
|
|
|
poke_sprites + gen_iii + "ruby-sapphire/back/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"back_shiny": try_image_names(
|
|
|
|
poke_sprites + gen_iii + "ruby-sapphire/back/shiny/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2020-08-04 10:17:48 +00:00
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"generation-iv": {
|
|
|
|
"diamond-pearl": {
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_default": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_iv + "diamond-pearl/", info, "png"
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"front_female": try_image_names(
|
|
|
|
poke_sprites + gen_iv + "diamond-pearl/female/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"front_shiny": try_image_names(
|
|
|
|
poke_sprites + gen_iv + "diamond-pearl/shiny/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"front_shiny_female": try_image_names(
|
|
|
|
poke_sprites + gen_iv + "diamond-pearl/shiny/female/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"back_default": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_iv + "diamond-pearl/back/", info, "png"
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"back_female": try_image_names(
|
|
|
|
poke_sprites + gen_iv + "diamond-pearl/back/female/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"back_shiny": try_image_names(
|
|
|
|
poke_sprites + gen_iv + "diamond-pearl/back/shiny/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"back_shiny_female": try_image_names(
|
|
|
|
poke_sprites + gen_iv + "diamond-pearl/back/shiny/female/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2020-08-04 10:17:48 +00:00
|
|
|
),
|
|
|
|
},
|
|
|
|
"heartgold-soulsilver": {
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_default": try_image_names(
|
|
|
|
poke_sprites + gen_iv + "heartgold-soulsilver/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"front_female": try_image_names(
|
|
|
|
poke_sprites + gen_iv + "heartgold-soulsilver/female/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"front_shiny": try_image_names(
|
|
|
|
poke_sprites + gen_iv + "heartgold-soulsilver/shiny/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"front_shiny_female": try_image_names(
|
|
|
|
poke_sprites
|
|
|
|
+ gen_iv
|
|
|
|
+ "heartgold-soulsilver/shiny/female/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"back_default": try_image_names(
|
|
|
|
poke_sprites + gen_iv + "heartgold-soulsilver/back/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"back_female": try_image_names(
|
|
|
|
poke_sprites + gen_iv + "heartgold-soulsilver/back/female/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"back_shiny": try_image_names(
|
|
|
|
poke_sprites + gen_iv + "heartgold-soulsilver/back/shiny/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"back_shiny_female": try_image_names(
|
|
|
|
poke_sprites
|
|
|
|
+ gen_iv
|
|
|
|
+ "heartgold-soulsilver/back/shiny/female/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2020-08-04 10:17:48 +00:00
|
|
|
),
|
|
|
|
},
|
|
|
|
"platinum": {
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_default": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_iv + "platinum/", info, "png"
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"front_female": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_iv + "platinum/female/", info, "png"
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"front_shiny": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_iv + "platinum/shiny/", info, "png"
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"front_shiny_female": try_image_names(
|
|
|
|
poke_sprites + gen_iv + "platinum/shiny/female/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"back_default": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_iv + "platinum/back/", info, "png"
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"back_female": try_image_names(
|
|
|
|
poke_sprites + gen_iv + "platinum/back/female/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"back_shiny": try_image_names(
|
|
|
|
poke_sprites + gen_iv + "platinum/back/shiny/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"back_shiny_female": try_image_names(
|
|
|
|
poke_sprites + gen_iv + "platinum/back/shiny/female/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2020-08-04 10:17:48 +00:00
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"generation-v": {
|
|
|
|
"black-white": {
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_default": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_v + "black-white/", info, "png"
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"front_female": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_v + "black-white/female/", info, "png"
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"front_shiny": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_v + "black-white/shiny/", info, "png"
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"front_shiny_female": try_image_names(
|
|
|
|
poke_sprites + gen_v + "black-white/shiny/female/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"back_default": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_v + "black-white/back/", info, "png"
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"back_female": try_image_names(
|
|
|
|
poke_sprites + gen_v + "black-white/back/female/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"back_shiny": try_image_names(
|
|
|
|
poke_sprites + gen_v + "black-white/back/shiny/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"back_shiny_female": try_image_names(
|
|
|
|
poke_sprites + gen_v + "black-white/back/shiny/female/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2020-08-04 10:17:48 +00:00
|
|
|
),
|
2020-08-15 00:29:19 +00:00
|
|
|
"animated": {
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_default": try_image_names(
|
|
|
|
poke_sprites + gen_v + "black-white/animated/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"gif",
|
2020-08-15 00:29:19 +00:00
|
|
|
),
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_female": try_image_names(
|
|
|
|
poke_sprites + gen_v + "black-white/animated/female/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"gif",
|
2020-08-15 00:29:19 +00:00
|
|
|
),
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_shiny": try_image_names(
|
|
|
|
poke_sprites + gen_v + "black-white/animated/shiny/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"gif",
|
2020-08-15 00:29:19 +00:00
|
|
|
),
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_shiny_female": try_image_names(
|
|
|
|
poke_sprites
|
|
|
|
+ gen_v
|
2021-02-05 21:59:44 +00:00
|
|
|
+ "black-white/animated/shiny/female/",
|
|
|
|
info,
|
|
|
|
"gif",
|
2020-08-15 00:29:19 +00:00
|
|
|
),
|
2021-02-05 21:57:00 +00:00
|
|
|
"back_default": try_image_names(
|
|
|
|
poke_sprites + gen_v + "black-white/animated/back/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"gif",
|
2020-08-15 00:29:19 +00:00
|
|
|
),
|
2021-02-05 21:57:00 +00:00
|
|
|
"back_female": try_image_names(
|
|
|
|
poke_sprites
|
|
|
|
+ gen_v
|
2021-02-05 21:59:44 +00:00
|
|
|
+ "black-white/animated/back/female/",
|
|
|
|
info,
|
|
|
|
"gif",
|
2020-08-15 00:29:19 +00:00
|
|
|
),
|
2021-02-05 21:57:00 +00:00
|
|
|
"back_shiny": try_image_names(
|
|
|
|
poke_sprites
|
|
|
|
+ gen_v
|
2021-02-05 21:59:44 +00:00
|
|
|
+ "black-white/animated/back/shiny/",
|
|
|
|
info,
|
|
|
|
"gif",
|
2020-08-15 00:29:19 +00:00
|
|
|
),
|
2021-02-05 21:57:00 +00:00
|
|
|
"back_shiny_female": try_image_names(
|
|
|
|
poke_sprites
|
|
|
|
+ gen_v
|
2021-02-05 21:59:44 +00:00
|
|
|
+ "black-white/animated/back/shiny/female/",
|
|
|
|
info,
|
|
|
|
"gif",
|
2020-08-15 00:29:19 +00:00
|
|
|
),
|
|
|
|
},
|
2020-08-04 10:17:48 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
"generation-vi": {
|
|
|
|
"omegaruby-alphasapphire": {
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_default": try_image_names(
|
|
|
|
poke_sprites + gen_vi + "omegaruby-alphasapphire/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"front_female": try_image_names(
|
|
|
|
poke_sprites + gen_vi + "omegaruby-alphasapphire/female/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"front_shiny": try_image_names(
|
|
|
|
poke_sprites + gen_vi + "omegaruby-alphasapphire/shiny/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"front_shiny_female": try_image_names(
|
|
|
|
poke_sprites
|
|
|
|
+ gen_vi
|
|
|
|
+ "omegaruby-alphasapphire/shiny/female/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2020-08-04 10:17:48 +00:00
|
|
|
),
|
|
|
|
},
|
|
|
|
"x-y": {
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_default": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_vi + "x-y/", info, "png"
|
2020-08-04 10:17:48 +00:00
|
|
|
),
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_female": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_vi + "x-y/female/", info, "png"
|
2020-08-04 10:17:48 +00:00
|
|
|
),
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_shiny": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_vi + "x-y/shiny/", info, "png"
|
2020-08-04 10:17:48 +00:00
|
|
|
),
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_shiny_female": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_vi + "x-y/shiny/female/", info, "png"
|
2020-08-04 10:17:48 +00:00
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"generation-vii": {
|
|
|
|
"ultra-sun-ultra-moon": {
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_default": try_image_names(
|
|
|
|
poke_sprites + gen_vii + "ultra-sun-ultra-moon/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"front_female": try_image_names(
|
|
|
|
poke_sprites + gen_vii + "ultra-sun-ultra-moon/female/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"front_shiny": try_image_names(
|
|
|
|
poke_sprites + gen_vii + "ultra-sun-ultra-moon/shiny/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2021-02-05 21:57:00 +00:00
|
|
|
),
|
|
|
|
"front_shiny_female": try_image_names(
|
|
|
|
poke_sprites
|
|
|
|
+ gen_vii
|
|
|
|
+ "ultra-sun-ultra-moon/shiny/female/",
|
2021-02-05 21:59:44 +00:00
|
|
|
info,
|
|
|
|
"png",
|
2020-08-04 10:17:48 +00:00
|
|
|
),
|
2020-08-24 03:05:22 +00:00
|
|
|
},
|
|
|
|
"icons": {
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_default": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_vii + "icons/", info, "png"
|
2020-08-24 03:05:22 +00:00
|
|
|
),
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_female": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_vii + "icons/female/", info, "png"
|
2020-08-24 03:05:22 +00:00
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"generation-viii": {
|
|
|
|
"icons": {
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_default": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_viii + "icons/", info, "png"
|
2020-08-24 03:05:22 +00:00
|
|
|
),
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_female": try_image_names(
|
2021-02-05 21:59:44 +00:00
|
|
|
poke_sprites + gen_viii + "icons/female/", info, "png"
|
2020-08-24 03:05:22 +00:00
|
|
|
),
|
2021-02-05 21:57:00 +00:00
|
|
|
},
|
2020-08-04 10:17:48 +00:00
|
|
|
},
|
2020-07-28 00:22:15 +00:00
|
|
|
},
|
2018-09-07 19:06:34 +00:00
|
|
|
}
|
|
|
|
yield PokemonSprites(
|
2018-10-20 00:05:10 +00:00
|
|
|
id=int(info[0]),
|
|
|
|
pokemon=Pokemon.objects.get(pk=int(info[0])),
|
|
|
|
sprites=json.dumps(sprites),
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((PokemonSprites,), "pokemon.csv", csv_record_to_objects)
|
2016-02-16 06:47:05 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield PokemonAbility(
|
2018-10-20 00:05:10 +00:00
|
|
|
pokemon_id=int(info[0]),
|
|
|
|
ability_id=int(info[1]),
|
|
|
|
is_hidden=bool(int(info[2])),
|
|
|
|
slot=int(info[3]),
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((PokemonAbility,), "pokemon_abilities.csv", csv_record_to_objects)
|
2016-02-16 06:47:05 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield PokemonDexNumber(
|
2018-10-20 00:05:10 +00:00
|
|
|
pokemon_species_id=int(info[0]),
|
|
|
|
pokedex_id=int(info[1]),
|
|
|
|
pokedex_number=int(info[2]),
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((PokemonDexNumber,), "pokemon_dex_numbers.csv", csv_record_to_objects)
|
2016-02-16 06:47:05 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield PokemonEggGroup(
|
2018-10-20 00:05:10 +00:00
|
|
|
pokemon_species_id=int(info[0]), egg_group_id=int(info[1])
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((PokemonEggGroup,), "pokemon_egg_groups.csv", csv_record_to_objects)
|
2016-02-10 04:11:37 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield PokemonEvolution(
|
2018-10-20 00:05:10 +00:00
|
|
|
id=int(info[0]),
|
|
|
|
evolved_species_id=int(info[1]),
|
|
|
|
evolution_trigger_id=int(info[2]),
|
|
|
|
evolution_item_id=int(info[3]) if info[3] != "" else None,
|
|
|
|
min_level=int(info[4]) if info[4] != "" else None,
|
|
|
|
gender_id=int(info[5]) if info[5] != "" else None,
|
|
|
|
location_id=int(info[6]) if info[6] != "" else None,
|
|
|
|
held_item_id=int(info[7]) if info[7] != "" else None,
|
|
|
|
time_of_day=info[8],
|
|
|
|
known_move_id=int(info[9]) if info[9] != "" else None,
|
|
|
|
known_move_type_id=int(info[10]) if info[10] != "" else None,
|
|
|
|
min_happiness=int(info[11]) if info[11] != "" else None,
|
|
|
|
min_beauty=int(info[12]) if info[12] != "" else None,
|
|
|
|
min_affection=int(info[13]) if info[13] != "" else None,
|
|
|
|
relative_physical_stats=int(info[14]) if info[14] != "" else None,
|
|
|
|
party_species_id=int(info[15]) if info[15] != "" else None,
|
|
|
|
party_type_id=int(info[16]) if info[16] != "" else None,
|
|
|
|
trade_species_id=int(info[17]) if info[17] != "" else None,
|
|
|
|
needs_overworld_rain=bool(int(info[18])),
|
|
|
|
turn_upside_down=bool(int(info[19])),
|
|
|
|
)
|
|
|
|
|
|
|
|
build_generic((PokemonEvolution,), "pokemon_evolution.csv", csv_record_to_objects)
|
2018-09-07 19:06:34 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield PokemonForm(
|
2018-10-20 00:05:10 +00:00
|
|
|
id=int(info[0]),
|
|
|
|
name=info[1],
|
|
|
|
form_name=info[2],
|
|
|
|
pokemon_id=int(info[3]),
|
|
|
|
version_group_id=int(info[4]),
|
|
|
|
is_default=bool(int(info[5])),
|
|
|
|
is_battle_only=bool(int(info[6])),
|
|
|
|
is_mega=bool(int(info[7])),
|
|
|
|
form_order=int(info[8]),
|
|
|
|
order=int(info[9]),
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((PokemonForm,), "pokemon_forms.csv", csv_record_to_objects)
|
2018-09-07 19:06:34 +00:00
|
|
|
|
2021-02-05 21:57:00 +00:00
|
|
|
def try_image_names(path, info, extension):
|
|
|
|
form_identifier = info[2]
|
|
|
|
pokemon_id = info[3]
|
|
|
|
pokemon = Pokemon.objects.get(pk=int(pokemon_id))
|
|
|
|
species_id = getattr(pokemon, "pokemon_species_id")
|
2021-02-08 18:54:08 +00:00
|
|
|
is_default = int(info[5])
|
2021-02-05 21:57:00 +00:00
|
|
|
if form_identifier:
|
2021-02-08 18:56:35 +00:00
|
|
|
form_file_name = "%s-%s.%s" % (species_id, form_identifier, extension)
|
|
|
|
id_file_name = "%s.%s" % (pokemon_id, extension)
|
2021-01-29 21:18:05 +00:00
|
|
|
file_name = (
|
2021-02-08 18:56:35 +00:00
|
|
|
id_file_name
|
|
|
|
if file_path_or_none(path + id_file_name)
|
|
|
|
else form_file_name
|
2021-01-29 21:18:05 +00:00
|
|
|
)
|
2021-02-08 18:56:35 +00:00
|
|
|
if id_file_name and form_file_name and (not is_default):
|
|
|
|
file_name = form_file_name
|
2018-09-07 19:06:34 +00:00
|
|
|
else:
|
2021-02-05 21:57:00 +00:00
|
|
|
file_name = "%s.%s" % (species_id, extension)
|
|
|
|
return file_path_or_none(path + file_name)
|
|
|
|
|
|
|
|
def csv_record_to_objects(info):
|
|
|
|
poke_sprites = "pokemon/"
|
2018-09-07 19:06:34 +00:00
|
|
|
sprites = {
|
2021-02-05 21:59:44 +00:00
|
|
|
"front_default": try_image_names(poke_sprites, info, "png"),
|
|
|
|
"front_shiny": try_image_names(poke_sprites + "shiny/", info, "png"),
|
|
|
|
"back_default": try_image_names(poke_sprites + "back/", info, "png"),
|
|
|
|
"back_shiny": try_image_names(poke_sprites + "back/shiny/", info, "png"),
|
2021-02-05 21:57:00 +00:00
|
|
|
"front_female": try_image_names(poke_sprites + "female/", info, "png"),
|
|
|
|
"front_shiny_female": try_image_names(
|
|
|
|
poke_sprites + "shiny/female/", info, "png"
|
|
|
|
),
|
|
|
|
"back_female": try_image_names(poke_sprites + "back/female/", info, "png"),
|
|
|
|
"back_shiny_female": try_image_names(
|
|
|
|
poke_sprites + "back/shiny/female/", info, "png"
|
2018-10-20 00:05:10 +00:00
|
|
|
),
|
2018-09-07 19:06:34 +00:00
|
|
|
}
|
|
|
|
yield PokemonFormSprites(
|
2018-10-20 00:05:10 +00:00
|
|
|
id=int(info[0]), pokemon_form_id=int(info[0]), sprites=json.dumps(sprites)
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((PokemonFormSprites,), "pokemon_forms.csv", csv_record_to_objects)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield PokemonFormName(
|
2018-10-20 00:05:10 +00:00
|
|
|
pokemon_form=PokemonForm.objects.get(pk=int(info[0])),
|
|
|
|
language=Language.objects.get(pk=int(info[1])),
|
|
|
|
name=info[2],
|
|
|
|
pokemon_name=info[3],
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((PokemonFormName,), "pokemon_form_names.csv", csv_record_to_objects)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield PokemonFormGeneration(
|
2018-10-20 00:05:10 +00:00
|
|
|
pokemon_form_id=int(info[0]),
|
|
|
|
generation_id=int(info[1]),
|
|
|
|
game_index=int(info[2]),
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic(
|
|
|
|
(PokemonFormGeneration,), "pokemon_form_generations.csv", csv_record_to_objects
|
|
|
|
)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2020-04-25 13:10:50 +00:00
|
|
|
def csv_record_to_objects(info):
|
|
|
|
yield PokemonFormType(
|
|
|
|
pokemon_form_id=int(info[0]), type_id=int(info[1]), slot=int(info[2])
|
|
|
|
)
|
|
|
|
|
|
|
|
build_generic((PokemonFormType,), "pokemon_form_types.csv", csv_record_to_objects)
|
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield PokemonGameIndex(
|
2018-10-20 00:05:10 +00:00
|
|
|
pokemon_id=int(info[0]), version_id=int(info[1]), game_index=int(info[2])
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic(
|
|
|
|
(PokemonGameIndex,), "pokemon_game_indices.csv", csv_record_to_objects
|
|
|
|
)
|
2018-09-06 20:00:41 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield PokemonHabitatName(
|
2018-10-20 00:05:10 +00:00
|
|
|
pokemon_habitat_id=int(info[0]), language_id=int(info[1]), name=info[2]
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic(
|
|
|
|
(PokemonHabitatName,), "pokemon_habitat_names.csv", csv_record_to_objects
|
|
|
|
)
|
2018-09-06 20:00:41 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield PokemonItem(
|
2018-10-20 00:05:10 +00:00
|
|
|
pokemon_id=int(info[0]),
|
|
|
|
version_id=int(info[1]),
|
|
|
|
item_id=int(info[2]),
|
|
|
|
rarity=int(info[3]),
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((PokemonItem,), "pokemon_items.csv", csv_record_to_objects)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield PokemonMove(
|
2018-10-20 00:05:10 +00:00
|
|
|
pokemon_id=int(info[0]),
|
|
|
|
version_group_id=int(info[1]),
|
|
|
|
move_id=int(info[2]),
|
|
|
|
move_learn_method_id=int(info[3]),
|
|
|
|
level=int(info[4]),
|
|
|
|
order=int(info[5]) if info[5] != "" else None,
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((PokemonMove,), "pokemon_moves.csv", csv_record_to_objects)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield PokemonStat(
|
2018-10-20 00:05:10 +00:00
|
|
|
pokemon_id=int(info[0]),
|
|
|
|
stat_id=int(info[1]),
|
|
|
|
base_stat=int(info[2]),
|
|
|
|
effort=int(info[3]),
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((PokemonStat,), "pokemon_stats.csv", csv_record_to_objects)
|
2018-09-06 20:00:41 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield PokemonType(
|
2018-10-20 00:05:10 +00:00
|
|
|
pokemon_id=int(info[0]), type_id=int(info[1]), slot=int(info[2])
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
build_generic((PokemonType,), "pokemon_types.csv", csv_record_to_objects)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2019-11-30 20:49:55 +00:00
|
|
|
def csv_record_to_objects(info):
|
|
|
|
yield PokemonTypePast(
|
|
|
|
pokemon_id=int(info[0]),
|
|
|
|
generation_id=int(info[1]),
|
|
|
|
type_id=int(info[2]),
|
2021-02-06 21:52:36 +00:00
|
|
|
slot=int(info[3]),
|
2019-11-30 20:49:55 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
build_generic((PokemonTypePast,), "pokemon_types_past.csv", csv_record_to_objects)
|
|
|
|
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2015-10-29 17:45:58 +00:00
|
|
|
###############
|
|
|
|
# ENCOUNTER #
|
|
|
|
###############
|
2015-04-21 03:31:59 +00:00
|
|
|
|
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
def _build_encounters():
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield EncounterMethod(id=int(info[0]), name=info[1], order=int(info[2]))
|
|
|
|
|
|
|
|
build_generic((EncounterMethod,), "encounter_methods.csv", csv_record_to_objects)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield LocationAreaEncounterRate(
|
2018-10-20 00:05:10 +00:00
|
|
|
location_area_id=int(info[0]),
|
|
|
|
encounter_method_id=int(info[1]),
|
|
|
|
version_id=int(info[2]),
|
|
|
|
rate=int(info[3]),
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
build_generic(
|
2018-10-20 00:05:10 +00:00
|
|
|
(LocationAreaEncounterRate,),
|
|
|
|
"location_area_encounter_rates.csv",
|
|
|
|
csv_record_to_objects,
|
2018-09-08 22:42:24 +00:00
|
|
|
)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield EncounterMethodName(
|
2018-10-20 00:05:10 +00:00
|
|
|
encounter_method_id=int(info[0]), language_id=int(info[1]), name=info[2]
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic(
|
|
|
|
(EncounterMethodName,), "encounter_method_prose.csv", csv_record_to_objects
|
|
|
|
)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield EncounterCondition(id=int(info[0]), name=info[1])
|
|
|
|
|
|
|
|
build_generic(
|
|
|
|
(EncounterCondition,), "encounter_conditions.csv", csv_record_to_objects
|
|
|
|
)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield EncounterConditionName(
|
2018-10-20 00:05:10 +00:00
|
|
|
encounter_condition_id=int(info[0]), language_id=int(info[1]), name=info[2]
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic(
|
|
|
|
(EncounterConditionName,),
|
|
|
|
"encounter_condition_prose.csv",
|
|
|
|
csv_record_to_objects,
|
|
|
|
)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield EncounterSlot(
|
2018-10-20 00:05:10 +00:00
|
|
|
id=int(info[0]),
|
|
|
|
version_group_id=int(info[1]),
|
|
|
|
encounter_method_id=int(info[2]),
|
|
|
|
slot=int(info[3]) if info[3] != "" else None,
|
|
|
|
rarity=int(info[4]),
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((EncounterSlot,), "encounter_slots.csv", csv_record_to_objects)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield Encounter(
|
2018-10-20 00:05:10 +00:00
|
|
|
id=int(info[0]),
|
|
|
|
version_id=int(info[1]),
|
|
|
|
location_area_id=int(info[2]),
|
|
|
|
encounter_slot_id=int(info[3]),
|
|
|
|
pokemon_id=int(info[4]),
|
|
|
|
min_level=int(info[5]),
|
|
|
|
max_level=int(info[6]),
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((Encounter,), "encounters.csv", csv_record_to_objects)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield EncounterConditionValue(
|
2018-10-20 00:05:10 +00:00
|
|
|
id=int(info[0]),
|
|
|
|
encounter_condition_id=int(info[1]),
|
|
|
|
name=info[2],
|
|
|
|
is_default=bool(int(info[3])),
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
build_generic(
|
2018-10-20 00:05:10 +00:00
|
|
|
(EncounterConditionValue,),
|
|
|
|
"encounter_condition_values.csv",
|
|
|
|
csv_record_to_objects,
|
2018-09-08 22:42:24 +00:00
|
|
|
)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield EncounterConditionValueName(
|
2018-10-20 00:05:10 +00:00
|
|
|
encounter_condition_value_id=int(info[0]),
|
|
|
|
language_id=int(info[1]),
|
|
|
|
name=info[2],
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
build_generic(
|
2018-10-20 00:05:10 +00:00
|
|
|
(EncounterConditionValueName,),
|
|
|
|
"encounter_condition_value_prose.csv",
|
|
|
|
csv_record_to_objects,
|
2018-09-08 22:42:24 +00:00
|
|
|
)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield EncounterConditionValueMap(
|
2018-10-20 00:05:10 +00:00
|
|
|
encounter_id=int(info[0]), encounter_condition_value_id=int(info[1])
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
build_generic(
|
2018-10-20 00:05:10 +00:00
|
|
|
(EncounterConditionValueMap,),
|
|
|
|
"encounter_condition_value_map.csv",
|
|
|
|
csv_record_to_objects,
|
2018-09-08 22:42:24 +00:00
|
|
|
)
|
2015-04-21 03:31:59 +00:00
|
|
|
|
|
|
|
|
2015-10-29 17:45:58 +00:00
|
|
|
##############
|
|
|
|
# PAL PARK #
|
|
|
|
##############
|
|
|
|
|
2015-12-05 11:13:46 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
def _build_pal_parks():
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-10-20 00:05:10 +00:00
|
|
|
yield PalParkArea(id=int(info[0]), name=info[1])
|
|
|
|
|
|
|
|
build_generic((PalParkArea,), "pal_park_areas.csv", csv_record_to_objects)
|
2015-12-05 11:13:46 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield PalParkAreaName(
|
2018-10-20 00:05:10 +00:00
|
|
|
pal_park_area_id=int(info[0]), language_id=int(info[1]), name=info[2]
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((PalParkAreaName,), "pal_park_area_names.csv", csv_record_to_objects)
|
2015-12-05 11:13:46 +00:00
|
|
|
|
2018-09-08 22:42:24 +00:00
|
|
|
def csv_record_to_objects(info):
|
2018-09-07 19:06:34 +00:00
|
|
|
yield PalPark(
|
2018-10-20 00:05:10 +00:00
|
|
|
pokemon_species_id=int(info[0]),
|
|
|
|
pal_park_area_id=int(info[1]),
|
|
|
|
base_score=int(info[2]),
|
|
|
|
rate=int(info[3]),
|
2018-09-07 19:06:34 +00:00
|
|
|
)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
build_generic((PalPark,), "pal_park.csv", csv_record_to_objects)
|
2015-12-05 11:13:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
def build_all():
|
2018-09-07 19:06:34 +00:00
|
|
|
_build_languages()
|
|
|
|
_build_regions()
|
|
|
|
_build_generations()
|
|
|
|
_build_versions()
|
|
|
|
_build_damage_classes()
|
|
|
|
_build_stats()
|
|
|
|
_build_abilities()
|
|
|
|
_build_characteristics()
|
|
|
|
_build_egg_groups()
|
|
|
|
_build_growth_rates()
|
|
|
|
_build_items()
|
|
|
|
_build_types()
|
|
|
|
_build_contests()
|
|
|
|
_build_moves()
|
|
|
|
_build_berries()
|
|
|
|
_build_natures()
|
|
|
|
_build_genders()
|
|
|
|
_build_experiences()
|
|
|
|
_build_machines()
|
|
|
|
_build_evolutions()
|
|
|
|
_build_pokedexes()
|
|
|
|
_build_locations()
|
|
|
|
_build_pokemons()
|
|
|
|
_build_encounters()
|
|
|
|
_build_pal_parks()
|
2015-12-05 11:13:46 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2016-03-05 11:40:41 +00:00
|
|
|
build_all()
|