Skip to content

Commit

Permalink
Add Disabled Item field that is used to check knock off damage during…
Browse files Browse the repository at this point in the history
… Magic Room
  • Loading branch information
ShivaD173 committed Oct 17, 2024
1 parent a050f87 commit 8a74489
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
38 changes: 19 additions & 19 deletions calc/src/mechanics/gen789.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1003,30 +1003,30 @@ export function calculateBPModsSMSSSV(
const bpMods = [];

// Move effects

let defenderItem = (defender.item && defender.item !== "") ? defender.item : defender.disabledItem;

Check failure on line 1006 in calc/src/mechanics/gen789.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

This line has a length of 101. Maximum allowed is 100

Check failure on line 1006 in calc/src/mechanics/gen789.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

'defenderItem' is never reassigned. Use 'const' instead

Check failure on line 1006 in calc/src/mechanics/gen789.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Strings must use singlequote
let resistedKnockOffDamage =
(!defender.item || isQPActive(defender, field)) ||
(defender.named('Dialga-Origin') && defender.hasItem('Adamant Crystal')) ||
(defender.named('Palkia-Origin') && defender.hasItem('Lustrous Globe')) ||
(!defenderItem || isQPActive(defender, field)) ||
(defender.named('Dialga-Origin') && defenderItem === 'Adamant Crystal') ||
(defender.named('Palkia-Origin') && defenderItem === 'Lustrous Globe') ||
// Griseous Core for gen 9, Griseous Orb otherwise
(defender.name.includes('Giratina-Origin') && defender.item.includes('Griseous')) ||
(defender.name.includes('Arceus') && defender.item.includes('Plate')) ||
(defender.name.includes('Genesect') && defender.item.includes('Drive')) ||
(defender.named('Groudon', 'Groudon-Primal') && defender.hasItem('Red Orb')) ||
(defender.named('Kyogre', 'Kyogre-Primal') && defender.hasItem('Blue Orb')) ||
(defender.name.includes('Silvally') && defender.item.includes('Memory')) ||
defender.item.includes(' Z') ||
(defender.named('Zacian') && defender.hasItem('Rusted Sword')) ||
(defender.named('Zamazenta') && defender.hasItem('Rusted Shield')) ||
(defender.name.includes('Ogerpon-Cornerstone') && defender.hasItem('Cornerstone Mask')) ||
(defender.name.includes('Ogerpon-Hearthflame') && defender.hasItem('Hearthflame Mask')) ||
(defender.name.includes('Ogerpon-Wellspring') && defender.hasItem('Wellspring Mask')) ||
(defender.named('Venomicon-Epilogue') && defender.hasItem('Vile Vial'));
(defender.name.includes('Giratina-Origin') && defenderItem.includes('Griseous')) ||
(defender.name.includes('Arceus') && defenderItem.includes('Plate')) ||
(defender.name.includes('Genesect') && defenderItem.includes('Drive')) ||
(defender.named('Groudon', 'Groudon-Primal') && defenderItem === 'Red Orb') ||
(defender.named('Kyogre', 'Kyogre-Primal') && defenderItem === 'Blue Orb') ||
(defender.name.includes('Silvally') && defenderItem.includes('Memory')) ||
defenderItem.includes(' Z') ||
(defender.named('Zacian') && defenderItem === 'Rusted Sword') ||
(defender.named('Zamazenta') && defenderItem === 'Rusted Shield') ||
(defender.name.includes('Ogerpon-Cornerstone') && defenderItem === 'Cornerstone Mask') ||
(defender.name.includes('Ogerpon-Hearthflame') && defenderItem === 'Hearthflame Mask') ||
(defender.name.includes('Ogerpon-Wellspring') && defenderItem === 'Wellspring Mask') ||
(defender.named('Venomicon-Epilogue') && defenderItem === 'Vile Vial');

// The last case only applies when the Pokemon has the Mega Stone that matches its species
// (or when it's already a Mega-Evolution)
if (!resistedKnockOffDamage && defender.item) {
const item = gen.items.get(toID(defender.item))!;
if (!resistedKnockOffDamage && defenderItem) {
const item = gen.items.get(toID(defenderItem))!;
resistedKnockOffDamage = !!item.megaEvolves && defender.name.includes(item.megaEvolves);
}

Expand Down
1 change: 1 addition & 0 deletions calc/src/mechanics/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ export function checkItem(pokemon: Pokemon, magicRoomActive?: boolean) {
pokemon.hasAbility('Klutz') && !EV_ITEMS.includes(pokemon.item!) ||
magicRoomActive
) {
pokemon.disabledItem = pokemon.item;
pokemon.item = '' as ItemName;
}
}
Expand Down
1 change: 1 addition & 0 deletions calc/src/pokemon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class Pokemon implements State.Pokemon {
alliesFainted?: number;
boostedStat?: I.StatIDExceptHP | 'auto';
item?: I.ItemName;
disabledItem?: I.ItemName;
teraType?: I.TypeName;

nature: I.NatureName;
Expand Down

0 comments on commit 8a74489

Please sign in to comment.