{ "version": 3, "sources": ["../../sim/dex-abilities.ts"], "sourcesContent": ["import type { PokemonEventMethods, ConditionData } from './dex-conditions';\nimport { assignMissingFields, BasicEffect, toID } from './dex-data';\nimport { Utils } from '../lib/utils';\n\ninterface AbilityEventMethods {\n\tonCheckShow?: (this: Battle, pokemon: Pokemon) => void;\n\tonEnd?: (this: Battle, target: Pokemon & Side & Field) => void;\n\tonStart?: (this: Battle, target: Pokemon) => void;\n}\n\n/* Possible Ability flags */\ninterface AbilityFlags {\n\tbreakable?: 1; // Can be suppressed by Mold Breaker and related effects\n\tcantsuppress?: 1; // Ability can't be suppressed by e.g. Gastro Acid or Neutralizing Gas\n\tfailroleplay?: 1; // Role Play fails if target has this Ability\n\tfailskillswap?: 1; // Skill Swap fails if either the user or target has this Ability\n\tnoentrain?: 1; // Entrainment fails if user has this Ability\n\tnoreceiver?: 1; // Receiver and Power of Alchemy will not activate if an ally faints with this Ability\n\tnotrace?: 1; // Trace cannot copy this Ability\n\tnotransform?: 1; // Disables the Ability if the user is Transformed\n}\n\nexport interface AbilityData extends Partial, AbilityEventMethods, PokemonEventMethods {\n\tname: string;\n}\n\nexport type ModdedAbilityData = AbilityData | Partial & { inherit: true };\nexport interface AbilityDataTable { [abilityid: IDEntry]: AbilityData }\nexport interface ModdedAbilityDataTable { [abilityid: IDEntry]: ModdedAbilityData }\n\nexport class Ability extends BasicEffect implements Readonly {\n\tdeclare readonly effectType: 'Ability';\n\n\t/** Rating from -1 Detrimental to +5 Essential; see `data/abilities.ts` for details. */\n\treadonly rating: number;\n\treadonly suppressWeather: boolean;\n\treadonly flags: AbilityFlags;\n\tdeclare readonly condition?: ConditionData;\n\n\tconstructor(data: AnyObject) {\n\t\tsuper(data);\n\n\t\tthis.fullname = `ability: ${this.name}`;\n\t\tthis.effectType = 'Ability';\n\t\tthis.suppressWeather = !!data.suppressWeather;\n\t\tthis.flags = data.flags || {};\n\t\tthis.rating = data.rating || 0;\n\n\t\tif (!this.gen) {\n\t\t\tif (this.num >= 268) {\n\t\t\t\tthis.gen = 9;\n\t\t\t} else if (this.num >= 234) {\n\t\t\t\tthis.gen = 8;\n\t\t\t} else if (this.num >= 192) {\n\t\t\t\tthis.gen = 7;\n\t\t\t} else if (this.num >= 165) {\n\t\t\t\tthis.gen = 6;\n\t\t\t} else if (this.num >= 124) {\n\t\t\t\tthis.gen = 5;\n\t\t\t} else if (this.num >= 77) {\n\t\t\t\tthis.gen = 4;\n\t\t\t} else if (this.num >= 1) {\n\t\t\t\tthis.gen = 3;\n\t\t\t}\n\t\t}\n\t\tassignMissingFields(this, data);\n\t}\n}\n\nconst EMPTY_ABILITY = Utils.deepFreeze(new Ability({ id: '', name: '', exists: false }));\n\nexport class DexAbilities {\n\treadonly dex: ModdedDex;\n\treadonly abilityCache = new Map();\n\tallCache: readonly Ability[] | null = null;\n\n\tconstructor(dex: ModdedDex) {\n\t\tthis.dex = dex;\n\t}\n\n\tget(name: string | Ability = ''): Ability {\n\t\tif (name && typeof name !== 'string') return name;\n\t\tconst id = toID(name.trim());\n\t\treturn this.getByID(id);\n\t}\n\n\tgetByID(id: ID): Ability {\n\t\tif (id === '') return EMPTY_ABILITY;\n\t\tlet ability = this.abilityCache.get(id);\n\t\tif (ability) return ability;\n\n\t\tif (this.dex.data.Aliases.hasOwnProperty(id)) {\n\t\t\tability = this.get(this.dex.data.Aliases[id]);\n\t\t} else if (id && this.dex.data.Abilities.hasOwnProperty(id)) {\n\t\t\tconst abilityData = this.dex.data.Abilities[id] as any;\n\t\t\tconst abilityTextData = this.dex.getDescs('Abilities', id, abilityData);\n\t\t\tability = new Ability({\n\t\t\t\tname: id,\n\t\t\t\t...abilityData,\n\t\t\t\t...abilityTextData,\n\t\t\t});\n\t\t\tif (ability.gen > this.dex.gen) {\n\t\t\t\t(ability as any).isNonstandard = 'Future';\n\t\t\t}\n\t\t\tif (this.dex.currentMod === 'gen7letsgo' && ability.id !== 'noability') {\n\t\t\t\t(ability as any).isNonstandard = 'Past';\n\t\t\t}\n\t\t\tif ((this.dex.currentMod === 'gen7letsgo' || this.dex.gen <= 2) && ability.id === 'noability') {\n\t\t\t\t(ability as any).isNonstandard = null;\n\t\t\t}\n\t\t} else {\n\t\t\tability = new Ability({\n\t\t\t\tid, name: id, exists: false,\n\t\t\t});\n\t\t}\n\n\t\tif (ability.exists) this.abilityCache.set(id, this.dex.deepFreeze(ability));\n\t\treturn ability;\n\t}\n\n\tall(): readonly Ability[] {\n\t\tif (this.allCache) return this.allCache;\n\t\tconst abilities = [];\n\t\tfor (const id in this.dex.data.Abilities) {\n\t\t\tabilities.push(this.getByID(id as ID));\n\t\t}\n\t\tthis.allCache = abilities;\n\t\treturn this.allCache;\n\t}\n}\n"], "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAuD;AACvD,mBAAsB;AA4Bf,MAAM,gBAAgB,4BAA6C;AAAA,EASzE,YAAY,MAAiB;AAC5B,UAAM,IAAI;AAEV,SAAK,WAAW,YAAY,KAAK;AACjC,SAAK,aAAa;AAClB,SAAK,kBAAkB,CAAC,CAAC,KAAK;AAC9B,SAAK,QAAQ,KAAK,SAAS,CAAC;AAC5B,SAAK,SAAS,KAAK,UAAU;AAE7B,QAAI,CAAC,KAAK,KAAK;AACd,UAAI,KAAK,OAAO,KAAK;AACpB,aAAK,MAAM;AAAA,MACZ,WAAW,KAAK,OAAO,KAAK;AAC3B,aAAK,MAAM;AAAA,MACZ,WAAW,KAAK,OAAO,KAAK;AAC3B,aAAK,MAAM;AAAA,MACZ,WAAW,KAAK,OAAO,KAAK;AAC3B,aAAK,MAAM;AAAA,MACZ,WAAW,KAAK,OAAO,KAAK;AAC3B,aAAK,MAAM;AAAA,MACZ,WAAW,KAAK,OAAO,IAAI;AAC1B,aAAK,MAAM;AAAA,MACZ,WAAW,KAAK,OAAO,GAAG;AACzB,aAAK,MAAM;AAAA,MACZ;AAAA,IACD;AACA,6CAAoB,MAAM,IAAI;AAAA,EAC/B;A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