mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
Fix Dack Fayden Emblem.
The emblem's effect was referencing the permanent directly. This meant that if the permanent left and came back, the control effect would start working again.
This commit is contained in:
parent
964f2fb9d0
commit
dd0c89db1d
2 changed files with 95 additions and 12 deletions
|
@ -27,9 +27,6 @@
|
|||
*/
|
||||
package mage.cards.d;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.LoyaltyAbility;
|
||||
import mage.abilities.SpellAbility;
|
||||
|
@ -59,6 +56,11 @@ import mage.players.Player;
|
|||
import mage.target.Target;
|
||||
import mage.target.TargetPlayer;
|
||||
import mage.target.common.TargetArtifactPermanent;
|
||||
import mage.target.targetpointer.FixedTargets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -135,7 +137,7 @@ class DackFaydenEmblemTriggeredAbility extends TriggeredAbilityImpl {
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
boolean returnValue = false;
|
||||
List<UUID> targettedPermanents = new ArrayList<>(0);
|
||||
List<UUID> targetedPermanentIds = new ArrayList<>(0);
|
||||
Player player = game.getPlayer(this.getControllerId());
|
||||
if (player != null) {
|
||||
if (event.getPlayerId().equals(this.getControllerId())) {
|
||||
|
@ -147,7 +149,7 @@ class DackFaydenEmblemTriggeredAbility extends TriggeredAbilityImpl {
|
|||
for (UUID targetId : target.getTargets()) {
|
||||
if (game.getBattlefield().containsPermanent(targetId)) {
|
||||
returnValue = true;
|
||||
targettedPermanents.add(targetId);
|
||||
targetedPermanentIds.add(targetId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +158,7 @@ class DackFaydenEmblemTriggeredAbility extends TriggeredAbilityImpl {
|
|||
for (UUID targetId : effect.getTargetPointer().getTargets(game, spellAbility)) {
|
||||
if (game.getBattlefield().containsPermanent(targetId)) {
|
||||
returnValue = true;
|
||||
targettedPermanents.add(targetId);
|
||||
targetedPermanentIds.add(targetId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -166,7 +168,15 @@ class DackFaydenEmblemTriggeredAbility extends TriggeredAbilityImpl {
|
|||
for (Effect effect : this.getEffects()) {
|
||||
if (effect instanceof DackFaydenEmblemEffect) {
|
||||
DackFaydenEmblemEffect dackEffect = (DackFaydenEmblemEffect) effect;
|
||||
dackEffect.setPermanents(targettedPermanents);
|
||||
List<Permanent> permanents = new ArrayList<>();
|
||||
for(UUID permanentId : targetedPermanentIds) {
|
||||
Permanent permanent = game.getPermanent(permanentId);
|
||||
if(permanent != null) {
|
||||
permanents.add(permanent);
|
||||
}
|
||||
}
|
||||
|
||||
dackEffect.setTargets(permanents, game);
|
||||
}
|
||||
}
|
||||
return returnValue;
|
||||
|
@ -180,7 +190,7 @@ class DackFaydenEmblemTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
class DackFaydenEmblemEffect extends ContinuousEffectImpl {
|
||||
|
||||
protected List<UUID> permanents;
|
||||
protected FixedTargets fixedTargets;
|
||||
|
||||
DackFaydenEmblemEffect() {
|
||||
super(Duration.EndOfGame, Layer.ControlChangingEffects_2, SubLayer.NA, Outcome.GainControl);
|
||||
|
@ -189,7 +199,7 @@ class DackFaydenEmblemEffect extends ContinuousEffectImpl {
|
|||
|
||||
DackFaydenEmblemEffect(final DackFaydenEmblemEffect effect) {
|
||||
super(effect);
|
||||
this.permanents = effect.permanents;
|
||||
this.fixedTargets = effect.fixedTargets;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -199,7 +209,7 @@ class DackFaydenEmblemEffect extends ContinuousEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (UUID permanentId : this.permanents) {
|
||||
for (UUID permanentId : fixedTargets.getTargets(game, source)) {
|
||||
Permanent permanent = game.getPermanent(permanentId);
|
||||
if (permanent != null) {
|
||||
permanent.changeControllerId(source.getControllerId(), game);
|
||||
|
@ -208,7 +218,7 @@ class DackFaydenEmblemEffect extends ContinuousEffectImpl {
|
|||
return true;
|
||||
}
|
||||
|
||||
public void setPermanents(List<UUID> targettedPermanents) {
|
||||
this.permanents = new ArrayList<>(targettedPermanents);
|
||||
public void setTargets(List<Permanent> targetedPermanents, Game game) {
|
||||
this.fixedTargets = new FixedTargets(targetedPermanents, game);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
package org.mage.test.cards.control;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
public class DackFaydenTest extends CardTestPlayerBase {
|
||||
|
||||
@Test
|
||||
public void testDackFaydenEmblem() {
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Dack Fayden");
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Ornithopter");
|
||||
|
||||
addCard(Zone.HAND, playerA, "Gut Shot");
|
||||
|
||||
|
||||
for(int i = 1; i < 8; i+= 2) {
|
||||
activateAbility(i, PhaseStep.PRECOMBAT_MAIN, playerA,"+1: Target player draws two cards, then discards two cards.", playerB);
|
||||
}
|
||||
|
||||
activateAbility(9, PhaseStep.PRECOMBAT_MAIN, playerA,
|
||||
"-6: You get an emblem with \"Whenever you cast a spell that targets one or more permanents, gain control of those permanents.\"");
|
||||
|
||||
castSpell(10, PhaseStep.PRECOMBAT_MAIN, playerA, "Gut Shot", "Ornithopter");
|
||||
|
||||
setStopAt(10, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 18);
|
||||
assertLife(playerB, 20);
|
||||
|
||||
assertCounterCount("Dack Fayden", CounterType.LOYALTY, 1);
|
||||
assertPermanentCount(playerA, "Ornithopter", 1);
|
||||
}
|
||||
|
||||
//Ensure that if a permanent moves to a different zone and comes back,
|
||||
//it won't still be under the controller of Dack's Emblem.
|
||||
@Test
|
||||
public void testDackFaydenEmblemAcrossZones() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Dack Fayden");
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Ornithopter");
|
||||
|
||||
addCard(Zone.HAND, playerA, "Gut Shot");
|
||||
|
||||
addCard(Zone.HAND, playerA, "Unsummon");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Island");
|
||||
|
||||
for(int i = 1; i < 8; i+= 2) {
|
||||
activateAbility(i, PhaseStep.PRECOMBAT_MAIN, playerA,"+1: Target player draws two cards, then discards two cards.", playerB);
|
||||
}
|
||||
|
||||
activateAbility(9, PhaseStep.PRECOMBAT_MAIN, playerA,
|
||||
"-6: You get an emblem with \"Whenever you cast a spell that targets one or more permanents, gain control of those permanents.\"");
|
||||
|
||||
castSpell(10, PhaseStep.PRECOMBAT_MAIN, playerA, "Gut Shot", "Ornithopter");
|
||||
castSpell(10, PhaseStep.PRECOMBAT_MAIN, playerA, "Unsummon", "Ornithopter", "Gut Shot", StackClause.WHILE_NOT_ON_STACK);
|
||||
castSpell(10, PhaseStep.PRECOMBAT_MAIN, playerB, "Ornithopter");
|
||||
|
||||
setStopAt(10, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 18);
|
||||
assertLife(playerB, 20);
|
||||
|
||||
assertCounterCount("Dack Fayden", CounterType.LOYALTY, 1);
|
||||
assertPermanentCount(playerB, "Ornithopter", 1);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue