-
-
Notifications
You must be signed in to change notification settings - Fork 148
fix(engine): Jeweled Amulet notes and reproduces spent mana type (#6504) #6812
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jsdevninja
wants to merge
6
commits into
phase-rs:main
Choose a base branch
from
jsdevninja:fix/6504-jeweled-amulet-noted-mana
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,271
−4
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9404900
fix(engine): Jeweled Amulet notes and reproduces spent mana type (#6504)
jsdevninja 4a1a6fb
fix(engine): address review — narrow noted-mana class, fix incarnatio…
jsdevninja 8924857
fix(engine): thread noted-mana payment per-activation, not per-object
jsdevninja 588457d
fix(engine): clear noted-mana payment when copying an activated ability
jsdevninja 5fdf11d
test(engine): guard Ice Cauldron's noted-mana boundary through the pr…
jsdevninja 56fc5b9
fix(PR-6812): resolve review blockers
matthewevans File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| use crate::types::ability::{ChosenAttribute, Effect, EffectError, ResolvedAbility}; | ||
| use crate::types::events::GameEvent; | ||
| use crate::types::game_state::GameState; | ||
|
|
||
| /// CR 106.1b + CR 602.2b + CR 608.2c: `Effect::NoteManaSpent` — record the mana | ||
| /// type(s) spent to pay this resolving ability's own activation cost onto its | ||
| /// source as `ChosenAttribute::NotedManaSpent` ("Note the type of mana spent to | ||
| /// pay this activation cost" — Jeweled Amulet). Scoped to the singular-type | ||
| /// wording only: Ice Cauldron's sibling "note the type AND AMOUNT..." needs an | ||
| /// exact stored multiset plus a spend restriction, which this building block | ||
| /// does not model — that text is intentionally left unmatched by the parser | ||
| /// and still reports `Effect::unimplemented`. | ||
| /// | ||
| /// Composable building block: cost payment stays in the mana-payment funnel; | ||
| /// `push_ability_entry` (the single authority where an activated ability | ||
| /// reaches the stack) snapshots what was spent, paired with the source's | ||
| /// incarnation at that moment, directly onto THIS activation's own | ||
| /// `ResolvedAbility::noted_mana_payment` (issue #6504) — never a per-object | ||
| /// mutable field, so a permanent untapped and reactivated with a different | ||
| /// payment while this ability still sits unresolved on the stack cannot | ||
| /// corrupt what this instance observed. This effect is the persistent writer, | ||
| /// read back by `ManaProduction::NotedType`. Doing the write at resolution — | ||
| /// not at payment time — means a countered or otherwise removed-from-stack | ||
| /// ability never notes anything (CR 608.2c: instructions are followed only on | ||
| /// resolution). | ||
| /// | ||
| /// "The last noted type" is singular per card, so this replaces any prior | ||
| /// `ChosenAttribute::NotedManaSpent` before pushing (replace-on-rechoose). | ||
| /// | ||
| /// CR 400.7: a source that leaves and returns (bounce/flicker) while this | ||
| /// SAME activation is still unresolved on the stack becomes a new object at | ||
| /// the same storage id — a new incarnation with no memory of the old | ||
| /// payment. Refuses to write unless the object's current incarnation still | ||
| /// matches `noted_mana_payment.source_incarnation`, mirroring the engine's | ||
| /// existing incarnation-pairing idiom (`ResolvedAbility::source_is_current`, | ||
| /// `TargetFilter::SelfRef` resolution). | ||
| pub fn resolve( | ||
| state: &mut GameState, | ||
| ability: &ResolvedAbility, | ||
| _events: &mut Vec<GameEvent>, | ||
| ) -> Result<(), EffectError> { | ||
| let Effect::NoteManaSpent = &ability.effect else { | ||
| return Ok(()); | ||
| }; | ||
|
|
||
| let Some(payment) = ability.noted_mana_payment.as_ref() else { | ||
| // Nothing was captured at activation (e.g. the cost had no mana | ||
| // component to observe) — nothing to note. | ||
| return Ok(()); | ||
| }; | ||
|
|
||
| let Some(src) = state.objects.get(&ability.source_id) else { | ||
| // CR 608.2c: the source has left the zone it was in — nothing to note. | ||
| return Ok(()); | ||
| }; | ||
| if src.incarnation != payment.source_incarnation { | ||
| // CR 400.7: this activation's payment was captured on a prior | ||
| // incarnation of this object (bounced/flickered since). The CURRENT | ||
| // incarnation never paid anything itself — nothing to note. | ||
| return Ok(()); | ||
| } | ||
| let spent_types = payment.types.clone(); | ||
|
|
||
| let Some(src) = state.objects.get_mut(&ability.source_id) else { | ||
| return Ok(()); | ||
| }; | ||
| src.chosen_attributes | ||
| .retain(|a| !matches!(a, ChosenAttribute::NotedManaSpent(_))); | ||
| src.chosen_attributes | ||
| .push(ChosenAttribute::NotedManaSpent(spent_types)); | ||
|
|
||
| Ok(()) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.