pokemon-showdown-client/src/battle-dex-data.ts
Guangcong Luo f6c03e0370 Implement new battle-text-parser
All battle text messages have been moved out of `src/battle.ts` and
into its own file `data/text.js`.

Code for handling this is in the new files `src/battle-log.ts` and
`src/battle-text-parser.ts`.

`data/text.js` is now extremely self-contained, and nearly ready for
translation support!

This is a significant modernization of battle.ts. In addition to moving
messages out:

Functions for getting names (`pokemon.getLowerName()` etc) have been
removed.

`battle.minorQueue` has been removed. Minor lines are now processed
directly on the main queue, with a new `battle.waitForAnimations`
flag to decide whether or not the main queue should wait for animations
to finish before moving on to the next line.

`battle.waitForResult()` and `battle.endPrevAction()` have been
removed. These confusingly-named functions closed the messagebar (and
flush the minor queue). They've been replaced with
`scene.maybeCloseMessagebar()`.

`pokemon.markMove()` and `pokemon.markAbility()` have been renamed
`pokemon.rememberMove()` and `pokemon.rememberAbility()`.
2018-11-15 18:52:53 -06:00

248 lines
4.2 KiB
TypeScript

/**
* Pokemon Showdown Dex Data
*
* A collection of data and definitions for src/battle-dex.ts.
*
* Larger data has their own files in data/, so this is just for small
* miscellaneous data that doesn't need its own file.
*
* Licensing note: PS's client has complicated licensing:
* - The client as a whole is AGPLv3
* - The battle replay/animation engine (battle-*.ts) by itself is MIT
*
* @author Guangcong Luo <guangcongluo@gmail.com>
* @license MIT
*/
type ID = string & {__isID: true};
const BattleNatures = {
Adamant: {
plus: 'atk',
minus: 'spa'
},
Bashful: {},
Bold: {
plus: 'def',
minus: 'atk'
},
Brave: {
plus: 'atk',
minus: 'spe'
},
Calm: {
plus: 'spd',
minus: 'atk'
},
Careful: {
plus: 'spd',
minus: 'spa'
},
Docile: {},
Gentle: {
plus: 'spd',
minus: 'def'
},
Hardy: {},
Hasty: {
plus: 'spe',
minus: 'def'
},
Impish: {
plus: 'def',
minus: 'spa'
},
Jolly: {
plus: 'spe',
minus: 'spa'
},
Lax: {
plus: 'def',
minus: 'spd'
},
Lonely: {
plus: 'atk',
minus: 'def'
},
Mild: {
plus: 'spa',
minus: 'def'
},
Modest: {
plus: 'spa',
minus: 'atk'
},
Naive: {
plus: 'spe',
minus: 'spd'
},
Naughty: {
plus: 'atk',
minus: 'spd'
},
Quiet: {
plus: 'spa',
minus: 'spe'
},
Quirky: {},
Rash: {
plus: 'spa',
minus: 'spd'
},
Relaxed: {
plus: 'def',
minus: 'spe'
},
Sassy: {
plus: 'spd',
minus: 'spe'
},
Serious: {},
Timid: {
plus: 'spe',
minus: 'atk'
}
};
const BattleStatIDs = {
HP: 'hp',
hp: 'hp',
Atk: 'atk',
atk: 'atk',
Def: 'def',
def: 'def',
SpA: 'spa',
SAtk: 'spa',
SpAtk: 'spa',
spa: 'spa',
spc: 'spa',
Spc: 'spa',
SpD: 'spd',
SDef: 'spd',
SpDef: 'spd',
spd: 'spd',
Spe: 'spe',
Spd: 'spe',
spe: 'spe'
};
const BattlePOStatNames = { // only used for interacting with PO
hp: 'HP',
atk: 'Atk',
def: 'Def',
spa: 'SAtk',
spd: 'SDef',
spe: 'Spd'
};
const BattleStatNames = { // proper style
hp: 'HP',
atk: 'Atk',
def: 'Def',
spa: 'SpA',
spd: 'SpD',
spe: 'Spe'
};
const BattleStats = {
hp: 'HP', atk: 'Attack', def: 'Defense', spa: 'Special Attack', spd: 'Special Defense', spe: 'Speed', accuracy: 'accuracy', evasion: 'evasiveness', spc: 'Special'
};
const baseSpeciesChart = [
'pikachu',
'pichu',
'unown',
'castform',
'deoxys',
'burmy',
'wormadam',
'cherrim',
'shellos',
'gastrodon',
'rotom',
'giratina',
'shaymin',
'arceus',
'basculin',
'darmanitan',
'deerling',
'sawsbuck',
'tornadus',
'thundurus',
'landorus',
'kyurem',
'keldeo',
'meloetta',
'genesect',
'vivillon',
'flabebe',
'floette',
'florges',
'furfrou',
'aegislash',
'pumpkaboo',
'gourgeist',
'meowstic',
'hoopa',
'zygarde',
'lycanroc',
'wishiwashi',
'minior',
'mimikyu',
'greninja',
'oricorio',
'silvally',
'necrozma',
// alola totems
'raticate',
'marowak',
'kommoo',
// mega evolutions
'charizard',
'mewtwo'
// others are hardcoded by ending with 'mega'
];
type StatName = 'hp' | 'atk' | 'def' | 'spa' | 'spd' | 'spe';
type StatusName = 'par' | 'psn' | 'frz' | 'slp' | 'brn';
type BoostStatName = 'atk' | 'def' | 'spa' | 'spd' | 'spe' | 'evasion' | 'accuracy' | 'spc';
type GenderName = 'M' | 'F' | '';
interface Effect {
readonly id: ID;
readonly name: string;
readonly gen: number;
readonly effectType: 'Item' | 'Move' | 'Ability' | 'Template';
readonly exists: boolean;
}
interface Item extends Effect {
readonly effectType: 'Item';
readonly zMoveFrom?: string;
}
interface Move extends Effect {
readonly effectType: 'Move';
readonly type: string;
readonly category: string;
readonly isZ?: string;
}
interface Ability extends Effect {
readonly effectType: 'Ability';
}
interface Template extends Effect {
readonly effectType: 'Template';
readonly species: string;
readonly speciesid: ID;
readonly baseSpecies: string;
readonly forme: string;
readonly formeLetter: string;
readonly formeid: string;
readonly spriteid: string;
readonly types: string[];
readonly abilities: {0: string, 1?: string, H?: string, S?: string};
readonly baseStats: {hp: number, atk: number, def: number, spa: number, spd: number, spe: number}
readonly unreleasedHidden: boolean;
readonly tier: string;
readonly weightkg: number;
readonly isNonstandard: boolean;
readonly isTotem?: boolean;
readonly isMega?: boolean;
}