implement [M3C] Localized Destruction (#12333)

This commit is contained in:
grimreap124 2024-05-31 20:14:10 +10:00 committed by GitHub
parent 3d89256c84
commit 0e9f26b5e8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 107 additions and 0 deletions

View file

@ -0,0 +1,106 @@
package mage.cards.l;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.PayEnergyCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DestroyAllEffect;
import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
import mage.abilities.effects.common.counter.GetEnergyCountersControllerEffect;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.ComparisonType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.counters.CounterType;
import mage.filter.FilterPermanent;
import mage.filter.StaticFilters;
import mage.filter.predicate.mageobject.PowerPredicate;
import mage.game.Game;
import mage.players.Player;
/**
*
* @author grimreap124
*/
public final class LocalizedDestruction extends CardImpl {
public LocalizedDestruction(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[] { CardType.SORCERY }, "{3}{W}{W}");
// You get {E}, then you may pay one or more {E}. If you do, each creature you control with power equal to the amount of paid this way gains indestructible until end of turn.
// You get {E}
this.getSpellAbility().addEffect(new GetEnergyCountersControllerEffect(1));
// then you may pay one or more {E}. If you do, each creature you control with power equal to the amount of paid this way gains indestructible until end of turn.
this.getSpellAbility().addEffect(new LocalizedDestructionEffect());
// Destroy all creatures.
this.getSpellAbility().addEffect(new DestroyAllEffect(StaticFilters.FILTER_PERMANENT_CREATURES));
}
private LocalizedDestruction(final LocalizedDestruction card) {
super(card);
}
@Override
public LocalizedDestruction copy() {
return new LocalizedDestruction(this);
}
}
class LocalizedDestructionEffect extends OneShotEffect {
LocalizedDestructionEffect() {
super(Outcome.AddAbility);
this.staticText = ", then you may pay one or more {E}. If you do, each creature you control with power equal to the amount of paid this way gains indestructible until end of turn";
}
private LocalizedDestructionEffect(final LocalizedDestructionEffect effect) {
super(effect);
}
@Override
public LocalizedDestructionEffect copy() {
return new LocalizedDestructionEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
int totalEnergy = controller.getCountersCount(CounterType.ENERGY);
if (totalEnergy == 0) {
return false;
}
if (!controller.chooseUse(this.getOutcome(),
"Pay 1 or more {E}? Each creature you control with power equal to the amount of paid this way gains indestructible until end of turn",
source, game)) {
return true;
}
int numberToPay = controller.getAmount(1, totalEnergy,
"Pay one or more {E}", game);
Cost cost = new PayEnergyCost(numberToPay);
if (cost.pay(source, game, source, source.getControllerId(), true)) {
FilterPermanent filter = new FilterPermanent();
filter.add(new PowerPredicate(ComparisonType.EQUAL_TO, numberToPay));
game.addEffect(new GainAbilityControlledEffect(
IndestructibleAbility.getInstance(), Duration.EndOfTurn,
filter), source);
}
return true;
}
}

View file

@ -67,6 +67,7 @@ public final class ModernHorizons3Commander extends ExpansionSet {
cards.add(new SetCardInfo("Jyoti, Moag Ancient", 8, Rarity.MYTHIC, mage.cards.j.JyotiMoagAncient.class));
cards.add(new SetCardInfo("Legion Loyalty", 171, Rarity.MYTHIC, mage.cards.l.LegionLoyalty.class));
cards.add(new SetCardInfo("Lightning Runner", 215, Rarity.MYTHIC, mage.cards.l.LightningRunner.class));
cards.add(new SetCardInfo("Localized Destruction", 41, Rarity.RARE, mage.cards.l.LocalizedDestruction.class));
cards.add(new SetCardInfo("March from Velis Vel", 48, Rarity.RARE, mage.cards.m.MarchFromVelisVel.class));
cards.add(new SetCardInfo("Midnight Clock", 189, Rarity.RARE, mage.cards.m.MidnightClock.class));
cards.add(new SetCardInfo("Myr Battlesphere", 301, Rarity.RARE, mage.cards.m.MyrBattlesphere.class));