[APC] Add Captain's Maneuver (#8964)

This commit is contained in:
sprangg 2022-05-17 20:04:43 +03:00 committed by GitHub
parent 705816ead1
commit b9ac785807
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 94 additions and 0 deletions

View file

@ -0,0 +1,92 @@
package mage.cards.c;
import java.util.UUID;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
import mage.abilities.effects.RedirectionEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.filter.common.FilterCreaturePlayerOrPlaneswalker;
import mage.filter.predicate.other.AnotherTargetPredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.target.common.TargetAnyTarget;
/**
*
* @author sprangg
*/
public final class CaptainsManeuver extends CardImpl {
public CaptainsManeuver(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{R}{W}");
//The next X damage that would be dealt to target creature, planeswalker, or player this turn is dealt to another target creature, planeswalker, or player instead.
this.getSpellAbility().addEffect(new CaptainsManeuverEffect());
FilterCreaturePlayerOrPlaneswalker filter = new FilterCreaturePlayerOrPlaneswalker("creature, planeswalker or player (damage is redirected from)");
TargetAnyTarget target = new TargetAnyTarget(filter);
target.setTargetTag(1);
this.getSpellAbility().addTarget(target);
FilterCreaturePlayerOrPlaneswalker filter2 = new FilterCreaturePlayerOrPlaneswalker("another creature, planeswalker or player (damage is redirected to)");
filter2.getPlayerFilter().add(new AnotherTargetPredicate(2));
filter2.getPermanentFilter().add(new AnotherTargetPredicate(2));
TargetAnyTarget target2 = new TargetAnyTarget(filter2);
target2.setTargetTag(2);
this.getSpellAbility().addTarget(target2);
}
private CaptainsManeuver(final CaptainsManeuver card) {
super(card);
}
@Override
public CaptainsManeuver copy() {
return new CaptainsManeuver(this);
}
}
class CaptainsManeuverEffect extends RedirectionEffect {
protected MageObjectReference redirectToObject;
public CaptainsManeuverEffect() {
super(Duration.EndOfTurn, Integer.MAX_VALUE, UsageType.ONE_USAGE_ABSOLUTE);
staticText = "The next X damage that would be dealt to target creature, planeswalker, or player this turn is dealt to another target creature, planeswalker, or player instead.";
}
private CaptainsManeuverEffect(final CaptainsManeuverEffect effect) {
super(effect);
this.redirectToObject = effect.redirectToObject;
}
@Override
public CaptainsManeuverEffect copy() {
return new CaptainsManeuverEffect(this);
}
@Override
public void init(Ability source, Game game) {
super.init(source, game);
amountToRedirect = ManacostVariableValue.REGULAR.calculate(game, source, this);
redirectToObject = new MageObjectReference(source.getTargets().get(1).getFirstTarget(), game);
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getTargetId().equals(getTargetPointer().getFirst(game, source))) {
if (game.getPlayer(redirectToObject.getSourceId()) != null || game.getControllerId(redirectToObject.getSourceId()) != null) {
if (redirectToObject.equals(new MageObjectReference(source.getTargets().get(1).getFirstTarget(), game))) {
redirectTarget = source.getTargets().get(1);
return true;
}
}
}
return false;
}
}

View file

@ -35,6 +35,7 @@ public final class Apocalypse extends ExpansionSet {
cards.add(new SetCardInfo("Bloodfire Kavu", 58, Rarity.UNCOMMON, mage.cards.b.BloodfireKavu.class));
cards.add(new SetCardInfo("Bog Gnarr", 76, Rarity.COMMON, mage.cards.b.BogGnarr.class));
cards.add(new SetCardInfo("Brass Herald", 133, Rarity.UNCOMMON, mage.cards.b.BrassHerald.class));
cards.add(new SetCardInfo("Captain's Maneuver", 92, Rarity.UNCOMMON, mage.cards.c.CaptainsManeuver.class));
cards.add(new SetCardInfo("Caves of Koilos", 140, Rarity.RARE, mage.cards.c.CavesOfKoilos.class));
cards.add(new SetCardInfo("Ceta Disciple", 19, Rarity.COMMON, mage.cards.c.CetaDisciple.class));
cards.add(new SetCardInfo("Ceta Sanctuary", 20, Rarity.UNCOMMON, mage.cards.c.CetaSanctuary.class));

View file

@ -48,6 +48,7 @@ public final class Planechase extends ExpansionSet {
cards.add(new SetCardInfo("Bull Cerodon", 84, Rarity.UNCOMMON, mage.cards.b.BullCerodon.class));
cards.add(new SetCardInfo("Cabal Coffers", 132, Rarity.UNCOMMON, mage.cards.c.CabalCoffers.class));
cards.add(new SetCardInfo("Cadaverous Knight", 20, Rarity.COMMON, mage.cards.c.CadaverousKnight.class));
cards.add(new SetCardInfo("Captain's Maneuver", 85, Rarity.UNCOMMON, mage.cards.c.CaptainsManeuver.class));
cards.add(new SetCardInfo("Cerodon Yearling", 86, Rarity.COMMON, mage.cards.c.CerodonYearling.class));
cards.add(new SetCardInfo("Cinder Elemental", 51, Rarity.UNCOMMON, mage.cards.c.CinderElemental.class));
cards.add(new SetCardInfo("Cone of Flame", 52, Rarity.UNCOMMON, mage.cards.c.ConeOfFlame.class));