mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-04-17 23:29:40 -05:00
* Split up dex-data over individual files This commit introduces: - `dex-abilities.ts` - `dex-conditions.ts` - `dex-formats.ts` - `dex-items.ts` - `dex-moves.ts` - `dex-species.ts` These files centralize definitions from `dex-data` and `global-types`. * Inherit ItemData from Item etc Previously, Condition inherited from ConditionData. Now, ConditionData inherits from Condition. The advantage of the new approach is that now, Condition and DataCondition no longer need to be separate types, and there should be much less duplication of type definitions in general. This has also been done for - ItemData/Item/DataItem - AbilityData/Ability/DataAbility - FormatData/Format/DataFormat Species and DataSpecies was already merged, but this also reverses their inheritance (saving a lot of duplicated definitions in the process!) The only one left is MoveData, which is just super complicated and will need its own commit.
53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
import {EventMethods} from './dex-conditions';
|
|
import {BasicEffect} from './dex-data';
|
|
|
|
interface AbilityEventMethods {
|
|
onCheckShow?: (this: Battle, pokemon: Pokemon) => void;
|
|
onEnd?: (this: Battle, target: Pokemon & Side & Field) => void;
|
|
onPreStart?: (this: Battle, pokemon: Pokemon) => void;
|
|
onStart?: (this: Battle, target: Pokemon) => void;
|
|
}
|
|
|
|
export interface AbilityData extends Partial<Ability>, AbilityEventMethods, EventMethods {
|
|
name: string;
|
|
}
|
|
|
|
export type ModdedAbilityData = AbilityData | Partial<AbilityData> & {inherit: true};
|
|
|
|
export class Ability extends BasicEffect implements Readonly<BasicEffect> {
|
|
readonly effectType: 'Ability';
|
|
|
|
/** Rating from -1 Detrimental to +5 Essential; see `data/abilities.ts` for details. */
|
|
readonly rating: number;
|
|
readonly suppressWeather: boolean;
|
|
readonly condition?: Partial<ConditionData>;
|
|
readonly isPermanent?: boolean;
|
|
readonly isUnbreakable?: boolean;
|
|
|
|
constructor(data: AnyObject, ...moreData: (AnyObject | null)[]) {
|
|
super(data, ...moreData);
|
|
data = this;
|
|
|
|
this.fullname = `ability: ${this.name}`;
|
|
this.effectType = 'Ability';
|
|
this.suppressWeather = !!data.suppressWeather;
|
|
this.rating = data.rating || 0;
|
|
|
|
if (!this.gen) {
|
|
if (this.num >= 234) {
|
|
this.gen = 8;
|
|
} else if (this.num >= 192) {
|
|
this.gen = 7;
|
|
} else if (this.num >= 165) {
|
|
this.gen = 6;
|
|
} else if (this.num >= 124) {
|
|
this.gen = 5;
|
|
} else if (this.num >= 77) {
|
|
this.gen = 4;
|
|
} else if (this.num >= 1) {
|
|
this.gen = 3;
|
|
}
|
|
}
|
|
}
|
|
}
|