mirror of
https://github.com/correl/mage.git
synced 2024-12-24 03:00:14 +00:00
* 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);
This commit is contained in:
parent
9c56ff90d3
commit
a0a1dcb39f
12 changed files with 177 additions and 96 deletions
|
@ -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<UUID> 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<UUID> 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() {
|
||||
|
|
|
@ -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<UUID, CardView> {
|
|||
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<UUID> abilityTargets = new ArrayList<>();
|
||||
for (Effect effect : ability.getEffects()) {
|
||||
|
|
|
@ -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<UUID> targetList = new ArrayList<>();
|
||||
for (Effect effect : mode.getEffects()) {
|
||||
|
@ -102,13 +102,13 @@ public class StackAbilityView extends CardView {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!names.isEmpty()) {
|
||||
getRules().add("<i>Related objects: " + names.toString() + "</i>");
|
||||
}
|
||||
|
||||
// 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("<span color='green'><i>Chosen mode: " + mode.getEffects().getText(mode) + "</i></span>");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (HintUtils.ABILITY_HINTS_ENABLE) {
|
||||
List<String> abilityHints = new ArrayList<>();
|
||||
for (Hint hint : ability.getHints()) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<UUID, Integer> 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<UUID, Integer> entry : firstTargetPointer.zoneChangeCounter.entrySet()) {
|
||||
for (Map.Entry<UUID, Integer> 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<MageObjectReference> targets = new ArrayList<>();
|
||||
final ArrayList<UUID> 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<Permanent> 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<Card> 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<UUID, Integer> 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<UUID, Integer> entry : firstTargetPointer.zoneChangeCounter.entrySet()) {
|
||||
for (Map.Entry<UUID, Integer> 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<TargetPointer> {
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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<String, String> 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;
|
||||
}
|
||||
}
|
|
@ -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<UUID, Integer> 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<UUID, Integer> 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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue