Legacy's Allure modified so its ability can be copied

This commit is contained in:
Evan Kranzler 2017-09-19 20:52:18 -04:00
parent 602eee1928
commit bd415215f5
4 changed files with 21 additions and 26 deletions

View file

@ -37,15 +37,12 @@ import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.ComparisonType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.TargetAdjustment;
import mage.constants.TargetController; import mage.constants.TargetController;
import mage.constants.Zone; import mage.constants.Zone;
import mage.counters.Counter; import mage.counters.CounterType;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.PowerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
/** /**
@ -53,39 +50,24 @@ import mage.target.common.TargetCreaturePermanent;
*/ */
public class LegacysAllure extends CardImpl { public class LegacysAllure extends CardImpl {
private final UUID originalId; private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature with power less than or equal to the number of treasure counters on {this}");
public LegacysAllure(UUID ownerId, CardSetInfo setInfo) { public LegacysAllure(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{U}{U}"); super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{U}{U}");
// At the beginning of your upkeep, you may put a treasure counter on Legacy's Allure. // At the beginning of your upkeep, you may put a treasure counter on Legacy's Allure.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new AddCountersSourceEffect(new Counter("treasure")), TargetController.YOU, true)); this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD,
new AddCountersSourceEffect(CounterType.TREASURE.createInstance(), true), TargetController.YOU, true));
//TODO: Make ability properly copiable
// Sacrifice Legacy's Allure: Gain control of target creature with power less than or equal to the number of treasure counters on Legacy's Allure. // Sacrifice Legacy's Allure: Gain control of target creature with power less than or equal to the number of treasure counters on Legacy's Allure.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new GainControlTargetEffect(Duration.EndOfGame, true), new SacrificeSourceCost()); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new GainControlTargetEffect(Duration.EndOfGame, true), new SacrificeSourceCost());
ability.addTarget(new TargetCreaturePermanent(new FilterCreaturePermanent("creature with power less than or equal to the number of treasure counters on " + getLogName()))); ability.addTarget(new TargetCreaturePermanent(0, 0, filter, false));
originalId = ability.getOriginalId(); ability.setTargetAdjustment(TargetAdjustment.TREASURE_COUNTER_POWER);
this.addAbility(ability); this.addAbility(ability);
} }
public LegacysAllure(final LegacysAllure card) { public LegacysAllure(final LegacysAllure card) {
super(card); super(card);
this.originalId = card.originalId;
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability.getOriginalId().equals(originalId)) {
Permanent sourcePermanent = game.getPermanent(ability.getSourceId());
if (sourcePermanent != null) {
int numbCounters = sourcePermanent.getCounters(game).getCount("treasure");
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature with power less than or equal to the number of treasure counters on " + getLogName());
filter.add(new PowerPredicate(ComparisonType.FEWER_THAN, numbCounters + 1));
ability.getTargets().clear();
ability.getTargets().add(new TargetCreaturePermanent(filter));
}
}
} }
@Override @Override

View file

@ -47,6 +47,7 @@ import mage.counters.Counters;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.filter.FilterPermanent; import mage.filter.FilterPermanent;
import mage.filter.FilterSpell; import mage.filter.FilterSpell;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.ColorPredicate; import mage.filter.predicate.mageobject.ColorPredicate;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate; import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.filter.predicate.mageobject.NamePredicate; import mage.filter.predicate.mageobject.NamePredicate;
@ -61,6 +62,7 @@ import mage.target.TargetCard;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.target.TargetSpell; import mage.target.TargetSpell;
import mage.target.common.TargetCardInOpponentsGraveyard; import mage.target.common.TargetCardInOpponentsGraveyard;
import mage.target.common.TargetCreaturePermanent;
import mage.util.GameLog; import mage.util.GameLog;
import mage.util.SubTypeList; import mage.util.SubTypeList;
import mage.watchers.Watcher; import mage.watchers.Watcher;
@ -405,6 +407,16 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
ability.addTarget(new TargetPermanent(0, xValue, permanentFilter, false)); ability.addTarget(new TargetPermanent(0, xValue, permanentFilter, false));
} }
break; break;
case TREASURE_COUNTER_POWER:
sourcePermanent = game.getPermanentOrLKIBattlefield(ability.getSourceId());
if (sourcePermanent != null) {
xValue = sourcePermanent.getCounters(game).getCount(CounterType.TREASURE);
FilterCreaturePermanent filter2 = new FilterCreaturePermanent("creature with power less than or equal to the number of treasure counters on {this}");
filter2.add(new PowerPredicate(ComparisonType.FEWER_THAN, xValue + 1));
ability.getTargets().clear();
ability.getTargets().add(new TargetCreaturePermanent(filter2));
}
break;
} }
} }

View file

@ -6,5 +6,5 @@ package mage.constants;
*/ */
public enum TargetAdjustment { public enum TargetAdjustment {
NONE, X_TARGETS, X_CMC_EQUAL_PERM, X_CMC_EQUAL_GY_CARD, X_POWER_LEQ, CHOSEN_NAME, CHOSEN_COLOR, VERSE_COUNTER_TARGETS NONE, X_TARGETS, X_CMC_EQUAL_PERM, X_CMC_EQUAL_GY_CARD, X_POWER_LEQ, CHOSEN_NAME, CHOSEN_COLOR, VERSE_COUNTER_TARGETS, TREASURE_COUNTER_POWER
} }

View file

@ -122,6 +122,7 @@ public enum CounterType {
TIME("time"), TIME("time"),
TOWER("tower"), TOWER("tower"),
TRAP("trap"), TRAP("trap"),
TREASURE("treasure"),
UNITY("unity"), UNITY("unity"),
VELOCITY("velocity"), VELOCITY("velocity"),
VERSE("verse"), VERSE("verse"),