Implemented Gideon's Triumph

This commit is contained in:
Evan Kranzler 2019-04-01 14:53:23 -04:00
parent 13ff59584c
commit a54bb5024a
2 changed files with 122 additions and 0 deletions

View file

@ -0,0 +1,121 @@
package mage.cards.g;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.SacrificeEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.WatcherScope;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledPlaneswalkerPermanent;
import mage.filter.predicate.Predicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.target.common.TargetOpponent;
import mage.watchers.Watcher;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class GideonsTriumph extends CardImpl {
public GideonsTriumph(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{W}");
// Target opponent sacrifices a creature that attacked or blocked this turn. If you control a Gideon planeswalker, that player sacrifices two of those creatures instead.
this.getSpellAbility().addEffect(new GideonsTriumphEffect());
this.getSpellAbility().addTarget(new TargetOpponent());
}
private GideonsTriumph(final GideonsTriumph card) {
super(card);
}
@Override
public GideonsTriumph copy() {
return new GideonsTriumph(this);
}
}
class GideonsTriumphEffect extends OneShotEffect {
private static final FilterControlledPlaneswalkerPermanent filter
= new FilterControlledPlaneswalkerPermanent(SubType.GIDEON);
private static final FilterPermanent filter2
= new FilterPermanent("creature that attacked or blocked this turn");
GideonsTriumphEffect() {
super(Outcome.Benefit);
staticText = "Target opponent sacrifices a creature that attacked or blocked this turn. " +
"If you control a Gideon planeswalker, that player sacrifices two of those creatures instead.";
}
private GideonsTriumphEffect(final GideonsTriumphEffect effect) {
super(effect);
}
@Override
public GideonsTriumphEffect copy() {
return new GideonsTriumphEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
int count = 1;
if (!game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game).isEmpty()) {
count++;
}
return new SacrificeEffect(filter2, count, "Target opponent").apply(game, source);
}
}
enum GideonsTriumphCondition implements Predicate<Permanent> {
instance;
@Override
public boolean apply(Permanent input, Game game) {
GideonsTriumphWatcher watcher = game.getState().getWatcher(GideonsTriumphWatcher.class);
return input.isCreature() && watcher.attackedOrBlockedThisTurn(input, game);
}
}
class GideonsTriumphWatcher extends Watcher {
private final Set<MageObjectReference> attackedOrBlockedThisTurnCreatures = new HashSet<>();
public GideonsTriumphWatcher() {
super(WatcherScope.GAME);
}
private GideonsTriumphWatcher(final GideonsTriumphWatcher watcher) {
super(watcher);
this.attackedOrBlockedThisTurnCreatures.addAll(watcher.attackedOrBlockedThisTurnCreatures);
}
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED || event.getType() == GameEvent.EventType.BLOCKER_DECLARED) {
this.attackedOrBlockedThisTurnCreatures.add(new MageObjectReference(event.getSourceId(), game));
}
}
boolean attackedOrBlockedThisTurn(Permanent permanent, Game game) {
return this.attackedOrBlockedThisTurnCreatures.contains(new MageObjectReference(permanent, game));
}
@Override
public GideonsTriumphWatcher copy() {
return new GideonsTriumphWatcher(this);
}
}

View file

@ -39,6 +39,7 @@ public final class WarOfTheSpark extends ExpansionSet {
cards.add(new SetCardInfo("Forest", 262, Rarity.LAND, mage.cards.basiclands.Forest.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Forest", 262, Rarity.LAND, mage.cards.basiclands.Forest.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Forest", 263, Rarity.LAND, mage.cards.basiclands.Forest.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Forest", 263, Rarity.LAND, mage.cards.basiclands.Forest.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Forest", 264, Rarity.LAND, mage.cards.basiclands.Forest.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Forest", 264, Rarity.LAND, mage.cards.basiclands.Forest.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Gideon's Triumph", 15, Rarity.UNCOMMON, mage.cards.g.GideonsTriumph.class));
cards.add(new SetCardInfo("Herald of the Dreadhorde", 93, Rarity.COMMON, mage.cards.h.HeraldOfTheDreadhorde.class)); cards.add(new SetCardInfo("Herald of the Dreadhorde", 93, Rarity.COMMON, mage.cards.h.HeraldOfTheDreadhorde.class));
cards.add(new SetCardInfo("Honor the God-Pharaoh", 132, Rarity.COMMON, mage.cards.h.HonorTheGodPharaoh.class)); cards.add(new SetCardInfo("Honor the God-Pharaoh", 132, Rarity.COMMON, mage.cards.h.HonorTheGodPharaoh.class));
cards.add(new SetCardInfo("Ignite the Beacon", 18, Rarity.RARE, mage.cards.i.IgniteTheBeacon.class)); cards.add(new SetCardInfo("Ignite the Beacon", 18, Rarity.RARE, mage.cards.i.IgniteTheBeacon.class));