[MIC] Implemented Prowling Geistcatcher

This commit is contained in:
Evan Kranzler 2021-09-27 08:40:16 -04:00
parent 9bcd7e0dcd
commit 11d5fc7eae
3 changed files with 131 additions and 7 deletions

View file

@ -0,0 +1,120 @@
package mage.cards.p;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.LeavesBattlefieldTriggeredAbility;
import mage.abilities.common.SacrificePermanentTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.PermanentToken;
import mage.players.Player;
import mage.util.CardUtil;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class ProwlingGeistcatcher extends CardImpl {
public ProwlingGeistcatcher(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{B}");
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.ROGUE);
this.power = new MageInt(2);
this.toughness = new MageInt(4);
// Whenever you sacrifice another creature, exile it. If that creature was a token, put a +1/+1 counter on Prowling Geistcatcher.
this.addAbility(new SacrificePermanentTriggeredAbility(
new ProwlingGeistcatcherExileEffect(),
StaticFilters.FILTER_CONTROLLED_ANOTHER_CREATURE, true
));
// When Prowling Geistcatcher leaves the battlefield, return each card exiled with it to the battlefield under your control.
this.addAbility(new LeavesBattlefieldTriggeredAbility(new ProwlingGeistcatcherReturnEffect(), false));
}
private ProwlingGeistcatcher(final ProwlingGeistcatcher card) {
super(card);
}
@Override
public ProwlingGeistcatcher copy() {
return new ProwlingGeistcatcher(this);
}
}
class ProwlingGeistcatcherExileEffect extends OneShotEffect {
ProwlingGeistcatcherExileEffect() {
super(Outcome.Benefit);
staticText = "exile it. If that creature was a token, put a +1/+1 counter on {this}";
}
private ProwlingGeistcatcherExileEffect(final ProwlingGeistcatcherExileEffect effect) {
super(effect);
}
@Override
public ProwlingGeistcatcherExileEffect copy() {
return new ProwlingGeistcatcherExileEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Card card = game.getCard(getTargetPointer().getFirst(game, source));
if (player != null && card != null) {
player.moveCardsToExile(
card, source, game, true,
CardUtil.getExileZoneId(game, source),
CardUtil.getSourceLogName(game, source)
);
}
Permanent exiled = (Permanent) getValue("sacrificedPermanent");
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
if (exiled instanceof PermanentToken && permanent != null) {
permanent.addCounters(CounterType.P1P1.createInstance(), source, game);
}
return true;
}
}
class ProwlingGeistcatcherReturnEffect extends OneShotEffect {
ProwlingGeistcatcherReturnEffect() {
super(Outcome.Benefit);
staticText = "return each card exiled with it to the battlefield under your control";
}
private ProwlingGeistcatcherReturnEffect(final ProwlingGeistcatcherReturnEffect effect) {
super(effect);
}
@Override
public ProwlingGeistcatcherReturnEffect copy() {
return new ProwlingGeistcatcherReturnEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
return player.moveCards(game.getExile().getExileZone(
CardUtil.getExileZoneId(game, source)
), Zone.BATTLEFIELD, source, game);
}
}

View file

@ -114,6 +114,7 @@ public final class MidnightHuntCommander extends ExpansionSet {
cards.add(new SetCardInfo("Orzhov Advokist", 91, Rarity.UNCOMMON, mage.cards.o.OrzhovAdvokist.class));
cards.add(new SetCardInfo("Overseer of the Damned", 127, Rarity.RARE, mage.cards.o.OverseerOfTheDamned.class));
cards.add(new SetCardInfo("Path of Ancestry", 178, Rarity.COMMON, mage.cards.p.PathOfAncestry.class));
cards.add(new SetCardInfo("Prowling Geistcatcher", 21, Rarity.RARE, mage.cards.p.ProwlingGeistcatcher.class));
cards.add(new SetCardInfo("Ravenous Rotbelly", 22, Rarity.RARE, mage.cards.r.RavenousRotbelly.class));
cards.add(new SetCardInfo("Return to Dust", 92, Rarity.UNCOMMON, mage.cards.r.ReturnToDust.class));
cards.add(new SetCardInfo("Riders of Gavony", 93, Rarity.RARE, mage.cards.r.RidersOfGavony.class));

View file

@ -7,6 +7,7 @@ import mage.filter.FilterPermanent;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
/**
@ -50,14 +51,16 @@ public class SacrificePermanentTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (isControlledBy(event.getPlayerId())
&& filter.match(game.getPermanentOrLKIBattlefield(event.getTargetId()), getSourceId(), getControllerId(), game)) {
if (setTargetPointer) {
this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId(), game));
}
return true;
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getTargetId());
if (!isControlledBy(event.getPlayerId()) || permanent == null
|| !filter.match(permanent, getSourceId(), getControllerId(), game)) {
return false;
}
return false;
this.getEffects().setValue("sacrificedPermanent", permanent);
if (setTargetPointer) {
this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId(), game));
}
return true;
}
@Override