Skip to content

Commit

Permalink
Merge pull request PokeAPI#634 from phrasmotica/feature/past-type-eff…
Browse files Browse the repository at this point in the history
…icacy

Add past type damage relations data
  • Loading branch information
Naramsim authored Jul 24, 2021
2 parents 05edde9 + 206af8a commit 2be93d8
Show file tree
Hide file tree
Showing 7 changed files with 547 additions and 116 deletions.
10 changes: 10 additions & 0 deletions data/v2/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,16 @@ def csv_record_to_objects(info):

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

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)


#############
# CONTEST #
Expand Down
7 changes: 7 additions & 0 deletions data/v2/csv/type_efficacy_past.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
damage_type_id,target_type_id,damage_factor,generation_id
4,7,200,1
7,4,200,1
8,14,0,1
15,10,100,1
8,9,50,5
17,9,50,5
214 changes: 144 additions & 70 deletions pokemon_v2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2864,67 +2864,133 @@ Types are properties for Pokémon and their moves. Each type has three propertie

```json
{
"id": 5,
"name": "ground",
"damage_relations": {
"no_damage_to": [{
"name": "flying",
"url": "http://pokeapi.co/api/v2/type/3/"
}],
"half_damage_to": [{
"name": "bug",
"url": "http://pokeapi.co/api/v2/type/7/"
}],
"double_damage_to": [{
"name": "poison",
"url": "http://pokeapi.co/api/v2/type/4/"
}],
"no_damage_from": [{
"name": "electric",
"url": "http://pokeapi.co/api/v2/type/13/"
}],
"half_damage_from": [{
"name": "poison",
"url": "http://pokeapi.co/api/v2/type/4/"
}],
"double_damage_from": [{
"name": "water",
"url": "http://pokeapi.co/api/v2/type/11/"
}]
},
"game_indices": [{
"game_index": 4,
"generation": {
"name": "generation-i",
"url": "http://pokeapi.co/api/v2/generation/1/"
}
}],
"generation": {
"name": "generation-i",
"url": "http://pokeapi.co/api/v2/generation/1/"
},
"move_damage_class": {
"name": "physical",
"url": "http://pokeapi.co/api/v2/move-damage-class/2/"
},
"names": [{
"name": "じめん",
"language": {
"name": "ja",
"url": "http://pokeapi.co/api/v2/language/1/"
}
}],
"pokemon": [{
"slot": 1,
"pokemon": {
"name": "sandshrew",
"url": "http://pokeapi.co/api/v2/pokemon/27/"
}
}],
"moves": [{
"name": "sand-attack",
"url": "http://pokeapi.co/api/v2/move/28/"
}]
"id": 8,
"name": "ghost",
"damage_relations": {
"no_damage_to": [
{
"name": "normal",
"url": "https://pokeapi.co/api/v2/type/1/"
}
],
"half_damage_to": [
{
"name": "dark",
"url": "https://pokeapi.co/api/v2/type/17/"
}
],
"double_damage_to": [
{
"name": "ghost",
"url": "https://pokeapi.co/api/v2/type/8/"
}
],
"no_damage_from": [
{
"name": "normal",
"url": "https://pokeapi.co/api/v2/type/1/"
}
],
"half_damage_from": [
{
"name": "poison",
"url": "https://pokeapi.co/api/v2/type/4/"
}
],
"double_damage_from": [
{
"name": "ghost",
"url": "https://pokeapi.co/api/v2/type/8/"
}
]
},
"past_damage_relations": [
{
"generation": {
"name": "generation-v",
"url": "https://pokeapi.co/api/v2/generation/5/"
},
"damage_relations": {
"no_damage_to": [
{
"name": "normal",
"url": "https://pokeapi.co/api/v2/type/1/"
}
],
"half_damage_to": [
{
"name": "steel",
"url": "https://pokeapi.co/api/v2/type/9/"
}
],
"double_damage_to": [
{
"name": "ghost",
"url": "https://pokeapi.co/api/v2/type/8/"
}
],
"no_damage_from": [
{
"name": "normal",
"url": "https://pokeapi.co/api/v2/type/1/"
}
],
"half_damage_from": [
{
"name": "poison",
"url": "https://pokeapi.co/api/v2/type/4/"
}
],
"double_damage_from": [
{
"name": "ghost",
"url": "https://pokeapi.co/api/v2/type/8/"
}
]
}
}
],
"game_indices": [
{
"game_index": 8,
"generation": {
"name": "generation-i",
"url": "https://pokeapi.co/api/v2/generation/1/"
}
}
],
"generation": {
"name": "generation-i",
"url": "https://pokeapi.co/api/v2/generation/1/"
},
"move_damage_class": {
"name": "physical",
"url": "https://pokeapi.co/api/v2/move-damage-class/2/"
},
"names": [
{
"name": "ゴースト",
"language": {
"name": "ja-Hrkt",
"url": "https://pokeapi.co/api/v2/language/1/"
}
}
],
"pokemon": [
{
"slot": 1,
"pokemon": {
"name": "gastly",
"url": "https://pokeapi.co/api/v2/pokemon/92/"
}
}
],
"moves": [
{
"name": "night-shade",
"url": "https://pokeapi.co/api/v2/move/101/"
}
]
}
```

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

| Name | Description | Data Type |
| ---- | ----------- | --------- |
| id | The identifier for this type resource | integer |
| name | The name for this type resource | string |
| damage_relations | A detail of how effective this type is toward others and vice versa | [TypeRelations](#typerelations) |
| game_indices | A list of game indices relevent to this item by generation | list [GenerationGameIndex](#generationgameindex) |
| generation | The generation this type was introduced in | [NamedAPIResource](#namedapiresource) ([Generation](#generations)) |
| move_damage_class | The class of damage inflicted by this type | [NamedAPIResource](#namedapiresource) ([MoveDamageClass](#move-damage-classes)) |
| names | The name of this type listed in different languages | list [Name](#resourcename) |
| pokemon | A list of details of pokemon that have this type | [TypePokemon](#typepokemon) |
| moves | A list of moves that have this type | list [NamedAPIResource](#namedapiresource) ([Move](#moves)) |
| id | The identifier for this type resource | integer |
| name | The name for this type resource | string |
| damage_relations | A detail of how effective this type is toward others and vice versa | [TypeRelations](#typerelations) |
| past_damage_relations | A list of details of how effective this type was toward others and vice versa in previous generations | list [TypeRelationsPast](#typerelationspast) |
| game_indices | A list of game indices relevent to this item by generation | list [GenerationGameIndex](#generationgameindex) |
| generation | The generation this type was introduced in | [NamedAPIResource](#namedapiresource) ([Generation](#generations)) |
| move_damage_class | The class of damage inflicted by this type | [NamedAPIResource](#namedapiresource) ([MoveDamageClass](#move-damage-classes)) |
| names | The name of this type listed in different languages | list [Name](#resourcename) |
| pokemon | A list of details of pokemon that have this type | [TypePokemon](#typepokemon) |
| moves | A list of moves that have this type | list [NamedAPIResource](#namedapiresource) ([Move](#moves)) |

#### TypePokemon

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

#### TypeRelationsPast

| Name | Description | Data Type |
| ---- | ----------- | --------- |
| generation | The last generation in which the referenced type had the listed damage relations | [NamedAPIResource](#namedapiresource) ([Generation](#generations)) |
| damage_relations | The damage relations the referenced type had up to and including the listed generation | list [TypeRelations](#typerelations) |


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

Expand Down
84 changes: 84 additions & 0 deletions pokemon_v2/migrations/0011_typeefficacypast.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Generated by Django 2.1.11 on 2021-02-24 13:42

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
("pokemon_v2", "0010_pokemonformtype"),
]

operations = [
migrations.CreateModel(
name="TypeEfficacyPast",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("damage_factor", models.IntegerField()),
(
"damage_type",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="typeefficacypast_damage_type",
to="pokemon_v2.Type",
),
),
(
"generation",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="typeefficacypast",
to="pokemon_v2.Generation",
),
),
(
"target_type",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="typeefficacypast_target_type",
to="pokemon_v2.Type",
),
),
],
options={
"abstract": False,
},
),
migrations.AlterField(
model_name="typeefficacy",
name="damage_type",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="typeefficacy_damage_type",
to="pokemon_v2.Type",
),
),
migrations.AlterField(
model_name="typeefficacy",
name="target_type",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="typeefficacy_target_type",
to="pokemon_v2.Type",
),
),
]
Loading

0 comments on commit 2be93d8

Please sign in to comment.