Rewrote Evolving Adaptive. Closes #10080

This commit is contained in:
PurpleCrowbar 2023-02-28 01:33:33 +00:00
parent d40ca742b3
commit eaa001aa14

View file

@ -1,6 +1,7 @@
package mage.cards.e;
import mage.MageInt;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.*;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
@ -11,9 +12,10 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.mageobject.AnotherPredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
@ -21,29 +23,30 @@ import mage.game.permanent.Permanent;
import java.util.UUID;
/**
* @author PurpleCrowbar
*/
public class EvolvingAdaptive extends CardImpl {
private static final DynamicValue oilCounters = new CountersSourceCount(CounterType.OIL);
public EvolvingAdaptive(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{G}");
this.addSubType(SubType.PHYREXIAN);
this.addSubType(SubType.WARRIOR);
this.subtype.add(SubType.PHYREXIAN, SubType.WARRIOR);
this.power = new MageInt(0);
this.toughness = new MageInt(0);
//Evolving Adaptive enters the battlefield with an oil counter on it.
// Evolving Adaptive enters the battlefield with an oil counter on it.
this.addAbility(new EntersBattlefieldAbility(
new AddCountersSourceEffect(CounterType.OIL.createInstance()),
"with an oil counter on it"
));
//Evolving Adaptive gets +1/+1 for each oil counter on it.
// Evolving Adaptive gets +1/+1 for each oil counter on it.
DynamicValue oilCounters = new CountersSourceCount(CounterType.OIL);
this.addAbility(new SimpleStaticAbility(new BoostSourceEffect(oilCounters, oilCounters, Duration.WhileOnBattlefield)
.setText("{this} gets +1/+1 for each oil counter on it")));
//Whenever another creature enters the battlefield under your control, if that creature has greater power or
//toughness than Evolving Adaptive, put an oil counter on Evolving Adaptive.
// Whenever another creature enters the battlefield under your control, if that creature has greater power or
// toughness than Evolving Adaptive, put an oil counter on Evolving Adaptive.
this.addAbility(new EvolvingAdaptiveTriggeredAbility());
}
@ -57,39 +60,42 @@ public class EvolvingAdaptive extends CardImpl {
}
}
class EvolvingAdaptiveTriggeredAbility extends EntersBattlefieldControlledTriggeredAbility {
class EvolvingAdaptiveTriggeredAbility extends TriggeredAbilityImpl {
private static final FilterPermanent filter = new FilterCreaturePermanent("another creature");
private static final FilterPermanent filter = new FilterControlledCreaturePermanent("another creature you control");
static {
filter.add(AnotherPredicate.instance);
}
public EvolvingAdaptiveTriggeredAbility() {
super(new AddCountersSourceEffect(CounterType.OIL.createInstance()), filter);
super(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.OIL.createInstance()));
this.setTriggerPhrase("Whenever another creature enters the battlefield under your " +
"control, if that creature has greater power or toughness than {this}, ");
}
public EvolvingAdaptiveTriggeredAbility(final EntersBattlefieldControlledTriggeredAbility ability) {
public EvolvingAdaptiveTriggeredAbility(final EvolvingAdaptiveTriggeredAbility ability) {
super(ability);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent enteringCreature = game.getPermanent(event.getSourceId());
Permanent permanent = getSourcePermanentIfItStillExists(game);
if (permanent != null){
if (!(enteringCreature.getPower().getValue() > permanent.getPower().getValue()) &&
!(enteringCreature.getToughness().getValue() > permanent.getToughness().getValue())) {
return false;
}
}
return super.checkTrigger(event, game);
}
@Override
public EvolvingAdaptiveTriggeredAbility copy() {
return new EvolvingAdaptiveTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent enteringCreature = game.getPermanent(event.getTargetId());
if (enteringCreature == null || !filter.match(enteringCreature, getControllerId(), this, game)) {
return false;
}
Permanent permanent = getSourcePermanentIfItStillExists(game);
return !(enteringCreature.getPower().getValue() <= permanent.getPower().getValue() &&
enteringCreature.getToughness().getValue() <= permanent.getToughness().getValue());
}
}