[FIN] Implement Self Destruct

This commit is contained in:
theelk801 2025-05-18 09:46:56 -04:00
parent ce835282bb
commit d5dc914dd6
2 changed files with 96 additions and 0 deletions

View file

@ -0,0 +1,95 @@
package mage.cards.s;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.filter.common.FilterAnyTarget;
import mage.filter.predicate.other.AnotherTargetPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetAnyTarget;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.targetpointer.EachTargetPointer;
import java.util.List;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class SelfDestruct extends CardImpl {
private static final FilterAnyTarget filter = new FilterAnyTarget("any other target");
static {
filter.getPermanentFilter().add(new AnotherTargetPredicate(2));
filter.getPlayerFilter().add(new AnotherTargetPredicate(2));
}
public SelfDestruct(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{R}");
// Target creature you control deals X damage to any other target and X damage to itself, where X is its power.
this.getSpellAbility().addEffect(new SelfDestructEffect());
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent());
this.getSpellAbility().addTarget(new TargetAnyTarget().setTargetTag(2));
}
private SelfDestruct(final SelfDestruct card) {
super(card);
}
@Override
public SelfDestruct copy() {
return new SelfDestruct(this);
}
}
class SelfDestructEffect extends OneShotEffect {
SelfDestructEffect() {
super(Outcome.Benefit);
staticText = "target creature you control deals X damage " +
"to any other target and X damage to itself, where X is its power";
this.setTargetPointer(new EachTargetPointer());
}
private SelfDestructEffect(final SelfDestructEffect effect) {
super(effect);
}
@Override
public SelfDestructEffect copy() {
return new SelfDestructEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
List<UUID> targets = this.getTargetPointer().getTargets(game, source);
if (targets.size() < 2) {
return false;
}
Permanent creature = game.getPermanent(targets.get(0));
if (creature == null) {
return false;
}
int power = creature.getPower().getValue();
if (power < 1) {
return false;
}
Permanent permanent = game.getPermanent(targets.get(1));
if (permanent != null) {
permanent.damage(power, creature.getId(), source, game);
}
Player player = game.getPlayer(targets.get(1));
if (player != null) {
player.damage(power, creature.getId(), source, game);
}
permanent.damage(power, permanent.getId(), source, game);
return true;
}
}

View file

@ -216,6 +216,7 @@ public final class FinalFantasy extends ExpansionSet {
cards.add(new SetCardInfo("Sazh Katzroy", 199, Rarity.RARE, mage.cards.s.SazhKatzroy.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Sazh Katzroy", 472, Rarity.RARE, mage.cards.s.SazhKatzroy.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Sazh's Chocobo", 200, Rarity.UNCOMMON, mage.cards.s.SazhsChocobo.class));
cards.add(new SetCardInfo("Self-Destruct", 157, Rarity.UNCOMMON, mage.cards.s.SelfDestruct.class));
cards.add(new SetCardInfo("Sephiroth's Intervention", 116, Rarity.COMMON, mage.cards.s.SephirothsIntervention.class));
cards.add(new SetCardInfo("Sephiroth, Fabled SOLDIER", 115, Rarity.MYTHIC, mage.cards.s.SephirothFabledSOLDIER.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Sephiroth, Fabled SOLDIER", 317, Rarity.MYTHIC, mage.cards.s.SephirothFabledSOLDIER.class, NON_FULL_USE_VARIOUS));