From a0a1dcb39fd1668b88bb32a794fb0403f84156f0 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Thu, 17 Dec 2020 03:05:58 +0400 Subject: [PATCH] * GUI: added additional target arrows to stack objects (now you can see triggered or affected permanents and another related links, see #6918); * Amulet of Vigor - improved combo support for multi triggers (now you can see triggered land name and chooses stack order, see #6918); --- .../src/main/java/mage/view/CardView.java | 32 ++++++++++++---- .../src/main/java/mage/view/CardsView.java | 7 ++-- .../main/java/mage/view/StackAbilityView.java | 10 ++--- Mage.Sets/src/mage/cards/a/AmuletOfVigor.java | 26 +++++++++---- .../src/mage/cards/g/GruulRagebeast.java | 37 +++++++------------ .../targetpointer/FirstTargetPointer.java | 18 ++++----- .../target/targetpointer/FixedTarget.java | 28 ++++++++------ .../target/targetpointer/FixedTargets.java | 31 +++++++++++----- .../targetpointer/SecondTargetPointer.java | 14 ++++--- .../target/targetpointer/TargetPointer.java | 20 ++++++++-- .../targetpointer/TargetPointerImpl.java | 33 +++++++++++++++++ .../targetpointer/ThirdTargetPointer.java | 17 ++++----- 12 files changed, 177 insertions(+), 96 deletions(-) create mode 100644 Mage/src/main/java/mage/target/targetpointer/TargetPointerImpl.java diff --git a/Mage.Common/src/main/java/mage/view/CardView.java b/Mage.Common/src/main/java/mage/view/CardView.java index b54fa54594..231f4858dd 100644 --- a/Mage.Common/src/main/java/mage/view/CardView.java +++ b/Mage.Common/src/main/java/mage/view/CardView.java @@ -8,6 +8,8 @@ import mage.abilities.Ability; import mage.abilities.Mode; import mage.abilities.SpellAbility; import mage.abilities.costs.mana.ManaCosts; +import mage.abilities.effects.Effect; +import mage.abilities.effects.Effects; import mage.abilities.keyword.AftermathAbility; import mage.cards.*; import mage.cards.mock.MockCard; @@ -474,7 +476,7 @@ public class CardView extends SimpleCardView { for (UUID modeId : spellAbility.getModes().getSelectedModes()) { Mode mode = spellAbility.getModes().get(modeId); if (!mode.getTargets().isEmpty()) { - setTargets(mode.getTargets()); + addTargets(mode.getTargets(), mode.getEffects(), spellAbility, game); } } } @@ -722,17 +724,31 @@ public class CardView extends SimpleCardView { this.tokenSetCode = token.getOriginalExpansionSetCode(); } - protected final void setTargets(Targets targets) { + protected final void addTargets(Targets targets, Effects effects, Ability source, Game game) { + if (this.targets == null) { + this.targets = new ArrayList<>(); + } + + // need only unique targets for arrow drawning + Set newTargets = new HashSet<>(); + + // fronormal targets for (Target target : targets) { if (target.isChosen()) { - for (UUID targetUUID : target.getTargets()) { - if (this.targets == null) { - this.targets = new ArrayList<>(); - } - this.targets.add(targetUUID); - } + newTargets.addAll(target.getTargets()); } } + + // from targetPointers (can be same as normal targets) + List fromPointers = effects.stream() + .map(Effect::getTargetPointer) + .filter(Objects::nonNull) + .map(p -> p.getTargets(game, source)) + .flatMap(Collection::stream) + .collect(Collectors.toList()); + newTargets.addAll(fromPointers); + + this.targets.addAll(newTargets); } public String getName() { diff --git a/Mage.Common/src/main/java/mage/view/CardsView.java b/Mage.Common/src/main/java/mage/view/CardsView.java index 1b7024deed..d83ac6a91e 100644 --- a/Mage.Common/src/main/java/mage/view/CardsView.java +++ b/Mage.Common/src/main/java/mage/view/CardsView.java @@ -1,7 +1,5 @@ package mage.view; -import java.util.*; -import java.util.stream.Collectors; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.Effect; @@ -17,6 +15,9 @@ import mage.target.targetpointer.TargetPointer; import mage.util.GameLog; import org.apache.log4j.Logger; +import java.util.*; +import java.util.stream.Collectors; + /** * @author BetaSteward_at_googlemail.com */ @@ -124,7 +125,7 @@ public class CardsView extends LinkedHashMap { abilityView = new AbilityView(ability, sourceObject.getName(), sourceCardView); } if (!ability.getTargets().isEmpty()) { - abilityView.setTargets(ability.getTargets()); + abilityView.addTargets(ability.getTargets(), ability.getEffects(), ability, game); } else { List abilityTargets = new ArrayList<>(); for (Effect effect : ability.getEffects()) { diff --git a/Mage.Common/src/main/java/mage/view/StackAbilityView.java b/Mage.Common/src/main/java/mage/view/StackAbilityView.java index a2214b83c4..4c2d6fc275 100644 --- a/Mage.Common/src/main/java/mage/view/StackAbilityView.java +++ b/Mage.Common/src/main/java/mage/view/StackAbilityView.java @@ -4,6 +4,8 @@ import mage.MageObject; import mage.abilities.Mode; import mage.abilities.Modes; import mage.abilities.effects.Effect; +import mage.abilities.hint.Hint; +import mage.abilities.hint.HintUtils; import mage.cards.Card; import mage.constants.AbilityType; import mage.constants.CardType; @@ -17,8 +19,6 @@ import mage.util.GameLog; import java.util.ArrayList; import java.util.List; import java.util.UUID; -import mage.abilities.hint.Hint; -import mage.abilities.hint.HintUtils; /** * @author BetaSteward_at_googlemail.com @@ -78,7 +78,7 @@ public class StackAbilityView extends CardView { for (UUID modeId : ability.getModes().getSelectedModes()) { Mode mode = ability.getModes().get(modeId); if (!mode.getTargets().isEmpty()) { - setTargets(mode.getTargets()); + addTargets(mode.getTargets(), mode.getEffects(), ability, game); } else { List targetList = new ArrayList<>(); for (Effect effect : mode.getEffects()) { @@ -102,13 +102,13 @@ public class StackAbilityView extends CardView { } } } - } } } if (!names.isEmpty()) { getRules().add("Related objects: " + names.toString() + ""); } + // show for modal ability, which mode was choosen if (ability.isModal()) { Modes modes = ability.getModes(); @@ -117,7 +117,7 @@ public class StackAbilityView extends CardView { this.rules.add("Chosen mode: " + mode.getEffects().getText(mode) + ""); } } - + if (HintUtils.ABILITY_HINTS_ENABLE) { List abilityHints = new ArrayList<>(); for (Hint hint : ability.getHints()) { diff --git a/Mage.Sets/src/mage/cards/a/AmuletOfVigor.java b/Mage.Sets/src/mage/cards/a/AmuletOfVigor.java index e0e8bc754e..ed1f3db9a3 100644 --- a/Mage.Sets/src/mage/cards/a/AmuletOfVigor.java +++ b/Mage.Sets/src/mage/cards/a/AmuletOfVigor.java @@ -1,7 +1,5 @@ - package mage.cards.a; -import java.util.UUID; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.effects.Effect; import mage.abilities.effects.common.UntapTargetEffect; @@ -11,9 +9,11 @@ import mage.constants.CardType; import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.target.targetpointer.FixedTarget; +import mage.util.GameLog; + +import java.util.UUID; /** * @author Loki @@ -21,8 +21,9 @@ import mage.target.targetpointer.FixedTarget; public final class AmuletOfVigor extends CardImpl { public AmuletOfVigor(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{1}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}"); + // Whenever a permanent enters the battlefield tapped and under your control, untap it. this.addAbility(new AmuletOfVigorTriggeredAbility()); } @@ -37,6 +38,7 @@ public final class AmuletOfVigor extends CardImpl { } class AmuletOfVigorTriggeredAbility extends TriggeredAbilityImpl { + AmuletOfVigorTriggeredAbility() { super(Zone.BATTLEFIELD, new UntapTargetEffect()); } @@ -57,10 +59,13 @@ class AmuletOfVigorTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { - Permanent p = game.getPermanent(event.getTargetId()); - if (p != null && p.isTapped() && p.isControlledBy(this.controllerId)) { + Permanent permanent = game.getPermanent(event.getTargetId()); + if (permanent != null && permanent.isTapped() && permanent.isControlledBy(this.getControllerId())) { for (Effect effect : this.getEffects()) { - effect.setTargetPointer(new FixedTarget(event.getTargetId())); + effect.setTargetPointer( + new FixedTarget(event.getTargetId()) + .withData("triggeredName", GameLog.getColoredObjectIdNameForTooltip(permanent)) + ); } return true; } @@ -69,6 +74,11 @@ class AmuletOfVigorTriggeredAbility extends TriggeredAbilityImpl { @Override public String getRule() { - return "Whenever a permanent enters the battlefield tapped and under your control, untap it."; + // that triggers depends on stack order, so make each trigger unique with extra info + String triggeredInfo = ""; + if (this.getEffects().get(0).getTargetPointer() != null) { + triggeredInfo = " Triggered permanent: " + this.getEffects().get(0).getTargetPointer().getData("triggeredName") + "."; + } + return "Whenever a permanent enters the battlefield tapped and under your control, untap it." + triggeredInfo; } } diff --git a/Mage.Sets/src/mage/cards/g/GruulRagebeast.java b/Mage.Sets/src/mage/cards/g/GruulRagebeast.java index c9096f7de4..ec3fcce7d9 100644 --- a/Mage.Sets/src/mage/cards/g/GruulRagebeast.java +++ b/Mage.Sets/src/mage/cards/g/GruulRagebeast.java @@ -2,7 +2,6 @@ package mage.cards.g; import mage.MageInt; import mage.abilities.Ability; -import mage.abilities.Mode; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; @@ -12,14 +11,12 @@ import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.SubType; import mage.constants.Zone; -import mage.filter.StaticFilters; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; -import mage.target.Target; -import mage.target.TargetPermanent; import mage.target.common.TargetOpponentsCreaturePermanent; import mage.target.targetpointer.FixedTarget; +import mage.util.GameLog; import java.util.UUID; @@ -54,7 +51,6 @@ class GruulRagebeastTriggeredAbility extends TriggeredAbilityImpl { GruulRagebeastTriggeredAbility() { super(Zone.BATTLEFIELD, new GruulRagebeastEffect(), false); this.addTarget(new TargetOpponentsCreaturePermanent().withChooseHint("for fighting")); - this.addTarget(new TargetPermanent(1, 1, StaticFilters.FILTER_PERMANENT, true)); // for info only } private GruulRagebeastTriggeredAbility(final GruulRagebeastTriggeredAbility ability) { @@ -82,13 +78,10 @@ class GruulRagebeastTriggeredAbility extends TriggeredAbilityImpl { && permanent.isCreature()) { for (Effect effect : this.getEffects()) { if (effect instanceof GruulRagebeastEffect) { - effect.setTargetPointer(new FixedTarget(event.getTargetId())); - - // triggered creature info stores as target - Target targetInfo = this.getTargets().get(1); - targetInfo.clearChosen(); - targetInfo.add(permanent.getId(), game); - targetInfo.withChooseHint(permanent.getLogName()); + effect.setTargetPointer( + new FixedTarget(event.getTargetId()) + .withData("triggeredName", GameLog.getColoredObjectIdNameForTooltip(sourceObject)) + ); } } return true; @@ -98,7 +91,13 @@ class GruulRagebeastTriggeredAbility extends TriggeredAbilityImpl { @Override public String getRule() { - return "Whenever {this} or another creature enters the battlefield under your control, " + super.getRule(); + // that triggers depends on stack order, so make each trigger unique with extra info + String triggeredInfo = ""; + if (this.getEffects().get(0).getTargetPointer() != null) { + triggeredInfo = " Your fighting creature: " + this.getEffects().get(0).getTargetPointer().getData("triggeredName") + "."; + } + return "Whenever {this} or another creature enters the battlefield under your control, " + + "that creature fights target creature an opponent controls." + triggeredInfo; } } @@ -114,8 +113,7 @@ class GruulRagebeastEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - // second target for info only, so use only first - Permanent triggeredCreature = game.getPermanent(targetPointer.getFirst(game, source)); + Permanent triggeredCreature = game.getPermanent(this.targetPointer.getFirst(game, source)); Permanent target = game.getPermanent(source.getFirstTarget()); if (triggeredCreature != null && target != null @@ -130,13 +128,4 @@ class GruulRagebeastEffect extends OneShotEffect { public GruulRagebeastEffect copy() { return new GruulRagebeastEffect(this); } - - @Override - public String getText(Mode mode) { - // additional info for stack ability about triggered permanent (it store info in second target) - Target target = mode.getTargets().get(1); - String info = (target.getChooseHint() == null ? "" : " (your fighting creature: " + target.getChooseHint() + ")"); - - return "that creature fights target creature an opponent controls" + info; - } } diff --git a/Mage/src/main/java/mage/target/targetpointer/FirstTargetPointer.java b/Mage/src/main/java/mage/target/targetpointer/FirstTargetPointer.java index d3c535e7fb..a05d5a70af 100644 --- a/Mage/src/main/java/mage/target/targetpointer/FirstTargetPointer.java +++ b/Mage/src/main/java/mage/target/targetpointer/FirstTargetPointer.java @@ -1,10 +1,5 @@ package mage.target.targetpointer; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; import mage.MageObject; import mage.abilities.Ability; import mage.cards.Card; @@ -12,7 +7,9 @@ import mage.constants.Zone; import mage.game.Game; import mage.game.permanent.Permanent; -public class FirstTargetPointer implements TargetPointer { +import java.util.*; + +public class FirstTargetPointer extends TargetPointerImpl { private Map zoneChangeCounter = new HashMap<>(); @@ -21,11 +18,14 @@ public class FirstTargetPointer implements TargetPointer { } public FirstTargetPointer() { + super(); } - public FirstTargetPointer(FirstTargetPointer firstTargetPointer) { + public FirstTargetPointer(final FirstTargetPointer targetPointer) { + super(targetPointer); + this.zoneChangeCounter = new HashMap<>(); - for (Map.Entry entry : firstTargetPointer.zoneChangeCounter.entrySet()) { + for (Map.Entry entry : targetPointer.zoneChangeCounter.entrySet()) { this.zoneChangeCounter.put(entry.getKey(), entry.getValue()); } } @@ -81,7 +81,7 @@ public class FirstTargetPointer implements TargetPointer { } @Override - public TargetPointer copy() { + public FirstTargetPointer copy() { return new FirstTargetPointer(this); } diff --git a/Mage/src/main/java/mage/target/targetpointer/FixedTarget.java b/Mage/src/main/java/mage/target/targetpointer/FixedTarget.java index 06c24f81b3..87223dfe29 100644 --- a/Mage/src/main/java/mage/target/targetpointer/FixedTarget.java +++ b/Mage/src/main/java/mage/target/targetpointer/FixedTarget.java @@ -1,9 +1,5 @@ package mage.target.targetpointer; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.UUID; import mage.MageObject; import mage.MageObjectReference; import mage.abilities.Ability; @@ -12,7 +8,12 @@ import mage.constants.Zone; import mage.game.Game; import mage.game.permanent.Permanent; -public class FixedTarget implements TargetPointer { +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.UUID; + +public class FixedTarget extends TargetPointerImpl { private final UUID targetId; private int zoneChangeCounter; @@ -29,6 +30,7 @@ public class FixedTarget implements TargetPointer { * @param target */ public FixedTarget(UUID target) { + super(); this.targetId = target; this.initialized = false; } @@ -45,6 +47,7 @@ public class FixedTarget implements TargetPointer { * @param game */ public FixedTarget(Card card, Game game) { + super(); this.targetId = card.getId(); this.zoneChangeCounter = card.getZoneChangeCounter(game); this.initialized = true; @@ -71,6 +74,7 @@ public class FixedTarget implements TargetPointer { * @param zoneChangeCounter */ public FixedTarget(UUID targetId, int zoneChangeCounter) { + super(); this.targetId = targetId; this.initialized = true; this.zoneChangeCounter = zoneChangeCounter; @@ -83,15 +87,18 @@ public class FixedTarget implements TargetPointer { * @param game */ public FixedTarget(UUID targetId, Game game) { + super(); this.targetId = targetId; this.initialized = true; this.zoneChangeCounter = game.getState().getZoneChangeCounter(targetId); } - public FixedTarget(final FixedTarget fixedTarget) { - this.targetId = fixedTarget.targetId; - this.zoneChangeCounter = fixedTarget.zoneChangeCounter; - this.initialized = fixedTarget.initialized; + public FixedTarget(final FixedTarget targetPointer) { + super(targetPointer); + + this.targetId = targetPointer.targetId; + this.zoneChangeCounter = targetPointer.zoneChangeCounter; + this.initialized = targetPointer.initialized; } @Override @@ -142,7 +149,7 @@ public class FixedTarget implements TargetPointer { } @Override - public TargetPointer copy() { + public FixedTarget copy() { return new FixedTarget(this); } @@ -173,5 +180,4 @@ public class FixedTarget implements TargetPointer { } return null; } - } diff --git a/Mage/src/main/java/mage/target/targetpointer/FixedTargets.java b/Mage/src/main/java/mage/target/targetpointer/FixedTargets.java index ccef9d4d40..c1075c4cb5 100644 --- a/Mage/src/main/java/mage/target/targetpointer/FixedTargets.java +++ b/Mage/src/main/java/mage/target/targetpointer/FixedTargets.java @@ -5,10 +5,6 @@ */ package mage.target.targetpointer; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.UUID; import mage.MageObject; import mage.MageObjectReference; import mage.abilities.Ability; @@ -18,10 +14,15 @@ import mage.constants.Zone; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.UUID; + /** * @author LevelX2 */ -public class FixedTargets implements TargetPointer { +public class FixedTargets extends TargetPointerImpl { final ArrayList targets = new ArrayList<>(); final ArrayList targetsNotInitialized = new ArrayList<>(); @@ -29,11 +30,15 @@ public class FixedTargets implements TargetPointer { private boolean initialized; public FixedTargets(UUID targetId) { + super(); + targetsNotInitialized.add(targetId); this.initialized = false; } public FixedTargets(Cards cards, Game game) { + super(); + for (UUID targetId : cards) { MageObjectReference mor = new MageObjectReference(targetId, game); targets.add(mor); @@ -42,6 +47,8 @@ public class FixedTargets implements TargetPointer { } public FixedTargets(List permanents, Game game) { + super(); + for (Permanent permanent : permanents) { MageObjectReference mor = new MageObjectReference(permanent.getId(), permanent.getZoneChangeCounter(game), game); targets.add(mor); @@ -50,6 +57,8 @@ public class FixedTargets implements TargetPointer { } public FixedTargets(Set cards, Game game) { + super(); + for (Card card : cards) { MageObjectReference mor = new MageObjectReference(card.getId(), card.getZoneChangeCounter(game), game); targets.add(mor); @@ -57,10 +66,12 @@ public class FixedTargets implements TargetPointer { this.initialized = true; } - private FixedTargets(final FixedTargets fixedTargets) { - this.targets.addAll(fixedTargets.targets); - this.targetsNotInitialized.addAll(fixedTargets.targetsNotInitialized); - this.initialized = fixedTargets.initialized; + private FixedTargets(final FixedTargets targetPointer) { + super(targetPointer); + + this.targets.addAll(targetPointer.targets); + this.targetsNotInitialized.addAll(targetPointer.targetsNotInitialized); + this.initialized = targetPointer.initialized; } @Override @@ -97,7 +108,7 @@ public class FixedTargets implements TargetPointer { } @Override - public TargetPointer copy() { + public FixedTargets copy() { return new FixedTargets(this); } diff --git a/Mage/src/main/java/mage/target/targetpointer/SecondTargetPointer.java b/Mage/src/main/java/mage/target/targetpointer/SecondTargetPointer.java index bbb54aa65e..4c1986845f 100644 --- a/Mage/src/main/java/mage/target/targetpointer/SecondTargetPointer.java +++ b/Mage/src/main/java/mage/target/targetpointer/SecondTargetPointer.java @@ -1,6 +1,5 @@ package mage.target.targetpointer; -import java.util.*; import mage.MageObject; import mage.abilities.Ability; import mage.cards.Card; @@ -8,7 +7,9 @@ import mage.constants.Zone; import mage.game.Game; import mage.game.permanent.Permanent; -public class SecondTargetPointer implements TargetPointer { +import java.util.*; + +public class SecondTargetPointer extends TargetPointerImpl { private Map zoneChangeCounter = new HashMap<>(); @@ -17,11 +18,14 @@ public class SecondTargetPointer implements TargetPointer { } public SecondTargetPointer() { + super(); } - public SecondTargetPointer(SecondTargetPointer firstTargetPointer) { + public SecondTargetPointer(final SecondTargetPointer targetPointer) { + super(targetPointer); + this.zoneChangeCounter = new HashMap<>(); - for (Map.Entry entry : firstTargetPointer.zoneChangeCounter.entrySet()) { + for (Map.Entry entry : targetPointer.zoneChangeCounter.entrySet()) { this.zoneChangeCounter.put(entry.getKey(), entry.getValue()); } } @@ -71,7 +75,7 @@ public class SecondTargetPointer implements TargetPointer { } @Override - public TargetPointer copy() { + public SecondTargetPointer copy() { return new SecondTargetPointer(this); } diff --git a/Mage/src/main/java/mage/target/targetpointer/TargetPointer.java b/Mage/src/main/java/mage/target/targetpointer/TargetPointer.java index c55e6a290b..a262afeabe 100644 --- a/Mage/src/main/java/mage/target/targetpointer/TargetPointer.java +++ b/Mage/src/main/java/mage/target/targetpointer/TargetPointer.java @@ -1,13 +1,15 @@ package mage.target.targetpointer; +import mage.abilities.Ability; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.util.Copyable; + import java.io.Serializable; import java.util.List; import java.util.UUID; -import mage.abilities.Ability; -import mage.game.Game; -import mage.game.permanent.Permanent; -public interface TargetPointer extends Serializable { +public interface TargetPointer extends Serializable, Copyable { void init(Game game, Ability source); @@ -34,4 +36,14 @@ public interface TargetPointer extends Serializable { * @return permanent */ Permanent getFirstTargetPermanentOrLKI(Game game, Ability source); + + /** + * Store text to target pointer (usefull to keep data for specific trigger, e.g. selected target name for rules) + * + * @param key + * @param value + */ + TargetPointer withData(String key, String value); + + String getData(String key); } diff --git a/Mage/src/main/java/mage/target/targetpointer/TargetPointerImpl.java b/Mage/src/main/java/mage/target/targetpointer/TargetPointerImpl.java new file mode 100644 index 0000000000..5cb7bdf4ee --- /dev/null +++ b/Mage/src/main/java/mage/target/targetpointer/TargetPointerImpl.java @@ -0,0 +1,33 @@ +package mage.target.targetpointer; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author JayDi85 + */ +public abstract class TargetPointerImpl implements TargetPointer { + + // Store custom data here. Use it to keep unique values for ability instances on stack (example: Gruul Ragebeast) + Map data = new HashMap<>(); + + public TargetPointerImpl() { + super(); + } + + public TargetPointerImpl(final TargetPointerImpl targetPointer) { + super(); + this.data.putAll(targetPointer.data); + } + + @Override + public String getData(String key) { + return this.data.getOrDefault(key, ""); + } + + @Override + public TargetPointer withData(String key, String value) { + this.data.put(key, value); + return this; + } +} diff --git a/Mage/src/main/java/mage/target/targetpointer/ThirdTargetPointer.java b/Mage/src/main/java/mage/target/targetpointer/ThirdTargetPointer.java index 31639c3dbb..db986897b0 100644 --- a/Mage/src/main/java/mage/target/targetpointer/ThirdTargetPointer.java +++ b/Mage/src/main/java/mage/target/targetpointer/ThirdTargetPointer.java @@ -5,11 +5,6 @@ */ package mage.target.targetpointer; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; import mage.MageObject; import mage.abilities.Ability; import mage.cards.Card; @@ -17,11 +12,12 @@ import mage.constants.Zone; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.*; + /** - * * @author LevelX2 */ -public class ThirdTargetPointer implements TargetPointer { +public class ThirdTargetPointer extends TargetPointerImpl { private Map zoneChangeCounter = new HashMap<>(); @@ -30,9 +26,12 @@ public class ThirdTargetPointer implements TargetPointer { } public ThirdTargetPointer() { + super(); } - public ThirdTargetPointer(ThirdTargetPointer targetPointer) { + public ThirdTargetPointer(final ThirdTargetPointer targetPointer) { + super(targetPointer); + this.zoneChangeCounter = new HashMap<>(); for (Map.Entry entry : targetPointer.zoneChangeCounter.entrySet()) { this.zoneChangeCounter.put(entry.getKey(), entry.getValue()); @@ -84,7 +83,7 @@ public class ThirdTargetPointer implements TargetPointer { } @Override - public TargetPointer copy() { + public ThirdTargetPointer copy() { return new ThirdTargetPointer(this); }