-
-
Notifications
You must be signed in to change notification settings - Fork 149
Fix True-Name Nemesis chosen-player protection #7213
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
traemyn
wants to merge
2
commits into
phase-rs:main
Choose a base branch
from
traemyn:fix/issue-5941-true-name-protection
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.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
63 changes: 63 additions & 0 deletions
63
crates/engine/tests/integration/issue_5941_true_name_chosen_player_protection.rs
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,63 @@ | ||
| //! Issue #5941: True-Name Nemesis must not be targetable by objects controlled | ||
| //! by the player chosen as it entered the battlefield. | ||
| //! | ||
| //! The regression drives the parsed ETB choice through `ChooseOption`, then | ||
| //! checks the production target-legality predicate with sources controlled by | ||
| //! both players. | ||
|
|
||
| use engine::game::scenario::{GameScenario, P0}; | ||
| use engine::game::targeting::find_legal_targets; | ||
| use engine::types::ability::ChoiceType; | ||
| use engine::types::ability::TargetFilter; | ||
| use engine::types::actions::GameAction; | ||
| use engine::types::game_state::WaitingFor; | ||
| use engine::types::identifiers::ObjectId; | ||
| use engine::types::player::PlayerId; | ||
|
|
||
| const P1: PlayerId = PlayerId(1); | ||
| const TRUE_NAME_ORACLE: &str = "As True-Name Nemesis enters, choose a player.\nTrue-Name Nemesis has protection from the chosen player. (This creature can't be blocked, targeted, dealt damage by, or enchanted by anything controlled by that player.)"; | ||
|
|
||
| fn add_source(scenario: &mut GameScenario, player: PlayerId, name: &str) -> ObjectId { | ||
| scenario.add_creature(player, name, 2, 2).id() | ||
| } | ||
|
|
||
| #[test] | ||
| fn true_name_protection_uses_the_protected_objects_chosen_player() { | ||
| let mut scenario = GameScenario::new_n_player(2, 5941); | ||
| let true_name = scenario | ||
| .add_creature_from_oracle(P0, "True-Name Nemesis", 3, 1, TRUE_NAME_ORACLE) | ||
| .id(); | ||
| let chosen_player_source = add_source(&mut scenario, P1, "Song of the Dryads"); | ||
| let other_player_source = add_source(&mut scenario, P0, "Friendly Spell"); | ||
| let mut runner = scenario.build(); | ||
|
|
||
| let source = crate::support::exact_named_choice_source(runner.state(), true_name); | ||
| runner.state_mut().waiting_for = WaitingFor::NamedChoice { | ||
| player: P0, | ||
| choice_type: ChoiceType::player(), | ||
| options: vec![P0.0.to_string(), P1.0.to_string()], | ||
| source: Some(source), | ||
| persist_player: None, | ||
| }; | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| runner | ||
| .act(GameAction::ChooseOption { | ||
| choice: P1.0.to_string(), | ||
| }) | ||
| .expect("choosing the player must succeed"); | ||
|
|
||
| assert_eq!(runner.state().objects[&true_name].chosen_player(), Some(P1)); | ||
|
|
||
| let targets_from_chosen_player = | ||
| find_legal_targets(runner.state(), &TargetFilter::Any, P1, chosen_player_source); | ||
| assert!( | ||
| !targets_from_chosen_player.contains(&engine::types::ability::TargetRef::Object(true_name)), | ||
| "True-Name must not be targetable by the chosen player's source, got {targets_from_chosen_player:?}" | ||
| ); | ||
|
|
||
| let targets_from_other_player = | ||
| find_legal_targets(runner.state(), &TargetFilter::Any, P0, other_player_source); | ||
| assert!( | ||
| targets_from_other_player.contains(&engine::types::ability::TargetRef::Object(true_name)), | ||
| "True-Name must remain targetable by another player's source, got {targets_from_other_player:?}" | ||
| ); | ||
| } | ||
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Implement the ownership leg of protection from the chosen player.
CR 702.16k covers objects controlled by the chosen player and objects owned by that player that another player does not control. The current comparison only checks
source.controller, so nonbattlefield sources owned by the chosen player can bypass protection. CR 109.4 also states that objects outside the stack and battlefield have no controller. (media.wizards.com)crates/engine/src/game/keywords.rs#L545-L549: Match the chosen player against the source owner when the source has no controller, while retaining controller matching for controlled sources.crates/engine/src/types/keywords.rs#L505-L507: Replace the CR 109.4 citation with the applicable CR 702.16k behavior and document the ownership case.As per path instructions, player-scoped queries on nonbattlefield zones must filter by
obj.owner, notcontroller.📍 Affects 2 files
crates/engine/src/game/keywords.rs#L545-L549(this comment)crates/engine/src/types/keywords.rs#L505-L507🤖 Prompt for AI Agents
Sources: Path instructions, MCP tools