Merge pull request #33657 from jalyna/add-oakdex-pokedex

[oakdex-pokedex] Added type defs for oakdex-pokedex
This commit is contained in:
Nathan Shively-Sanders
2019-03-08 15:20:54 -08:00
committed by GitHub
4 changed files with 867 additions and 0 deletions

349
types/oakdex-pokedex/index.d.ts vendored Normal file
View File

@@ -0,0 +1,349 @@
// Type definitions for oakdex-pokedex 0.4
// Project: https://github.com/jalyna/oakdex-pokedex
// Definitions by: Jalyna Schroeder <https://github.com/jalyna>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export interface Translations {
de: string;
en: string;
cz?: string;
dk?: string;
fr?: string;
gr?: string;
it?: string;
pl?: string;
tr?: string;
jp?: string;
es?: string;
}
export interface PokemonEvolution {
to: string;
level?: number;
happiness?: boolean;
trade?: boolean;
level_up?: boolean;
item?: string;
hold_item?: string;
move_learned?: string;
conditions?: string[];
}
export interface PokemonAbility {
name: string;
hidden?: boolean;
}
export interface StatObject {
hp: number;
atk: number;
def: number;
sp_atk: number;
sp_def: number;
speed: number;
}
export interface MegaEvolution {
types: string[];
ability: string;
height_us: string;
height_eu: string;
weight_us: string;
weight_eu: string;
base_stats: StatObject;
mega_stone: string;
image_suffix?: string;
}
export interface PokemonVariation {
condition?: string;
names: Translations;
types: string[];
height_us?: string;
height_eu?: string;
weight_us?: string;
weight_eu?: string;
base_stats?: StatObject;
pokeathlon_stats?: {
speed?: number[];
power?: number[];
stamina?: number[];
skill?: number[];
jump?: number[]
};
abilities?: string[];
image_suffix?: string;
}
export interface Learnset {
move: string;
level?: number;
tm?: string;
egg_move?: boolean;
variations?: string[];
}
export interface MoveLearnset {
games: string[];
learnset: Learnset[];
}
export interface Pokemon {
names: Translations;
categories: Translations;
national_id: number;
kanto_id: number | null;
johto_id: number | null;
hoenn_id: number | null;
sinnoh_id: number | null;
unova_id: number | null;
kalos_id: number | null;
alola_id: number | null;
ultra_alola_id: number | null;
pokedex_entries: {
[key: string]: Translations;
};
evolution_from: string | null;
evolutions: PokemonEvolution[];
types: string[];
abilities: PokemonAbility[];
gender_ratios: null | {
female: number;
male: number;
};
catch_rate: number;
egg_groups: string[];
hatch_time: number[];
height_us: string;
height_eu: string;
weight_us: string;
weight_eu: string;
base_exp_yield: number;
leveling_rate: string;
ev_yield: StatObject;
color: string;
base_friendship: number;
base_stats: StatObject;
pokeathlon_stats?: {
speed?: number[];
power?: number[];
stamina?: number[];
skill?: number[];
jump?: number[];
};
mega_evolutions: MegaEvolution[];
variation_names?: Translations;
variations: PokemonVariation[];
move_learnsets: MoveLearnset[];
}
export interface MoveStatusCondition {
condition: string;
probability: number;
}
export interface MoveStatModifier {
stat: string;
change_by: number;
affects_user?: boolean;
}
export interface MoveContest {
contest: string;
condition: string;
appeal: number;
jam: number;
}
export interface Move {
names: Translations;
index_number: number;
pp: number;
max_pp: number;
power: number;
accuracy: number;
type: string;
category: string;
priority: number;
target: string;
critical_hit: number;
pokedex_entries: {
[key: string]: Translations;
};
contests: MoveContest[];
makes_contact: boolean;
affected_by_protect: boolean;
affected_by_magic_coat: boolean;
affected_by_snatch: boolean;
affected_by_mirror_move: boolean;
affected_by_kings_rock: boolean;
in_battle_properties?: {
increased_critical_hit_ratio?: boolean;
status_conditions?: MoveStatusCondition[]
};
stat_modifiers?: MoveStatModifier[];
}
export interface Ability {
names: Translations;
index_number: number;
descriptions: Translations;
}
export interface PokemonType {
names: Translations;
color: string;
effectivness: {
Normal: number;
Fighting: number;
Flying: number;
Poison: number;
Ground: number;
Rock: number;
Bug: number;
Ghost: number;
Steel: number;
Fire: number;
Water: number;
Grass: number;
Electric: number;
Psychic: number;
Ice: number;
Dragon: number;
Dark: number;
Fairy: number;
};
}
export interface LocationPokemon {
pokemon: string;
location: string;
min_level: number;
max_level: number;
rarity: string;
games: string[];
day_times?: string[];
seasons?: string[];
variation?: string;
}
export interface Location {
names: Translations;
pokemon: LocationPokemon[];
}
export interface Region {
names: Translations;
locations: Location[];
}
export interface EggGroup {
names: Translations;
}
export interface Generation {
names: Translations;
dex_name: string;
number: number;
games: Translations[];
}
export interface Nature {
names: Translations;
increased_stat: string | null;
decreased_stat: string | null;
favorite_flavor: string | null;
disliked_flavor: string | null;
}
export interface ItemPrice {
games: string[];
buying: number;
selling: number;
}
export interface ItemPocket {
pocket: string;
generations: number[];
}
export interface ItemDescription {
translations: Translations;
games: string[];
}
export interface ItemPokemonChange {
field: string;
change_by_percent?: number;
revive?: boolean;
change_by?: number;
change?: string;
conditions?: string[];
}
export interface ItemMoveChange {
field: string;
change_by_percent?: number;
change_by?: number;
change_by_max?: number;
}
export interface ItemEffect {
condition: string;
target: string;
triggers_evolution?: boolean;
pokemon_changes?: ItemPokemonChange[];
move_changes?: ItemMoveChange[];
}
export interface Item {
names: Translations;
category: string;
descriptions: ItemDescription[];
prices: ItemPrice[];
pockets: ItemPocket[];
effects: ItemEffect[];
fling_power: number;
}
export interface Conditions {
[key: string]: any;
}
export function resetPokemon(): void;
export function importPokemon(customPokemon: string[] | string | Pokemon[]): void;
export function findPokemon(idOrName: string | number): Pokemon | null;
export function findMove(name: string): Move | null;
export function findAbility(name: string): Ability | null;
export function findType(name: string): PokemonType | null;
export function findRegion(name: string): Region | null;
export function findEggGroup(name: string): EggGroup | null;
export function findGeneration(name: string): Generation | null;
export function findNature(name: string): Nature | null;
export function findItem(name: string): Item | null;
export function allPokemon(conditions?: Conditions): Pokemon[];
export function allItems(conditions?: Conditions): Item[];
export function allTypes(conditions?: Conditions): PokemonType[];
export function allAbilities(conditions?: Conditions): Ability[];
export function allRegions(conditions?: Conditions): Region[];
export function allEggGroups(conditions?: Conditions): EggGroup[];
export function allGenerations(conditions?: Conditions): Generation[];
export function allNatures(conditions?: Conditions): Nature[];

View File

@@ -0,0 +1,492 @@
import {
Pokemon,
Move,
Ability,
PokemonType,
Region,
EggGroup,
Generation,
Nature,
Item
} from 'oakdex-pokedex';
// Pokemon
() => {
const pikachu: Pokemon = {
names: {
fr: 'Pikachu',
de: 'Pikachu',
it: 'Pikachu',
en: 'Pikachu'
},
national_id: 25,
types: [
'Electric'
],
abilities: [
{
name: 'Static'
},
{
name: 'Lightning Rod',
hidden: true
}
],
gender_ratios: {
male: 50,
female: 50
},
catch_rate: 190,
egg_groups: [
'Field',
'Fairy'
],
hatch_time: [
5355,
5609
],
height_us: '1\'04"',
height_eu: '0.4 m',
weight_us: '13.2 lbs.',
weight_eu: '6.0 kg',
base_exp_yield: 105,
leveling_rate: 'Medium Fast',
ev_yield: {
hp: 0,
atk: 0,
def: 0,
sp_atk: 0,
sp_def: 0,
speed: 2
},
color: 'Yellow',
base_friendship: 70,
base_stats: {
hp: 35,
atk: 55,
def: 30,
sp_atk: 50,
sp_def: 40,
speed: 90
},
evolutions: [
{
to: 'Raichu',
item: 'Thunderstone'
}
],
evolution_from: 'Pichu',
alola_id: 25,
categories: {
en: 'Mouse Pokémon',
de: 'Maus'
},
kanto_id: 25,
johto_id: 22,
hoenn_id: 163,
sinnoh_id: 104,
unova_id: null,
kalos_id: 36,
mega_evolutions: [],
variations: [
{
names: {
fr: 'Pikachu (Pokémon partenaire)',
de: 'Pikachu (Partner-Pokémon)',
it: 'Pikachu (Pokémon compagno)',
en: 'Pikachu (Partner Pokémon)'
},
types: [
'Electric'
],
base_stats: {
hp: 45,
atk: 80,
def: 50,
sp_atk: 75,
sp_def: 60,
speed: 120
}
}
],
pokedex_entries: {
Red: {
en: 'When several of these Pokémon gather, their electricity could build and cause lightning storms.',
de: 'Wenn sich mehrere dieser Pokémon versammeln, kann ihre Energie Blitzgewitter erzeugen.'
},
Blue: {
en: 'When several of these Pokémon gather, their electricity could build and cause lightning storms.',
de: 'Wenn sich mehrere dieser Pokémon versammeln, kann ihre Energie Blitzgewitter erzeugen.'
}
},
pokeathlon_stats: {
speed: [
3,
4
],
power: [
3,
4
],
stamina: [
3,
4
],
skill: [
3,
4
],
jump: [
3,
4
]
},
ultra_alola_id: 32,
move_learnsets: [
{
games: [
'Red',
'Blue'
],
learnset: [
{
move: 'Growl',
level: 1
},
{
move: 'Thunder Shock',
level: 1
},
{
move: 'Thunder Wave',
level: 9
},
{
move: 'Quick Attack',
level: 16
},
{
move: 'Swift',
level: 26
},
{
move: 'Agility',
level: 33
},
{
move: 'Thunder',
level: 43
},
{
move: 'Flash',
tm: 'HM5'
},
{
move: 'Mega Punch',
tm: 'TM1'
},
{
move: 'Mega Kick',
tm: 'TM5'
},
{
move: 'Toxic',
egg_move: true
}
]
}
]
};
};
// Move
() => {
const tackle: Move = {
index_number: 33,
pp: 35,
max_pp: 56,
power: 50,
accuracy: 100,
category: 'physical',
priority: 0,
target: 'target_adjacent_single',
critical_hit: 0,
makes_contact: true,
affected_by_protect: true,
affected_by_magic_coat: false,
affected_by_snatch: false,
affected_by_mirror_move: false,
affected_by_kings_rock: true,
names: {
cz: 'Nárazový útok',
dk: 'Tackling',
fr: 'Charge',
de: 'Tackle',
gr: 'Εφόρμηση',
en: 'Tackle'
},
type: 'Normal',
contests: [
{
contest: 'Contests',
appeal: 4,
jam: 0,
condition: 'Tough'
},
{
contest: 'Super Contests',
appeal: 3,
jam: 0,
condition: 'Tough'
},
{
contest: 'Contest Spectaculars',
appeal: 4,
jam: 0,
condition: 'Tough'
}
],
pokedex_entries: {
Gold: {
en: 'A full-body charge attack.',
de: 'Attacke mit vollem Körpereinsatz.'
},
Silver: {
en: 'A full-body charge attack.',
de: 'Attacke mit vollem Körpereinsatz.'
},
Crystal: {
en: 'A full-body charge attack.',
de: 'Attacke mit vollem Körpereinsatz.'
}
}
};
};
// Ability
() => {
const airLock: Ability = {
index_number: 76,
names: {
fr: 'Air Lock',
de: 'Klimaschutz',
it: 'Riparo',
en: 'Air Lock'
},
descriptions: {
en: 'Eliminates the effects of weather.',
de: 'Example'
}
};
};
// EggGroup
() => {
const bug: EggGroup = {
names: {
en: 'Bug',
jp: 'むし (虫) Mushi',
fr: 'Insecte',
de: 'Käfer',
it: 'Coleottero',
es: 'Bicho'
}
};
};
// Generation
() => {
const gen1: Generation = {
number: 1,
dex_name: 'kanto_id',
names: {
en: 'Generation I',
de: 'Generation I'
},
games: [
{
en: 'Red',
de: 'Rot'
},
{
en: 'Blue',
de: 'Blau'
},
{
en: 'Yellow',
de: 'Gelb'
}
]
};
};
// Item
() => {
const potion: Item = {
names: {
en: 'Potion',
de: 'Trank',
fr: 'Potion',
es: 'Poción',
it: 'Pozione'
},
category: 'Potions',
descriptions: [
{
games: [
'Gold',
'Silver',
'Crystal'
],
translations: {
en: 'Restores Pokémon HP by 20.',
de: 'Füllt die KP um 20 auf.'
}
}
],
prices: [
{
games: [
'Red',
'Blue',
'Yellow'
],
buying: 300,
selling: 150
},
{
games: [
'Sun',
'Moon',
'Ultra Sun',
'Ultra Moon'
],
buying: 200,
selling: 100
}
],
pockets: [
{
generations: [
1,
2,
3
],
pocket: 'Items'
},
{
generations: [
4,
5,
6,
7
],
pocket: 'Medicine'
}
],
fling_power: 30,
effects: [
{
condition: 'Always',
target: 'Single Pokemon',
pokemon_changes: [
{
field: 'current_hp',
change_by: 20
}
]
}
]
};
};
// Nature
() => {
const bold: Nature = {
names: {
en: 'Bold',
de: 'Kühn'
},
increased_stat: 'def',
decreased_stat: 'atk',
favorite_flavor: 'Sour',
disliked_flavor: 'Spicy'
};
};
// PokemonType
() => {
const dragon: PokemonType = {
names: {
dk: 'Drage',
fr: 'Dragon',
de: 'Drache',
gr: 'Δράκου Drakou',
it: 'Drago',
pl: 'SmokSmoczy',
en: 'Dragon'
},
effectivness: {
Normal: 1,
Fighting: 1,
Flying: 1,
Poison: 1,
Ground: 1,
Rock: 1,
Bug: 1,
Ghost: 1,
Steel: 0.5,
Fire: 1,
Water: 1,
Grass: 1,
Electric: 1,
Psychic: 1,
Ice: 1,
Dragon: 2,
Dark: 1,
Fairy: 0
},
color: '#6F35FC'
};
};
// Region
() => {
const alola: Region = {
names: {
en: 'Alola',
fr: 'Alola',
es: 'Alola',
de: 'Alola',
it: 'Alola'
},
locations: [
{
names: {
en: 'Route 1',
fr: 'Abords d\'Ekaeka',
es: 'Afueras de Hauoli',
de: 'Hauholi-Stadtrand',
it: 'Periferia di Hau\'oli'
},
pokemon: [
{
pokemon: 'Pikipek',
location: 'Walking',
min_level: 2,
max_level: 3,
rarity: 'common',
games: [
'Sun',
'Moon'
],
day_times: [
'day',
'night'
]
}
]
}
]
};
};

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"oakdex-pokedex-tests.ts"
]
}

View File

@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}