Jofthomas's picture
Jofthomas HF staff
Upload 4781 files
5c2ed06 verified
{
"version": 3,
"sources": ["../../../../data/mods/gen2stadium2/scripts.ts"],
"sourcesContent": ["/**\n * Stadium 2 mechanics inherit from gen 2 mechanics, but fixes some bugs.\n */\nexport const Scripts: ModdedBattleScriptsData = {\n\tinherit: 'gen2',\n\tgen: 2,\n\tpokemon: {\n\t\tinherit: true,\n\t\tgetStat(statName, unboosted, unmodified, fastReturn) {\n\t\t\t// @ts-expect-error type checking prevents 'hp' from being passed, but we're paranoid\n\t\t\tif (statName === 'hp') throw new Error(\"Please read `maxhp` directly\");\n\n\t\t\t// base stat\n\t\t\tlet stat = this.storedStats[statName];\n\n\t\t\t// Stat boosts.\n\t\t\tif (!unboosted) {\n\t\t\t\tlet boost = this.boosts[statName];\n\t\t\t\tif (boost > 6) boost = 6;\n\t\t\t\tif (boost < -6) boost = -6;\n\t\t\t\tif (boost >= 0) {\n\t\t\t\t\tconst boostTable = [1, 1.5, 2, 2.5, 3, 3.5, 4];\n\t\t\t\t\tstat = Math.floor(stat * boostTable[boost]);\n\t\t\t\t} else {\n\t\t\t\t\tconst numerators = [100, 66, 50, 40, 33, 28, 25];\n\t\t\t\t\tstat = Math.floor(stat * numerators[-boost] / 100);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this.status === 'par' && statName === 'spe' && this.volatiles['parspeeddrop']) {\n\t\t\t\tstat = Math.floor(stat / 4);\n\t\t\t}\n\t\t\tif (!unmodified) {\n\t\t\t\tif (this.status === 'brn' && statName === 'atk' && this.volatiles['brnattackdrop']) {\n\t\t\t\t\tstat = Math.floor(stat / 2);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Gen 2 caps stats at 999 and min is 1.\n\t\t\tstat = this.battle.clampIntRange(stat, 1, 999);\n\t\t\tif (fastReturn) return stat;\n\n\t\t\t// Screens\n\t\t\tif (!unboosted) {\n\t\t\t\tif (\n\t\t\t\t\t(statName === 'def' && this.side.sideConditions['reflect']) ||\n\t\t\t\t\t(statName === 'spd' && this.side.sideConditions['lightscreen'])\n\t\t\t\t) {\n\t\t\t\t\tstat *= 2;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Handle boosting items\n\t\t\tif (\n\t\t\t\t(['Cubone', 'Marowak'].includes(this.species.name) && this.item === 'thickclub' && statName === 'atk') ||\n\t\t\t\t(this.species.name === 'Pikachu' && this.item === 'lightball' && statName === 'spa')\n\t\t\t) {\n\t\t\t\tstat *= 2;\n\t\t\t} else if (this.species.name === 'Ditto' && this.item === 'metalpowder' && ['def', 'spd'].includes(statName)) {\n\t\t\t\tstat = Math.floor(stat * 1.5);\n\t\t\t}\n\n\t\t\treturn stat;\n\t\t},\n\t},\n\t// Stadium 2 shares gen 2 code but it fixes some problems with it.\n\tactions: {\n\t\tinherit: true,\n\t\ttryMoveHit(target, pokemon, move) {\n\t\t\tconst positiveBoostTable = [1, 1.33, 1.66, 2, 2.33, 2.66, 3];\n\t\t\tconst negativeBoostTable = [1, 0.75, 0.6, 0.5, 0.43, 0.36, 0.33];\n\t\t\tconst doSelfDestruct = true;\n\t\t\tlet damage: number | false | undefined = 0;\n\n\t\t\tif (move.selfdestruct && doSelfDestruct) {\n\t\t\t\tthis.battle.faint(pokemon, pokemon, move);\n\t\t\t\t/**\n\t\t\t\t * Keeping track of the last move used for self-ko clause,\n\t\t\t\t * making sure to clear the opponents last move so that self-destruct and explosion\n\t\t\t\t * does not persist between Pokemon, preventing problems caused by situations,\n\t\t\t\t * such as a player from blowing up both they and their opponents second last Pokemon\n\t\t\t\t * and their opponent blowing up their last Pokemon. If we did not clear here, there would be a problem.\n\t\t\t\t */\n\t\t\t\ttarget.side.lastMove = null;\n\t\t\t\tpokemon.side.lastMove = move;\n\t\t\t}\n\n\t\t\tlet hitResult = this.battle.singleEvent('PrepareHit', move, {}, target, pokemon, move);\n\t\t\tif (!hitResult) {\n\t\t\t\tif (hitResult === false) this.battle.add('-fail', target);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tthis.battle.runEvent('PrepareHit', pokemon, target, move);\n\n\t\t\tif (!this.battle.singleEvent('Try', move, null, pokemon, target, move)) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tif (move.target === 'all' || move.target === 'foeSide' || move.target === 'allySide' || move.target === 'allyTeam') {\n\t\t\t\tif (move.target === 'all') {\n\t\t\t\t\thitResult = this.battle.runEvent('TryHitField', target, pokemon, move);\n\t\t\t\t} else {\n\t\t\t\t\thitResult = this.battle.runEvent('TryHitSide', target, pokemon, move);\n\t\t\t\t}\n\t\t\t\tif (!hitResult) {\n\t\t\t\t\tif (hitResult === false) {\n\t\t\t\t\t\tthis.battle.add('-fail', pokemon);\n\t\t\t\t\t\tthis.battle.attrLastMove('[still]');\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\treturn this.moveHit(target, pokemon, move);\n\t\t\t}\n\n\t\t\thitResult = this.battle.runEvent('Invulnerability', target, pokemon, move);\n\t\t\tif (hitResult === false) {\n\t\t\t\tthis.battle.attrLastMove('[miss]');\n\t\t\t\tthis.battle.add('-miss', pokemon);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tif (move.ignoreImmunity === undefined) {\n\t\t\t\tmove.ignoreImmunity = (move.category === 'Status');\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t(!move.ignoreImmunity || (move.ignoreImmunity !== true && !move.ignoreImmunity[move.type])) &&\n\t\t\t\t!target.runImmunity(move.type, true)\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\thitResult = this.battle.singleEvent('TryImmunity', move, {}, target, pokemon, move);\n\t\t\tif (hitResult === false) {\n\t\t\t\tthis.battle.add('-immune', target);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\thitResult = this.battle.runEvent('TryHit', target, pokemon, move);\n\t\t\tif (!hitResult) {\n\t\t\t\tif (hitResult === false) this.battle.add('-fail', target);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tlet accuracy = move.accuracy;\n\t\t\tif (move.alwaysHit) {\n\t\t\t\taccuracy = true;\n\t\t\t} else {\n\t\t\t\taccuracy = this.battle.runEvent('Accuracy', target, pokemon, move, accuracy);\n\t\t\t}\n\t\t\t// Now, let's calculate the accuracy.\n\t\t\tif (accuracy !== true) {\n\t\t\t\taccuracy = Math.floor(accuracy * 255 / 100);\n\t\t\t\tif (move.ohko) {\n\t\t\t\t\tif (pokemon.level >= target.level) {\n\t\t\t\t\t\taccuracy += (pokemon.level - target.level) * 2;\n\t\t\t\t\t\taccuracy = Math.min(accuracy, 255);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.battle.add('-immune', target, '[ohko]');\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!move.ignoreAccuracy) {\n\t\t\t\t\tif (pokemon.boosts.accuracy > 0) {\n\t\t\t\t\t\taccuracy *= positiveBoostTable[pokemon.boosts.accuracy];\n\t\t\t\t\t} else {\n\t\t\t\t\t\taccuracy *= negativeBoostTable[-pokemon.boosts.accuracy];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!move.ignoreEvasion) {\n\t\t\t\t\tif (target.boosts.evasion > 0 && !move.ignorePositiveEvasion) {\n\t\t\t\t\t\taccuracy *= negativeBoostTable[target.boosts.evasion];\n\t\t\t\t\t} else if (target.boosts.evasion < 0) {\n\t\t\t\t\t\taccuracy *= positiveBoostTable[-target.boosts.evasion];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\taccuracy = Math.min(Math.floor(accuracy), 255);\n\t\t\t\taccuracy = Math.max(accuracy, 1);\n\t\t\t} else {\n\t\t\t\taccuracy = this.battle.runEvent('Accuracy', target, pokemon, move, accuracy);\n\t\t\t}\n\t\t\taccuracy = this.battle.runEvent('ModifyAccuracy', target, pokemon, move, accuracy);\n\t\t\tif (accuracy !== true) accuracy = Math.max(accuracy, 0);\n\t\t\tif (move.alwaysHit) {\n\t\t\t\taccuracy = true;\n\t\t\t} else {\n\t\t\t\taccuracy = this.battle.runEvent('Accuracy', target, pokemon, move, accuracy);\n\t\t\t}\n\t\t\tif (accuracy !== true && accuracy !== 255 && !this.battle.randomChance(accuracy, 256)) {\n\t\t\t\tthis.battle.attrLastMove('[miss]');\n\t\t\t\tthis.battle.add('-miss', pokemon);\n\t\t\t\tdamage = false;\n\t\t\t\treturn damage;\n\t\t\t}\n\t\t\tmove.totalDamage = 0;\n\t\t\tpokemon.lastDamage = 0;\n\t\t\tif (move.multihit) {\n\t\t\t\tlet hits = move.multihit;\n\t\t\t\tif (Array.isArray(hits)) {\n\t\t\t\t\tif (hits[0] === 2 && hits[1] === 5) {\n\t\t\t\t\t\thits = this.battle.sample([2, 2, 2, 3, 3, 3, 4, 5]);\n\t\t\t\t\t} else {\n\t\t\t\t\t\thits = this.battle.random(hits[0], hits[1] + 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\thits = Math.floor(hits);\n\t\t\t\tlet nullDamage = true;\n\t\t\t\tlet moveDamage: number | undefined | false;\n\n\t\t\t\tconst isSleepUsable = move.sleepUsable || this.dex.moves.get(move.sourceEffect).sleepUsable;\n\t\t\t\tlet i: number;\n\t\t\t\tfor (i = 0; i < hits && target.hp && pokemon.hp; i++) {\n\t\t\t\t\tif (pokemon.status === 'slp' && !isSleepUsable) break;\n\t\t\t\t\tmove.hit = i + 1;\n\t\t\t\t\tif (move.hit === hits) move.lastHit = true;\n\t\t\t\t\tmoveDamage = this.moveHit(target, pokemon, move);\n\t\t\t\t\tif (moveDamage === false) break;\n\t\t\t\t\tif (nullDamage && (moveDamage || moveDamage === 0 || moveDamage === undefined)) nullDamage = false;\n\t\t\t\t\tdamage = (moveDamage || 0);\n\t\t\t\t\tmove.totalDamage += damage;\n\t\t\t\t\tthis.battle.eachEvent('Update');\n\t\t\t\t}\n\t\t\t\tif (i === 0) return 1;\n\t\t\t\tif (nullDamage) damage = false;\n\t\t\t\tthis.battle.add('-hitcount', target, i);\n\t\t\t} else {\n\t\t\t\tdamage = this.moveHit(target, pokemon, move);\n\t\t\t\tmove.totalDamage = damage;\n\t\t\t}\n\t\t\tif (move.category !== 'Status') {\n\t\t\t\ttarget.gotAttacked(move, damage, pokemon);\n\t\t\t}\n\t\t\tif (move.ohko) this.battle.add('-ohko');\n\n\t\t\tif (!move.negateSecondary) {\n\t\t\t\tthis.battle.singleEvent('AfterMoveSecondary', move, null, target, pokemon, move);\n\t\t\t\tthis.battle.runEvent('AfterMoveSecondary', target, pokemon, move);\n\t\t\t}\n\t\t\t// Implementing Recoil mechanics from Stadium 2.\n\t\t\t// If a pokemon caused the other to faint with a recoil move and only one pokemon remains on both sides,\n\t\t\t// recoil damage will not be taken.\n\t\t\tif (move.recoil && move.totalDamage && (pokemon.side.pokemonLeft > 1 || target.side.pokemonLeft > 1 || target.hp)) {\n\t\t\t\tthis.battle.damage(this.calcRecoilDamage(move.totalDamage, move, pokemon), pokemon, target, 'recoil');\n\t\t\t}\n\t\t\treturn damage;\n\t\t},\n\t\tgetDamage(source, target, move, suppressMessages) {\n\t\t\t// First of all, we get the move.\n\t\t\tif (typeof move === 'string') {\n\t\t\t\tmove = this.dex.getActiveMove(move);\n\t\t\t} else if (typeof move === 'number') {\n\t\t\t\tmove = {\n\t\t\t\t\tbasePower: move,\n\t\t\t\t\ttype: '???',\n\t\t\t\t\tcategory: 'Physical',\n\t\t\t\t\twillCrit: false,\n\t\t\t\t\tflags: {},\n\t\t\t\t} as unknown as ActiveMove;\n\t\t\t}\n\n\t\t\t// Let's test for immunities.\n\t\t\tif (!move.ignoreImmunity || (move.ignoreImmunity !== true && !move.ignoreImmunity[move.type])) {\n\t\t\t\tif (!target.runImmunity(move.type, true)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Is it an OHKO move?\n\t\t\tif (move.ohko) {\n\t\t\t\treturn target.maxhp;\n\t\t\t}\n\n\t\t\t// We edit the damage through move's damage callback\n\t\t\tif (move.damageCallback) {\n\t\t\t\treturn move.damageCallback.call(this.battle, source, target);\n\t\t\t}\n\n\t\t\t// We take damage from damage=level moves\n\t\t\tif (move.damage === 'level') {\n\t\t\t\treturn source.level;\n\t\t\t}\n\n\t\t\t// If there's a fix move damage, we run it\n\t\t\tif (move.damage) {\n\t\t\t\treturn move.damage;\n\t\t\t}\n\n\t\t\t// We check the category and typing to calculate later on the damage\n\t\t\tmove.category = this.battle.getCategory(move);\n\t\t\t// '???' is typeless damage: used for Struggle and Confusion etc\n\t\t\tif (!move.type) move.type = '???';\n\t\t\tconst type = move.type;\n\n\t\t\t// We get the base power and apply basePowerCallback if necessary\n\t\t\tlet basePower: number | false | null | undefined = move.basePower;\n\t\t\tif (move.basePowerCallback) {\n\t\t\t\tbasePower = move.basePowerCallback.call(this.battle, source, target, move);\n\t\t\t}\n\n\t\t\t// We check for Base Power\n\t\t\tif (!basePower) {\n\t\t\t\tif (basePower === 0) return; // Returning undefined means not dealing damage\n\t\t\t\treturn basePower;\n\t\t\t}\n\t\t\tbasePower = this.battle.clampIntRange(basePower, 1);\n\n\t\t\t// Checking for the move's Critical Hit ratio\n\t\t\tlet critRatio = this.battle.runEvent('ModifyCritRatio', source, target, move, move.critRatio || 0);\n\t\t\tcritRatio = this.battle.clampIntRange(critRatio, 0, 5);\n\t\t\tconst critMult = [0, 16, 8, 4, 3, 2];\n\t\t\tlet isCrit = move.willCrit || false;\n\t\t\tif (typeof move.willCrit === 'undefined') {\n\t\t\t\tif (critRatio) {\n\t\t\t\t\tisCrit = this.battle.randomChance(1, critMult[critRatio]);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (isCrit && this.battle.runEvent('CriticalHit', target, null, move)) {\n\t\t\t\ttarget.getMoveHitData(move).crit = true;\n\t\t\t}\n\n\t\t\t// Happens after crit calculation\n\t\t\tif (basePower) {\n\t\t\t\t// confusion damage\n\t\t\t\tif (move.isConfusionSelfHit) {\n\t\t\t\t\tmove.type = move.baseMoveType!;\n\t\t\t\t\tbasePower = this.battle.runEvent('BasePower', source, target, move, basePower, true);\n\t\t\t\t\tmove.type = '???';\n\t\t\t\t} else {\n\t\t\t\t\tbasePower = this.battle.runEvent('BasePower', source, target, move, basePower, true);\n\t\t\t\t}\n\t\t\t\tif (basePower && move.basePowerModifier) {\n\t\t\t\t\tbasePower *= move.basePowerModifier;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!basePower) return 0;\n\t\t\tbasePower = this.battle.clampIntRange(basePower, 1);\n\n\t\t\t// We now check for attacker and defender\n\t\t\tlet level = source.level;\n\n\t\t\t// Using Beat Up\n\t\t\tif (move.allies) {\n\t\t\t\tthis.battle.add('-activate', source, 'move: Beat Up', '[of] ' + move.allies[0].name);\n\t\t\t\tlevel = move.allies[0].level;\n\t\t\t}\n\n\t\t\tconst attacker = move.overrideOffensivePokemon === 'target' ? target : source;\n\t\t\tconst defender = move.overrideDefensivePokemon === 'source' ? source : target;\n\n\t\t\tconst isPhysical = move.category === 'Physical';\n\t\t\tconst atkType: StatIDExceptHP = move.overrideOffensiveStat || (isPhysical ? 'atk' : 'spa');\n\t\t\tconst defType: StatIDExceptHP = move.overrideDefensiveStat || (isPhysical ? 'def' : 'spd');\n\n\t\t\tlet unboosted = false;\n\t\t\tlet noburndrop = false;\n\n\t\t\tif (isCrit) {\n\t\t\t\tif (!suppressMessages) this.battle.add('-crit', target);\n\t\t\t\t// Stat level modifications are ignored if they are neutral to or favour the defender.\n\t\t\t\t// Reflect and Light Screen defensive boosts are only ignored if stat level modifications were also ignored as a result of that.\n\t\t\t\tif (attacker.boosts[atkType] <= defender.boosts[defType]) {\n\t\t\t\t\tunboosted = true;\n\t\t\t\t\tnoburndrop = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet attack = attacker.getStat(atkType, unboosted, noburndrop);\n\t\t\tlet defense = defender.getStat(defType, unboosted);\n\n\t\t\t// Using Beat Up\n\t\t\tif (move.allies) {\n\t\t\t\tattack = move.allies[0].species.baseStats.atk;\n\t\t\t\tmove.allies.shift();\n\t\t\t\tdefense = defender.species.baseStats.def;\n\t\t\t}\n\n\t\t\t// Moves that ignore offense and defense respectively.\n\t\t\tif (move.ignoreOffensive) {\n\t\t\t\tthis.battle.debug('Negating (sp)atk boost/penalty.');\n\t\t\t\t// The attack drop from the burn is only applied when attacker's attack level is higher than defender's defense level.\n\t\t\t\tattack = attacker.getStat(atkType, true, true);\n\t\t\t}\n\n\t\t\tif (move.ignoreDefensive) {\n\t\t\t\tthis.battle.debug('Negating (sp)def boost/penalty.');\n\t\t\t\tdefense = target.getStat(defType, true, true);\n\t\t\t}\n\n\t\t\tif (attack >= 256 || defense >= 256) {\n\t\t\t\tattack = this.battle.clampIntRange(Math.floor(this.battle.clampIntRange(attack, 1, 999) / 4), 1);\n\t\t\t\tdefense = this.battle.clampIntRange(Math.floor(this.battle.clampIntRange(defense, 1, 999) / 4), 1);\n\t\t\t}\n\n\t\t\t// Self destruct moves halve defense at this point.\n\t\t\tif (move.selfdestruct && defType === 'def') {\n\t\t\t\tdefense = this.battle.clampIntRange(Math.floor(defense / 2), 1);\n\t\t\t}\n\n\t\t\t// Let's go with the calculation now that we have what we need.\n\t\t\t// We do it step by step just like the game does.\n\t\t\tlet damage = level * 2;\n\t\t\tdamage = Math.floor(damage / 5);\n\t\t\tdamage += 2;\n\t\t\tdamage *= basePower;\n\t\t\tdamage *= attack;\n\t\t\tdamage = Math.floor(damage / defense);\n\t\t\tdamage = Math.floor(damage / 50);\n\t\t\tif (isCrit) damage *= 2;\n\t\t\tdamage = Math.floor(this.battle.runEvent('ModifyDamage', attacker, defender, move, damage));\n\t\t\tdamage = this.battle.clampIntRange(damage, 1, 997);\n\t\t\tdamage += 2;\n\n\t\t\t// Weather modifiers\n\t\t\tif (\n\t\t\t\t(type === 'Water' && this.battle.field.isWeather('raindance')) ||\n\t\t\t\t(type === 'Fire' && this.battle.field.isWeather('sunnyday'))\n\t\t\t) {\n\t\t\t\tdamage = Math.floor(damage * 1.5);\n\t\t\t} else if (\n\t\t\t\t((type === 'Fire' || move.id === 'solarbeam') && this.battle.field.isWeather('raindance')) ||\n\t\t\t\t(type === 'Water' && this.battle.field.isWeather('sunnyday'))\n\t\t\t) {\n\t\t\t\tdamage = Math.floor(damage / 2);\n\t\t\t}\n\n\t\t\t// STAB damage bonus, the \"???\" type never gets STAB\n\t\t\tif (type !== '???' && source.hasType(type)) {\n\t\t\t\tdamage += Math.floor(damage / 2);\n\t\t\t}\n\n\t\t\t// Type effectiveness\n\t\t\tconst totalTypeMod = target.runEffectiveness(move);\n\t\t\t// Super effective attack\n\t\t\tif (totalTypeMod > 0) {\n\t\t\t\tif (!suppressMessages) this.battle.add('-supereffective', target);\n\t\t\t\tdamage *= 2;\n\t\t\t\tif (totalTypeMod >= 2) {\n\t\t\t\t\tdamage *= 2;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Resisted attack\n\t\t\tif (totalTypeMod < 0) {\n\t\t\t\tif (!suppressMessages) this.battle.add('-resisted', target);\n\t\t\t\tdamage = Math.floor(damage / 2);\n\t\t\t\tif (totalTypeMod <= -2) {\n\t\t\t\t\tdamage = Math.floor(damage / 2);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Apply random factor if damage is greater than 1, except for Flail and Reversal\n\t\t\tif (!move.noDamageVariance && damage > 1) {\n\t\t\t\tdamage *= this.battle.random(217, 256);\n\t\t\t\tdamage = Math.floor(damage / 255);\n\t\t\t}\n\n\t\t\t// If damage is less than 1, we return 1\n\t\t\tif (basePower && !Math.floor(damage)) {\n\t\t\t\treturn 1;\n\t\t\t}\n\n\t\t\t// We are done, this is the final damage\n\t\t\treturn damage;\n\t\t},\n\t},\n\t/**\n\t * Stadium 2 ignores stat drops due to status ailments upon boosting the dropped stat.\n\t * For example: if a burned Snorlax uses Curse then it will ignore the attack drop from\n\t * burn when it is recalculating its attack stat. This is why volatiles are added to status\n\t * conditions, so that we can keep track of whether or not to apply the stat drop from\n\t * statuses.\n\t */\n\tboost(boost, target, source = null, effect = null) {\n\t\tif (this.event) {\n\t\t\tif (!target) target = this.event.target;\n\t\t\tif (!source) source = this.event.source;\n\t\t\tif (!effect) effect = this.effect;\n\t\t}\n\t\tif (typeof effect === 'string') effect = this.dex.conditions.get(effect);\n\t\tif (!target?.hp) return 0;\n\t\tlet success = null;\n\t\tboost = this.runEvent('TryBoost', target, source, effect, { ...boost });\n\t\tlet i: BoostID;\n\t\tfor (i in boost) {\n\t\t\tconst currentBoost: SparseBoostsTable = {};\n\t\t\tcurrentBoost[i] = boost[i];\n\t\t\tlet boostBy = target.boostBy(currentBoost);\n\t\t\tlet msg = '-boost';\n\t\t\tif (boost[i]! < 0) {\n\t\t\t\tmsg = '-unboost';\n\t\t\t\tboostBy = -boostBy;\n\t\t\t}\n\t\t\tif (boostBy) {\n\t\t\t\tsuccess = true;\n\t\t\t\t// Check for boost increases deleting attack or speed drops\n\t\t\t\tif (i === 'atk' && target.status === 'brn' && target.volatiles['brnattackdrop']) {\n\t\t\t\t\ttarget.removeVolatile('brnattackdrop');\n\t\t\t\t}\n\t\t\t\tif (i === 'spe' && target.status === 'par' && target.volatiles['parspeeddrop']) {\n\t\t\t\t\ttarget.removeVolatile('parspeeddrop');\n\t\t\t\t}\n\t\t\t\tif (!effect || effect.effectType === 'Move') {\n\t\t\t\t\tthis.add(msg, target, i, boostBy);\n\t\t\t\t} else {\n\t\t\t\t\tthis.add(msg, target, i, boostBy, '[from] ' + effect.fullname);\n\t\t\t\t}\n\t\t\t\tthis.runEvent('AfterEachBoost', target, source, effect, currentBoost);\n\t\t\t}\n\t\t}\n\t\tthis.runEvent('AfterBoost', target, source, effect, boost);\n\t\treturn success;\n\t},\n\t/**\n\t * Implementing Self-KO Clause by having it check what the last move used by the players were\n\t * in the case both Pokemon faint. Since the only way this can happen in Stadium 2 is if a player\n\t * uses self-destruct or explosion, I can use this to determine who should win.\n\t */\n\tfaintMessages(lastFirst) {\n\t\tif (this.ended) return;\n\t\tconst length = this.faintQueue.length;\n\t\tif (!length) return false;\n\t\tif (lastFirst) {\n\t\t\tthis.faintQueue.unshift(this.faintQueue[this.faintQueue.length - 1]);\n\t\t\tthis.faintQueue.pop();\n\t\t}\n\t\tlet faintData;\n\t\twhile (this.faintQueue.length) {\n\t\t\tfaintData = this.faintQueue.shift()!;\n\t\t\tconst pokemon: Pokemon = faintData.target;\n\t\t\tif (!pokemon.fainted &&\n\t\t\t\tthis.runEvent('BeforeFaint', pokemon, faintData.source, faintData.effect)) {\n\t\t\t\tthis.add('faint', pokemon);\n\t\t\t\tpokemon.side.pokemonLeft--;\n\t\t\t\tif (pokemon.side.totalFainted < 100) pokemon.side.totalFainted++;\n\t\t\t\tthis.runEvent('Faint', pokemon, faintData.source, faintData.effect);\n\t\t\t\tthis.singleEvent('End', pokemon.getAbility(), pokemon.abilityState, pokemon);\n\t\t\t\tpokemon.clearVolatile(false);\n\t\t\t\tpokemon.fainted = true;\n\t\t\t\tpokemon.isActive = false;\n\t\t\t\tpokemon.isStarted = false;\n\t\t\t\tpokemon.side.faintedThisTurn = pokemon;\n\t\t\t}\n\t\t}\n\n\t\tif (this.gen <= 1) {\n\t\t\t// in gen 1, fainting skips the rest of the turn\n\t\t\t// residuals don't exist in gen 1\n\t\t\tthis.queue.clear();\n\t\t\t// Fainting clears accumulated Bide damage\n\t\t\tfor (const pokemon of this.getAllActive()) {\n\t\t\t\tif (pokemon.volatiles['bide']?.damage) {\n\t\t\t\t\tpokemon.volatiles['bide'].damage = 0;\n\t\t\t\t\tthis.hint(\"Desync Clause Mod activated!\");\n\t\t\t\t\tthis.hint(\"In Gen 1, Bide's accumulated damage is reset to 0 when a Pokemon faints.\");\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (this.gen <= 3 && this.gameType === 'singles') {\n\t\t\t// in gen 3 or earlier, fainting in singles skips to residuals\n\t\t\tfor (const pokemon of this.getAllActive()) {\n\t\t\t\tif (this.gen <= 2) {\n\t\t\t\t\t// in gen 2, fainting skips moves only\n\t\t\t\t\tthis.queue.cancelMove(pokemon);\n\t\t\t\t} else {\n\t\t\t\t\t// in gen 3, fainting skips all moves and switches\n\t\t\t\t\tthis.queue.cancelAction(pokemon);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (!this.p1.pokemonLeft && !this.p2.pokemonLeft) {\n\t\t\tif (this.p1.lastMove !== null && this.p2.lastMove === null) {\n\t\t\t\tthis.win(this.p2);\n\t\t\t\treturn true;\n\t\t\t} else if (this.p2.lastMove !== null && this.p1.lastMove === null) {\n\t\t\t\tthis.win(this.p1);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tthis.win(faintData ? faintData.target.side.foe : null);\n\t\t\treturn true;\n\t\t}\n\t\tif (!this.p1.pokemonLeft) {\n\t\t\tthis.win(this.p2);\n\t\t\treturn true;\n\t\t}\n\t\tif (!this.p2.pokemonLeft) {\n\t\t\tthis.win(this.p1);\n\t\t\treturn true;\n\t\t}\n\t\tif (faintData) {\n\t\t\tthis.runEvent('AfterFaint', faintData.target, faintData.source, faintData.effect, length);\n\t\t}\n\t\treturn false;\n\t},\n};\n"],
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,UAAmC;AAAA,EAC/C,SAAS;AAAA,EACT,KAAK;AAAA,EACL,SAAS;AAAA,IACR,SAAS;AAAA,IACT,QAAQ,UAAU,WAAW,YAAY,YAAY;AAEpD,UAAI,aAAa;AAAM,cAAM,IAAI,MAAM,8BAA8B;AAGrE,UAAI,OAAO,KAAK,YAAY,QAAQ;AAGpC,UAAI,CAAC,WAAW;AACf,YAAI,QAAQ,KAAK,OAAO,QAAQ;AAChC,YAAI,QAAQ;AAAG,kBAAQ;AACvB,YAAI,QAAQ;AAAI,kBAAQ;AACxB,YAAI,SAAS,GAAG;AACf,gBAAM,aAAa,CAAC,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAC7C,iBAAO,KAAK,MAAM,OAAO,WAAW,KAAK,CAAC;AAAA,QAC3C,OAAO;AAC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