implement [MH3] Lethal Throwdown (#12327)

This commit is contained in:
grimreap124 2024-05-31 20:13:42 +10:00 committed by GitHub
parent 48579814f9
commit 3d89256c84
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 97 additions and 4 deletions

View file

@ -0,0 +1,90 @@
package mage.cards.l;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.OrCost;
import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.filter.FilterPermanent;
import mage.filter.StaticFilters;
import mage.filter.predicate.permanent.ModifiedPredicate;
import mage.game.Game;
import mage.target.common.TargetCreatureOrPlaneswalker;
/**
*
* @author grimreap124
*/
public final class LethalThrowdown extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent("sacrifice a modified creature");
static {
filter.add(ModifiedPredicate.instance);
}
public LethalThrowdown(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[] { CardType.SORCERY }, "{B}");
// As an additional cost to cast this spell, sacrifice a creature or sacrifice a modified creature.
this.getSpellAbility()
.addCost(new OrCost("sacrifice a creature or sacrifice a modified creature",
new SacrificeTargetCost(StaticFilters.FILTER_PERMANENT_CREATURE)
.setText("sacrifice a creature"),
new SacrificeTargetCost(filter).setText("sacrifice a modified creature")));
// Destroy target creature or planeswalker. If the modified creature was sacrificed, draw a card.
this.getSpellAbility().addEffect(new LethalThrowdownEffect());
this.getSpellAbility().addEffect(new DestroyTargetEffect());
this.getSpellAbility().addTarget(new TargetCreatureOrPlaneswalker());
}
private LethalThrowdown(final LethalThrowdown card) {
super(card);
}
@Override
public LethalThrowdown copy() {
return new LethalThrowdown(this);
}
}
class LethalThrowdownEffect extends OneShotEffect {
LethalThrowdownEffect() {
super(Outcome.Benefit);
staticText = "Destroy target creature or planeswalker. If the modified creature was sacrificed, draw a card";
}
private LethalThrowdownEffect(final LethalThrowdownEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
for (Cost cost : source.getCosts()) {
if (cost instanceof OrCost) {
OrCost orCost = (OrCost) cost;
// This is a bit of a hack to check if the modified creature was sacrificed
// if this comes up anywhere else we should think of a more elegant solution
if (orCost.getSelectedCost().getText().equals("sacrifice a modified creature")) {
return new DrawCardSourceControllerEffect(1).apply(game, source);
}
}
}
return false;
}
@Override
public LethalThrowdownEffect copy() {
return new LethalThrowdownEffect(this);
}
}

View file

@ -142,6 +142,7 @@ public final class ModernHorizons3 extends ExpansionSet {
cards.add(new SetCardInfo("Kudo, King Among Bears", 192, Rarity.RARE, mage.cards.k.KudoKingAmongBears.class));
cards.add(new SetCardInfo("Laelia, the Blade Reforged", 281, Rarity.RARE, mage.cards.l.LaeliaTheBladeReforged.class));
cards.add(new SetCardInfo("Legion Leadership", 255, Rarity.UNCOMMON, mage.cards.l.LegionLeadership.class));
cards.add(new SetCardInfo("Lethal Throwdown", 99, Rarity.UNCOMMON, mage.cards.l.LethalThrowdown.class));
cards.add(new SetCardInfo("Lion Umbra", 160, Rarity.UNCOMMON, mage.cards.l.LionUmbra.class));
cards.add(new SetCardInfo("Mandibular Kite", 34, Rarity.COMMON, mage.cards.m.MandibularKite.class));
cards.add(new SetCardInfo("Marionette Apprentice", 100, Rarity.UNCOMMON, mage.cards.m.MarionetteApprentice.class));

View file

@ -48,6 +48,10 @@ public class OrCost implements Cost {
return description;
}
public Cost getSelectedCost() {
return selectedCost;
}
@Override
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
return costs.stream().anyMatch(cost -> cost.canPay(ability, source, controllerId, game));
@ -90,8 +94,7 @@ public class OrCost implements Cost {
Outcome.Detriment, sb.toString(), null,
CardUtil.getTextWithFirstCharUpperCase(usable.get(0).getText()),
CardUtil.getTextWithFirstCharUpperCase(usable.get(1).getText()),
ability, game
)) {
ability, game)) {
selectedCost = usable.get(0);
} else {
selectedCost = usable.get(1);
@ -110,8 +113,7 @@ public class OrCost implements Cost {
.collect(Collectors.toSet()));
controller.choose(Outcome.Neutral, choice, game);
selectedCost = costMap.getOrDefault(
CardUtil.getTextWithFirstCharLowerCase(choice.getChoice()), null
);
CardUtil.getTextWithFirstCharLowerCase(choice.getChoice()), null);
}
if (selectedCost == null) {
return false;