Skip to content

[codex] Implement Galarian Cursola Perish Body#248

Closed
RogerAngell99 wants to merge 1 commit intobcollazo:mainfrom
RogerAngell99:codex/implement-galarian-cursola-perish-body
Closed

[codex] Implement Galarian Cursola Perish Body#248
RogerAngell99 wants to merge 1 commit intobcollazo:mainfrom
RogerAngell99:codex/implement-galarian-cursola-perish-body

Conversation

@RogerAngell99
Copy link
Copy Markdown

Summary

Implements Galarian Cursola [A4a 035] Perish Body as a passive KO trigger based on attack-damage source tracking rather than only the current Active slot.

This needed core engine support because Perish Body depends on the identity of the Pokemon that produced the attack damage, not just its current board position. For example, Jumpluff ex can deal lethal damage with Breeze-By Attack and then move to the Bench before KO resolution; on heads, Perish Body should KO that Jumpluff instance on the Bench, not the newly promoted Active Pokemon. The same identity tracking is needed for delayed or reactive attack damage such as Mismagius's Cursed Prose and Alolan Sandslash's Spike Armor.

What changed

  • Added passive AbilityMechanic::PerishBody mapping and kept it out of UseAbility generation.
  • Added internal in-play Pokemon instance IDs so damage-origin tracking survives switches, retreats, and evolution, and is cleared when a Pokemon leaves play.
  • Added attack-damage context for normal, delayed, and reactive attack damage so Perish Body can distinguish attack damage from Tool, Ability, and checkup/status damage.
  • Deferred attack KO resolution for hit-and-run attacks so movement effects can resolve before Perish Body targets the original attacker instance.
  • Adjusted Will ownership handling so prior-turn defensive Perish Body flips are not forced, while same-turn Spike Armor/Cursed Prose edge cases can consume the Cursola owner's pending Will.
  • Added focused tests for direct attacks, bench/no-trigger cases, non-attack damage bypasses, Rocky Helmet, Will timing, Spike Armor, Cursed Prose, Jumpluff ex hit-and-run tracking, and Scizor/Gale Thrust-style extra attack damage.

Validation

  • cargo +stable-x86_64-pc-windows-gnu test --features test-utils --test pokemon galarian_cursola_perish_body
  • cargo +stable-x86_64-pc-windows-gnu test --features test-utils
  • cargo +stable-x86_64-pc-windows-gnu clippy --lib --features test-utils -- -D warnings

Benchmarks were checked separately before this commit; play random game showed no relevant regression versus origin/main.

@RogerAngell99 RogerAngell99 marked this pull request as ready for review April 29, 2026 06:51
@bcollazo
Copy link
Copy Markdown
Owner

Hey! I like the id-tracking. You are right, right now those switch to bench attacks dont take counterattacks apropriately.

I have to think more about the Perish solution. I'd like if possible to have a simpler solution (one with less code). If you have ideas on how to make the solution need less code changes let me know! 🙌

Thanks for the tests also!

Implement Galarian Cursola's Perish Body as a passive KO trigger driven by the damage/KO pipeline.

This keeps the internal play ID tracking from the previous PR because it solves the counterattack identity bug the maintainer called out. The engine now assigns an internal ID to each Pokemon in play, preserves that ID through switches, retreats, and evolution, and clears it when the Pokemon leaves play. That lets effects target the original attacking Pokemon even after movement effects, for example Jumpluff ex using Breeze-By Attack to move to the Bench before Perish Body resolves.

The Perish implementation is now smaller than the previous PR: instead of forecasting Perish Body branches in apply_action.rs, attack damage records a pending Perish trigger only when it actually makes an Active Galarian Cursola KO. The common mutation wrapper resolves that pending trigger with RNG after normal KO handling, finds the attacker by play ID, and KOs that exact instance if it is still in play.

Add attack-sourced delayed/reactive damage metadata for the edge cases from the report. Mismagius's Cursed Prose and Alolan Sandslash's Spike Armor can now count as attack damage for Perish Body, while ordinary Tool damage, Ability damage, Poison/Burn checkup damage, and bench KOs do not trigger it.

Will remains player-owned. The normal defensive Perish Body flip on the opponent's turn is not forced by Will from the previous turn, but same-turn attack-damage edge cases such as Spike Armor and Cursed Prose can consume the Cursola owner's pending Will and force heads.

Perish Body stays passive: it is mapped as an AbilityMechanic, never generates UseAbility, and panics if called directly through the active ability path.

Covered cases include direct lethal attack damage, bench non-trigger, non-attack damage bypasses, Rocky Helmet bypass, previous-turn Will bypass, Spike Armor, Cursed Prose, Cursed Prose target leaving Active, Jumpluff ex hit-and-run targeting, and Scizor/Gale Thrust-style extra attack damage.
@RogerAngell99 RogerAngell99 force-pushed the codex/implement-galarian-cursola-perish-body branch from 6782495 to 1b5d1ce Compare April 29, 2026 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants