[KHM] Implemented Wolverine Riders

This commit is contained in:
Evan Kranzler 2021-01-27 10:12:08 -05:00
parent 11b8078d96
commit 826e509ee6
3 changed files with 98 additions and 17 deletions

View file

@ -0,0 +1,83 @@
package mage.cards.w;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.EntersBattlefieldControlledTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.GainLifeEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.TargetController;
import mage.filter.FilterPermanent;
import mage.filter.predicate.permanent.AnotherPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.ElfToken;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class WolverineRiders extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent(SubType.ELF, "");
static {
filter.add(AnotherPredicate.instance);
}
public WolverineRiders(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{G}{G}");
this.subtype.add(SubType.ELF);
this.subtype.add(SubType.WARRIOR);
this.power = new MageInt(4);
this.toughness = new MageInt(4);
// At the beginning of each upkeep, create a 1/1 green Elf Warrior creature token.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(
new CreateTokenEffect(new ElfToken()), TargetController.EACH_PLAYER, false
));
// Whenever another Elf enters the battlefield under your control, you gain life equal to its toughness.
this.addAbility(new EntersBattlefieldControlledTriggeredAbility(
new GainLifeEffect(WolverineRidersValue.instance), filter, "Whenever another Elf " +
"enters the battlefield under your control, you gain life equal to its toughness."
));
}
private WolverineRiders(final WolverineRiders card) {
super(card);
}
@Override
public WolverineRiders copy() {
return new WolverineRiders(this);
}
}
enum WolverineRidersValue implements DynamicValue {
instance;
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
Permanent permanent = (Permanent) effect.getValue("permanentEnteringBattlefield");
return permanent == null ? 0 : permanent.getToughness().getValue();
}
@Override
public WolverineRidersValue copy() {
return instance;
}
@Override
public String getMessage() {
return "";
}
}

View file

@ -28,5 +28,6 @@ public final class KaldheimCommander extends ExpansionSet {
cards.add(new SetCardInfo("Sage of the Beyond", 6, Rarity.RARE, mage.cards.s.SageOfTheBeyond.class)); cards.add(new SetCardInfo("Sage of the Beyond", 6, Rarity.RARE, mage.cards.s.SageOfTheBeyond.class));
cards.add(new SetCardInfo("Spectral Deluge", 7, Rarity.RARE, mage.cards.s.SpectralDeluge.class)); cards.add(new SetCardInfo("Spectral Deluge", 7, Rarity.RARE, mage.cards.s.SpectralDeluge.class));
cards.add(new SetCardInfo("Stoic Farmer", 5, Rarity.RARE, mage.cards.s.StoicFarmer.class)); cards.add(new SetCardInfo("Stoic Farmer", 5, Rarity.RARE, mage.cards.s.StoicFarmer.class));
cards.add(new SetCardInfo("Wolverine Riders", 14, Rarity.RARE, mage.cards.w.WolverineRiders.class));
} }
} }

View file

@ -84,25 +84,22 @@ public class EntersBattlefieldAllTriggeredAbility extends TriggeredAbilityImpl {
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
UUID targetId = event.getTargetId(); UUID targetId = event.getTargetId();
Permanent permanent = game.getPermanent(targetId); Permanent permanent = game.getPermanent(targetId);
if (permanent != null && filter.match(permanent, getSourceId(), getControllerId(), game)) { if (permanent == null || !filter.match(permanent, getSourceId(), getControllerId(), game)) {
for (Effect effect : this.getEffects()) { return false;
effect.setValue("permanentEnteringBattlefield", permanent); }
} this.getEffects().setValue("permanentEnteringBattlefield", permanent);
if (setTargetPointer != SetTargetPointer.NONE) { if (setTargetPointer == SetTargetPointer.NONE) {
for (Effect effect : this.getEffects()) {
switch (setTargetPointer) {
case PLAYER:
effect.setTargetPointer(new FixedTarget(permanent.getControllerId()));
break;
case PERMANENT:
effect.setTargetPointer(new FixedTarget(permanent, game));
break;
}
}
}
return true; return true;
} }
return false; switch (setTargetPointer) {
case PLAYER:
this.getEffects().setTargetPointer(new FixedTarget(permanent.getControllerId()));
break;
case PERMANENT:
this.getEffects().setTargetPointer(new FixedTarget(permanent, game));
break;
}
return true;
} }
@Override @Override