From d809ba06d60965afae7e58394f7a31ea8a9e9c19 Mon Sep 17 00:00:00 2001 From: Shriansh Chari <30420527+shrianshChari@users.noreply.github.com> Date: Mon, 21 Oct 2024 20:46:28 -0400 Subject: [PATCH 1/3] Add support for Steely Spirit in npm package --- calc/src/desc.ts | 4 ++++ calc/src/field.ts | 2 ++ calc/src/mechanics/gen789.ts | 8 ++++++++ calc/src/state.ts | 1 + calc/src/test/calc.test.ts | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 47 insertions(+) diff --git a/calc/src/desc.ts b/calc/src/desc.ts index 504314c61..bd8be6859 100644 --- a/calc/src/desc.ts +++ b/calc/src/desc.ts @@ -31,6 +31,7 @@ export interface RawDesc { isAuroraVeil?: boolean; isFlowerGiftAttacker?: boolean; isFlowerGiftDefender?: boolean; + isSteelySpiritAttacker?: boolean; isFriendGuard?: boolean; isHelpingHand?: boolean; isCritical?: boolean; @@ -939,6 +940,9 @@ function buildDescription(description: RawDesc, attacker: Pokemon, defender: Pok if (description.isFlowerGiftAttacker) { output += 'with an ally\'s Flower Gift '; } + if (description.isSteelySpiritAttacker) { + output += 'with an ally\'s Steely Spirit '; + } if (description.isBattery) { output += 'Battery boosted '; } diff --git a/calc/src/field.ts b/calc/src/field.ts index 0c759013c..890e1582e 100644 --- a/calc/src/field.ts +++ b/calc/src/field.ts @@ -91,6 +91,7 @@ export class Side implements State.Side { isAuroraVeil: boolean; isBattery: boolean; isPowerSpot: boolean; + isSteelySpirit: boolean; isSwitching?: 'out' | 'in'; constructor(side: State.Side = {}) { @@ -113,6 +114,7 @@ export class Side implements State.Side { this.isAuroraVeil = !!side.isAuroraVeil; this.isBattery = !!side.isBattery; this.isPowerSpot = !!side.isPowerSpot; + this.isSteelySpirit = !!side.isSteelySpirit; this.isSwitching = side.isSwitching; } diff --git a/calc/src/mechanics/gen789.ts b/calc/src/mechanics/gen789.ts index f8d3e48bc..08cfe7b25 100644 --- a/calc/src/mechanics/gen789.ts +++ b/calc/src/mechanics/gen789.ts @@ -1390,6 +1390,14 @@ export function calculateAtModsSMSSSV( desc.isFlowerGiftAttacker = true; } + if ( + field.attackerSide.isSteelySpirit && + move.hasType('Steel') + ) { + atMods.push(6144); + desc.isSteelySpiritAttacker = true; + } + if ((defender.hasAbility('Thick Fat') && move.hasType('Fire', 'Ice')) || (defender.hasAbility('Water Bubble') && move.hasType('Fire')) || (defender.hasAbility('Purifying Salt') && move.hasType('Ghost'))) { diff --git a/calc/src/state.ts b/calc/src/state.ts index bd59b7383..82d473398 100644 --- a/calc/src/state.ts +++ b/calc/src/state.ts @@ -75,6 +75,7 @@ export namespace State { isAuroraVeil?: boolean; isBattery?: boolean; isPowerSpot?: boolean; + isSteelySpirit?: boolean; isSwitching?: 'out' | 'in'; } } diff --git a/calc/src/test/calc.test.ts b/calc/src/test/calc.test.ts index 3814567c4..b884db69a 100644 --- a/calc/src/test/calc.test.ts +++ b/calc/src/test/calc.test.ts @@ -749,6 +749,38 @@ describe('calc', () => { }); }); }); + + inGens(8, 9, ({gen, calculate, Pokemon, Move, Field}) => { + test('Steely Spirit should boost Steel-type moves as a field effect.', () => { + const pokemon = Pokemon('Perrserker', { + ability: 'Battle Armor', + }); + + const move = Move('Iron Head'); + + let result = calculate(pokemon, pokemon, move); + + expect(result.desc()).toBe( + '0 Atk Perrserker Iron Head vs. 0 HP / 0 Def Perrserker: 46-55 (16.3 - 19.5%) -- possible 6HKO' + ); + + const field = Field({attackerSide: {isSteelySpirit: true}}); + + result = calculate(pokemon, pokemon, move, field); + + expect(result.desc()).toBe( + '0 Atk Perrserker with an ally\'s Steely Spirit Iron Head vs. 0 HP / 0 Def Perrserker: 70-83 (24.9 - 29.5%) -- 99.9% chance to 4HKO' + ); + + pokemon.ability = 'Steely Spirit' as AbilityName; + + result = calculate(pokemon, pokemon, move, field); + + expect(result.desc()).toBe( + '0 Atk Steely Spirit Perrserker with an ally\'s Steely Spirit Iron Head vs. 0 HP / 0 Def Perrserker: 105-124 (37.3 - 44.1%) -- guaranteed 3HKO' + ); + }); + }); }); From f3816b0a2788483f896948ab5b9228749783c6dd Mon Sep 17 00:00:00 2001 From: Shriansh Chari <30420527+shrianshChari@users.noreply.github.com> Date: Mon, 21 Oct 2024 21:17:44 -0400 Subject: [PATCH 2/3] Add support in the frontend --- src/index.template.html | 11 +++++++++++ src/js/shared_controls.js | 3 ++- src/randoms.template.html | 11 +++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/index.template.html b/src/index.template.html index fd8f0b1be..d527c0f73 100644 --- a/src/index.template.html +++ b/src/index.template.html @@ -954,6 +954,17 @@ + +
+ + + +
+
+ + +
+
diff --git a/src/js/shared_controls.js b/src/js/shared_controls.js index feec7e57e..186ac9b60 100644 --- a/src/js/shared_controls.js +++ b/src/js/shared_controls.js @@ -1188,6 +1188,7 @@ function createField() { var isHelpingHand = [$("#helpingHandL").prop("checked"), $("#helpingHandR").prop("checked")]; var isTailwind = [$("#tailwindL").prop("checked"), $("#tailwindR").prop("checked")]; var isFlowerGift = [$("#flowerGiftL").prop("checked"), $("#flowerGiftR").prop("checked")]; + var isSteelySpirit = [$("#steelySpiritL").prop("checked"), $("#steelySpiritR").prop("checked")] var isFriendGuard = [$("#friendGuardL").prop("checked"), $("#friendGuardR").prop("checked")]; var isAuroraVeil = [$("#auroraVeilL").prop("checked"), $("#auroraVeilR").prop("checked")]; var isBattery = [$("#batteryL").prop("checked"), $("#batteryR").prop("checked")]; @@ -1200,7 +1201,7 @@ function createField() { spikes: spikes[i], isSR: isSR[i], steelsurge: steelsurge[i], vinelash: vinelash[i], wildfire: wildfire[i], cannonade: cannonade[i], volcalith: volcalith[i], isReflect: isReflect[i], isLightScreen: isLightScreen[i], - isProtected: isProtected[i], isSeeded: isSeeded[i], isForesight: isForesight[i], + isProtected: isProtected[i], isSeeded: isSeeded[i], isForesight: isForesight[i], isSteelySpirit: isSteelySpirit[i], isTailwind: isTailwind[i], isHelpingHand: isHelpingHand[i], isFlowerGift: isFlowerGift[i], isFriendGuard: isFriendGuard[i], isAuroraVeil: isAuroraVeil[i], isBattery: isBattery[i], isPowerSpot: isPowerSpot[i], isSwitching: isSwitchingOut[i] ? 'out' : undefined }); diff --git a/src/randoms.template.html b/src/randoms.template.html index 6b9c08a9b..18517a2d4 100644 --- a/src/randoms.template.html +++ b/src/randoms.template.html @@ -949,6 +949,17 @@
+ +
+ + + +
+
+ + +
+
From 9e378df819b9f0d8326ee63964e2f86fe089a94f Mon Sep 17 00:00:00 2001 From: Shriansh Chari <30420527+shrianshChari@users.noreply.github.com> Date: Mon, 21 Oct 2024 21:25:37 -0400 Subject: [PATCH 3/3] Satisfy linter --- src/js/shared_controls.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/shared_controls.js b/src/js/shared_controls.js index 186ac9b60..9f92cb0c5 100644 --- a/src/js/shared_controls.js +++ b/src/js/shared_controls.js @@ -1188,7 +1188,7 @@ function createField() { var isHelpingHand = [$("#helpingHandL").prop("checked"), $("#helpingHandR").prop("checked")]; var isTailwind = [$("#tailwindL").prop("checked"), $("#tailwindR").prop("checked")]; var isFlowerGift = [$("#flowerGiftL").prop("checked"), $("#flowerGiftR").prop("checked")]; - var isSteelySpirit = [$("#steelySpiritL").prop("checked"), $("#steelySpiritR").prop("checked")] + var isSteelySpirit = [$("#steelySpiritL").prop("checked"), $("#steelySpiritR").prop("checked")]; var isFriendGuard = [$("#friendGuardL").prop("checked"), $("#friendGuardR").prop("checked")]; var isAuroraVeil = [$("#auroraVeilL").prop("checked"), $("#auroraVeilR").prop("checked")]; var isBattery = [$("#batteryL").prop("checked"), $("#batteryR").prop("checked")];