Skip to content

Commit 2be93d8

Browse files
authored
Merge pull request #634 from phrasmotica/feature/past-type-efficacy
Add past type damage relations data
2 parents 05edde9 + 206af8a commit 2be93d8

File tree

7 files changed

+547
-116
lines changed

7 files changed

+547
-116
lines changed

data/v2/build.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,16 @@ def csv_record_to_objects(info):
594594

595595
build_generic((TypeEfficacy,), "type_efficacy.csv", csv_record_to_objects)
596596

597+
def csv_record_to_objects(info):
598+
yield TypeEfficacyPast(
599+
damage_type_id=int(info[0]),
600+
target_type_id=int(info[1]),
601+
damage_factor=int(info[2]),
602+
generation_id=int(info[3]),
603+
)
604+
605+
build_generic((TypeEfficacyPast,), "type_efficacy_past.csv", csv_record_to_objects)
606+
597607

598608
#############
599609
# CONTEST #

data/v2/csv/type_efficacy_past.csv

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
damage_type_id,target_type_id,damage_factor,generation_id
2+
4,7,200,1
3+
7,4,200,1
4+
8,14,0,1
5+
15,10,100,1
6+
8,9,50,5
7+
17,9,50,5

pokemon_v2/README.md

Lines changed: 144 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -2864,67 +2864,133 @@ Types are properties for Pokémon and their moves. Each type has three propertie
28642864

28652865
```json
28662866
{
2867-
"id": 5,
2868-
"name": "ground",
2869-
"damage_relations": {
2870-
"no_damage_to": [{
2871-
"name": "flying",
2872-
"url": "http://pokeapi.co/api/v2/type/3/"
2873-
}],
2874-
"half_damage_to": [{
2875-
"name": "bug",
2876-
"url": "http://pokeapi.co/api/v2/type/7/"
2877-
}],
2878-
"double_damage_to": [{
2879-
"name": "poison",
2880-
"url": "http://pokeapi.co/api/v2/type/4/"
2881-
}],
2882-
"no_damage_from": [{
2883-
"name": "electric",
2884-
"url": "http://pokeapi.co/api/v2/type/13/"
2885-
}],
2886-
"half_damage_from": [{
2887-
"name": "poison",
2888-
"url": "http://pokeapi.co/api/v2/type/4/"
2889-
}],
2890-
"double_damage_from": [{
2891-
"name": "water",
2892-
"url": "http://pokeapi.co/api/v2/type/11/"
2893-
}]
2894-
},
2895-
"game_indices": [{
2896-
"game_index": 4,
2897-
"generation": {
2898-
"name": "generation-i",
2899-
"url": "http://pokeapi.co/api/v2/generation/1/"
2900-
}
2901-
}],
2902-
"generation": {
2903-
"name": "generation-i",
2904-
"url": "http://pokeapi.co/api/v2/generation/1/"
2905-
},
2906-
"move_damage_class": {
2907-
"name": "physical",
2908-
"url": "http://pokeapi.co/api/v2/move-damage-class/2/"
2909-
},
2910-
"names": [{
2911-
"name": "じめん",
2912-
"language": {
2913-
"name": "ja",
2914-
"url": "http://pokeapi.co/api/v2/language/1/"
2915-
}
2916-
}],
2917-
"pokemon": [{
2918-
"slot": 1,
2919-
"pokemon": {
2920-
"name": "sandshrew",
2921-
"url": "http://pokeapi.co/api/v2/pokemon/27/"
2922-
}
2923-
}],
2924-
"moves": [{
2925-
"name": "sand-attack",
2926-
"url": "http://pokeapi.co/api/v2/move/28/"
2927-
}]
2867+
"id": 8,
2868+
"name": "ghost",
2869+
"damage_relations": {
2870+
"no_damage_to": [
2871+
{
2872+
"name": "normal",
2873+
"url": "https://pokeapi.co/api/v2/type/1/"
2874+
}
2875+
],
2876+
"half_damage_to": [
2877+
{
2878+
"name": "dark",
2879+
"url": "https://pokeapi.co/api/v2/type/17/"
2880+
}
2881+
],
2882+
"double_damage_to": [
2883+
{
2884+
"name": "ghost",
2885+
"url": "https://pokeapi.co/api/v2/type/8/"
2886+
}
2887+
],
2888+
"no_damage_from": [
2889+
{
2890+
"name": "normal",
2891+
"url": "https://pokeapi.co/api/v2/type/1/"
2892+
}
2893+
],
2894+
"half_damage_from": [
2895+
{
2896+
"name": "poison",
2897+
"url": "https://pokeapi.co/api/v2/type/4/"
2898+
}
2899+
],
2900+
"double_damage_from": [
2901+
{
2902+
"name": "ghost",
2903+
"url": "https://pokeapi.co/api/v2/type/8/"
2904+
}
2905+
]
2906+
},
2907+
"past_damage_relations": [
2908+
{
2909+
"generation": {
2910+
"name": "generation-v",
2911+
"url": "https://pokeapi.co/api/v2/generation/5/"
2912+
},
2913+
"damage_relations": {
2914+
"no_damage_to": [
2915+
{
2916+
"name": "normal",
2917+
"url": "https://pokeapi.co/api/v2/type/1/"
2918+
}
2919+
],
2920+
"half_damage_to": [
2921+
{
2922+
"name": "steel",
2923+
"url": "https://pokeapi.co/api/v2/type/9/"
2924+
}
2925+
],
2926+
"double_damage_to": [
2927+
{
2928+
"name": "ghost",
2929+
"url": "https://pokeapi.co/api/v2/type/8/"
2930+
}
2931+
],
2932+
"no_damage_from": [
2933+
{
2934+
"name": "normal",
2935+
"url": "https://pokeapi.co/api/v2/type/1/"
2936+
}
2937+
],
2938+
"half_damage_from": [
2939+
{
2940+
"name": "poison",
2941+
"url": "https://pokeapi.co/api/v2/type/4/"
2942+
}
2943+
],
2944+
"double_damage_from": [
2945+
{
2946+
"name": "ghost",
2947+
"url": "https://pokeapi.co/api/v2/type/8/"
2948+
}
2949+
]
2950+
}
2951+
}
2952+
],
2953+
"game_indices": [
2954+
{
2955+
"game_index": 8,
2956+
"generation": {
2957+
"name": "generation-i",
2958+
"url": "https://pokeapi.co/api/v2/generation/1/"
2959+
}
2960+
}
2961+
],
2962+
"generation": {
2963+
"name": "generation-i",
2964+
"url": "https://pokeapi.co/api/v2/generation/1/"
2965+
},
2966+
"move_damage_class": {
2967+
"name": "physical",
2968+
"url": "https://pokeapi.co/api/v2/move-damage-class/2/"
2969+
},
2970+
"names": [
2971+
{
2972+
"name": "ゴースト",
2973+
"language": {
2974+
"name": "ja-Hrkt",
2975+
"url": "https://pokeapi.co/api/v2/language/1/"
2976+
}
2977+
}
2978+
],
2979+
"pokemon": [
2980+
{
2981+
"slot": 1,
2982+
"pokemon": {
2983+
"name": "gastly",
2984+
"url": "https://pokeapi.co/api/v2/pokemon/92/"
2985+
}
2986+
}
2987+
],
2988+
"moves": [
2989+
{
2990+
"name": "night-shade",
2991+
"url": "https://pokeapi.co/api/v2/move/101/"
2992+
}
2993+
]
29282994
}
29292995
```
29302996

@@ -2934,15 +3000,16 @@ Types are properties for Pokémon and their moves. Each type has three propertie
29343000

29353001
| Name | Description | Data Type |
29363002
| ---- | ----------- | --------- |
2937-
| id | The identifier for this type resource | integer |
2938-
| name | The name for this type resource | string |
2939-
| damage_relations | A detail of how effective this type is toward others and vice versa | [TypeRelations](#typerelations) |
2940-
| game_indices | A list of game indices relevent to this item by generation | list [GenerationGameIndex](#generationgameindex) |
2941-
| generation | The generation this type was introduced in | [NamedAPIResource](#namedapiresource) ([Generation](#generations)) |
2942-
| move_damage_class | The class of damage inflicted by this type | [NamedAPIResource](#namedapiresource) ([MoveDamageClass](#move-damage-classes)) |
2943-
| names | The name of this type listed in different languages | list [Name](#resourcename) |
2944-
| pokemon | A list of details of pokemon that have this type | [TypePokemon](#typepokemon) |
2945-
| moves | A list of moves that have this type | list [NamedAPIResource](#namedapiresource) ([Move](#moves)) |
3003+
| id | The identifier for this type resource | integer |
3004+
| name | The name for this type resource | string |
3005+
| damage_relations | A detail of how effective this type is toward others and vice versa | [TypeRelations](#typerelations) |
3006+
| past_damage_relations | A list of details of how effective this type was toward others and vice versa in previous generations | list [TypeRelationsPast](#typerelationspast) |
3007+
| game_indices | A list of game indices relevent to this item by generation | list [GenerationGameIndex](#generationgameindex) |
3008+
| generation | The generation this type was introduced in | [NamedAPIResource](#namedapiresource) ([Generation](#generations)) |
3009+
| move_damage_class | The class of damage inflicted by this type | [NamedAPIResource](#namedapiresource) ([MoveDamageClass](#move-damage-classes)) |
3010+
| names | The name of this type listed in different languages | list [Name](#resourcename) |
3011+
| pokemon | A list of details of pokemon that have this type | [TypePokemon](#typepokemon) |
3012+
| moves | A list of moves that have this type | list [NamedAPIResource](#namedapiresource) ([Move](#moves)) |
29463013

29473014
#### TypePokemon
29483015

@@ -2962,6 +3029,13 @@ Types are properties for Pokémon and their moves. Each type has three propertie
29623029
| half_damage_from | A list of types that are not very effective against this type | list [NamedAPIResource](#namedapiresource) ([Type](#types)) |
29633030
| double_damage_from | A list of types that are very effective against this type | list [NamedAPIResource](#namedapiresource) ([Type](#types)) |
29643031

3032+
#### TypeRelationsPast
3033+
3034+
| Name | Description | Data Type |
3035+
| ---- | ----------- | --------- |
3036+
| generation | The last generation in which the referenced type had the listed damage relations | [NamedAPIResource](#namedapiresource) ([Generation](#generations)) |
3037+
| damage_relations | The damage relations the referenced type had up to and including the listed generation | list [TypeRelations](#typerelations) |
3038+
29653039

29663040
<h1 id="utility-section">Utility</h1>
29673041

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Generated by Django 2.1.11 on 2021-02-24 13:42
2+
3+
from django.db import migrations, models
4+
import django.db.models.deletion
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
("pokemon_v2", "0010_pokemonformtype"),
11+
]
12+
13+
operations = [
14+
migrations.CreateModel(
15+
name="TypeEfficacyPast",
16+
fields=[
17+
(
18+
"id",
19+
models.AutoField(
20+
auto_created=True,
21+
primary_key=True,
22+
serialize=False,
23+
verbose_name="ID",
24+
),
25+
),
26+
("damage_factor", models.IntegerField()),
27+
(
28+
"damage_type",
29+
models.ForeignKey(
30+
blank=True,
31+
null=True,
32+
on_delete=django.db.models.deletion.CASCADE,
33+
related_name="typeefficacypast_damage_type",
34+
to="pokemon_v2.Type",
35+
),
36+
),
37+
(
38+
"generation",
39+
models.ForeignKey(
40+
blank=True,
41+
null=True,
42+
on_delete=django.db.models.deletion.CASCADE,
43+
related_name="typeefficacypast",
44+
to="pokemon_v2.Generation",
45+
),
46+
),
47+
(
48+
"target_type",
49+
models.ForeignKey(
50+
blank=True,
51+
null=True,
52+
on_delete=django.db.models.deletion.CASCADE,
53+
related_name="typeefficacypast_target_type",
54+
to="pokemon_v2.Type",
55+
),
56+
),
57+
],
58+
options={
59+
"abstract": False,
60+
},
61+
),
62+
migrations.AlterField(
63+
model_name="typeefficacy",
64+
name="damage_type",
65+
field=models.ForeignKey(
66+
blank=True,
67+
null=True,
68+
on_delete=django.db.models.deletion.CASCADE,
69+
related_name="typeefficacy_damage_type",
70+
to="pokemon_v2.Type",
71+
),
72+
),
73+
migrations.AlterField(
74+
model_name="typeefficacy",
75+
name="target_type",
76+
field=models.ForeignKey(
77+
blank=True,
78+
null=True,
79+
on_delete=django.db.models.deletion.CASCADE,
80+
related_name="typeefficacy_target_type",
81+
to="pokemon_v2.Type",
82+
),
83+
),
84+
]

0 commit comments

Comments
 (0)