-
Notifications
You must be signed in to change notification settings - Fork 855
[LGN] Rework Whipgrass Entangler #10802
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
Merged
Merged
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
146 changes: 146 additions & 0 deletions
146
Mage.Tests/src/test/java/org/mage/test/cards/single/lgn/WhipgrassEntanglerTest.java
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,146 @@ | ||
| package org.mage.test.cards.single.lgn; | ||
|
|
||
| import mage.constants.PhaseStep; | ||
| import mage.constants.Zone; | ||
| import org.junit.Test; | ||
| import org.mage.test.serverside.base.CardTestPlayerBase; | ||
|
|
||
| public class WhipgrassEntanglerTest extends CardTestPlayerBase { | ||
|
|
||
| /** | ||
| * Whipgrass Entangler | ||
| * {2}{W} | ||
| * Creature — Human Cleric | ||
| * <p> | ||
| * {1}{W}: Until end of turn, target creature gains "This creature can't attack or block unless its controller pays {1} for each Cleric on the battlefield." | ||
| * <p> | ||
| * 1/3 | ||
| */ | ||
| private static final String entangler = "Whipgrass Entangler"; | ||
|
|
||
| @Test | ||
| public void gainAbilityHimselfAndPay() { | ||
| setStrictChooseMode(true); | ||
| addCard(Zone.BATTLEFIELD, playerA, entangler); | ||
| addCard(Zone.BATTLEFIELD, playerA, "Plains", 20); | ||
|
|
||
| activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{1}{W}: Until end of turn, ", entangler); | ||
| attack(1, playerA, entangler); | ||
| setChoice(playerA, true); // yes to "pay {1} for Entangler to attack" | ||
|
|
||
| setStopAt(1, PhaseStep.END_TURN); | ||
| execute(); | ||
|
|
||
| assertLife(playerB, 20 - 1); | ||
| assertTappedCount("Plains", true, 2 * 1 + 1 * 1); | ||
| } | ||
|
|
||
| @Test | ||
| public void gainAbilityTwiceAndPay() { | ||
| setStrictChooseMode(true); | ||
| addCard(Zone.BATTLEFIELD, playerA, entangler); | ||
| addCard(Zone.BATTLEFIELD, playerA, "Plains", 20); | ||
|
|
||
| activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{1}{W}: Until end of turn, ", entangler); | ||
| activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{1}{W}: Until end of turn, ", entangler); | ||
| attack(1, playerA, entangler); | ||
| setChoice(playerA, "Whipgrass Entangler"); // two of the same replacement effect to choose from. | ||
| setChoice(playerA, true); // yes to "pay {1} for Entangler to attack" | ||
| setChoice(playerA, true); // yes to "pay {1} for Entangler to attack" | ||
|
|
||
| setStopAt(1, PhaseStep.END_TURN); | ||
| execute(); | ||
|
|
||
| assertLife(playerB, 20 - 1); | ||
| assertTappedCount("Plains", true, 2 * 2 + 1 * 2); | ||
| } | ||
|
|
||
| @Test | ||
| public void gainAbilityWithTwoClericAndPay() { | ||
| setStrictChooseMode(true); | ||
| addCard(Zone.BATTLEFIELD, playerA, entangler); | ||
| addCard(Zone.BATTLEFIELD, playerA, "Akroma's Devoted"); // 2/4 Cleric | ||
| addCard(Zone.BATTLEFIELD, playerA, "Plains", 20); | ||
|
|
||
| activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{1}{W}: Until end of turn, ", entangler); | ||
| activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{1}{W}: Until end of turn, ", "Akroma's Devoted"); | ||
| attack(1, playerA, entangler); | ||
| setChoice(playerA, true); // yes to "pay {2} for Entangler to attack" | ||
| attack(1, playerA, "Akroma's Devoted"); | ||
| setChoice(playerA, true); // yes to "pay {2} for Akroma's Devoted to attack" | ||
|
|
||
| setStopAt(1, PhaseStep.END_TURN); | ||
| execute(); | ||
|
|
||
| assertLife(playerB, 20 - 1 - 2); | ||
| assertTappedCount("Plains", true, 2 * 2 + 2 * 2); | ||
| } | ||
|
|
||
| @Test | ||
| public void gainAbilityFromTwoEntanglerAndPay() { | ||
| setStrictChooseMode(true); | ||
| addCard(Zone.BATTLEFIELD, playerA, "Akroma's Devoted"); // 2/4 Cleric | ||
| addCard(Zone.BATTLEFIELD, playerA, entangler, 1); | ||
|
|
||
| // In order to make sure the ability is activated from both entanglers, we exile one and play the second one after | ||
| addCard(Zone.HAND, playerA, entangler); | ||
| addCard(Zone.HAND, playerA, "Swords to Plowshares", 1); | ||
| addCard(Zone.BATTLEFIELD, playerA, "Plains", 20); | ||
|
|
||
| // Activate first entangler | ||
| activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{1}{W}: Until end of turn, ", "Akroma's Devoted"); | ||
| // Exile first entangler | ||
| castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Swords to Plowshares", entangler, true); | ||
|
|
||
| // Cast second entangler | ||
| castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, entangler, true); | ||
| // Activate second entangler | ||
| activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{1}{W}: Until end of turn, ", "Akroma's Devoted"); | ||
|
|
||
| attack(1, playerA, "Akroma's Devoted"); | ||
| setChoice(playerA, "Akroma's Devoted"); // two of the same replacement effect to choose from. | ||
| setChoice(playerA, true); // yes to "pay {2} for Akroma's Devoted to attack" | ||
| setChoice(playerA, true); // yes to "pay {2} for Akroma's Devoted to attack" | ||
|
|
||
| setStopAt(1, PhaseStep.END_TURN); | ||
| execute(); | ||
|
|
||
| assertLife(playerB, 20 - 2); | ||
| assertTappedCount("Plains", true, 2 * 2 + 2 * 2 + 3 + 1); | ||
| } | ||
|
|
||
| @Test | ||
| public void gainAbilityWithCloneAndPay() { | ||
| setStrictChooseMode(true); | ||
| addCard(Zone.BATTLEFIELD, playerA, "Akroma's Devoted"); // 2/4 Cleric | ||
| addCard(Zone.BATTLEFIELD, playerA, entangler); | ||
| addCard(Zone.HAND, playerA, "Sakashima the Impostor"); // Clone with different name for easy targets | ||
|
|
||
| // In order to make sure the ability is activated from the clone, we exile the original one before activating Sakashima | ||
| addCard(Zone.HAND, playerA, "Swords to Plowshares", 1); | ||
| addCard(Zone.BATTLEFIELD, playerA, "Tundra", 20); | ||
|
|
||
| // Activate the original Entangler | ||
| activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{1}{W}: Until end of turn, ", "Akroma's Devoted"); | ||
| waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN); | ||
| // Cast Sakashima | ||
| castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Sakashima the Impostor", true); | ||
| setChoice(playerA, true); // yes to clone. | ||
| setChoice(playerA, entangler); // copy entangler | ||
| // Exile original entangler | ||
| castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Swords to Plowshares", entangler, true); | ||
| // Activate Sakashima. | ||
| activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{1}{W}: Until end of turn, ", "Akroma's Devoted"); | ||
|
|
||
| attack(1, playerA, "Akroma's Devoted"); | ||
| setChoice(playerA, "Akroma's Devoted"); // two of the same replacement effect to choose from. | ||
| setChoice(playerA, true); // yes to "pay {2} for Akroma's Devoted to attack" | ||
| setChoice(playerA, true); // yes to "pay {2} for Akroma's Devoted to attack" | ||
|
|
||
| setStopAt(1, PhaseStep.END_TURN); | ||
| execute(); | ||
|
|
||
| assertLife(playerB, 20 - 2); | ||
| assertTappedCount("Tundra", true, 2 * 2 + 2 * 2 + 4 + 1); | ||
| } | ||
| } |
82 changes: 82 additions & 0 deletions
82
Mage/src/main/java/mage/abilities/common/LinkedSimpleStaticAbility.java
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,82 @@ | ||
| package mage.abilities.common; | ||
|
|
||
| import mage.abilities.effects.Effect; | ||
| import mage.constants.Zone; | ||
| import mage.util.CardUtil; | ||
|
|
||
| import java.util.Objects; | ||
| import java.util.UUID; | ||
|
|
||
| /** | ||
| * Warning: please test with a lot of care when using this class for new things. | ||
| * <p> | ||
| * A static Ability linked to an Effect. | ||
| * The parent Ability does take responsability of setting the id for the child. | ||
| * | ||
| * @author Susucr | ||
| */ | ||
| public class LinkedSimpleStaticAbility extends SimpleStaticAbility { | ||
|
|
||
| public interface ChildEffect extends Effect { | ||
| /** | ||
| * Set the link for the child. | ||
| */ | ||
| void setParentLinkHandshake(UUID parentLinkHandshake); | ||
|
|
||
| /** | ||
| * The child Id should only change on copy when the parent wants it to. | ||
| */ | ||
| void manualNewId(); | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * The handshake UUID between this parent ability and its child. | ||
| */ | ||
| private UUID linkedHandshake; | ||
|
|
||
| public LinkedSimpleStaticAbility(ChildEffect effect) { | ||
| this(Zone.BATTLEFIELD, effect); | ||
| } | ||
|
|
||
| public LinkedSimpleStaticAbility(Zone zone, ChildEffect effect) { | ||
| super(Zone.BATTLEFIELD, effect); | ||
| this.linkedHandshake = UUID.randomUUID(); | ||
| initHandshake(); | ||
| setEffectIdManually(); | ||
| } | ||
|
|
||
| private LinkedSimpleStaticAbility(final LinkedSimpleStaticAbility effect) { | ||
| super(effect); | ||
| this.linkedHandshake = UUID.randomUUID(); | ||
| initHandshake(); | ||
| } | ||
|
|
||
| @Override | ||
| public LinkedSimpleStaticAbility copy() { | ||
| return new LinkedSimpleStaticAbility(this); | ||
| } | ||
|
|
||
| private void initHandshake() { | ||
| this.linkedHandshake = UUID.randomUUID(); | ||
| CardUtil.castStream(this.getEffects().stream(), ChildEffect.class) | ||
| .filter(Objects::nonNull) | ||
| .forEach(e -> e.setParentLinkHandshake(linkedHandshake)); | ||
| } | ||
|
|
||
| public void setEffectIdManually() { | ||
| CardUtil.castStream(this.getEffects().stream(), ChildEffect.class) | ||
| .filter(Objects::nonNull) | ||
| .forEach(e -> e.manualNewId()); | ||
| } | ||
|
|
||
| public boolean checkLinked(UUID handshake) { | ||
| return linkedHandshake.equals(handshake); | ||
| } | ||
|
|
||
| @Override | ||
| public void newId() { | ||
| super.newId(); | ||
| } | ||
| } | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.