[OTJ] Implement Rush of Dread

This commit is contained in:
theelk801 2024-04-01 16:20:53 -04:00
parent aaaf471a89
commit 03b99aa4b2
2 changed files with 119 additions and 0 deletions

View file

@ -0,0 +1,118 @@
package mage.cards.r;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.LoseHalfLifeTargetEffect;
import mage.abilities.effects.common.SacrificeEffect;
import mage.abilities.keyword.SpreeAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetOpponent;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class RushOfDread extends CardImpl {
public RushOfDread(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{B}{B}");
// Spree
this.addAbility(new SpreeAbility(this));
// + {1} -- Target opponent sacrifices half the creatures they control, rounded up.
this.getSpellAbility().addEffect(new RushOfDreadSacrificeEffect());
this.getSpellAbility().addTarget(new TargetOpponent());
this.getSpellAbility().withFirstModeCost(new GenericManaCost(1));
// + {2} -- Target opponent discards half the cards in their hand, rounded up.
this.getSpellAbility().addMode(new Mode(new RushOfDreadDiscardEffect())
.addTarget(new TargetOpponent())
.withCost(new GenericManaCost(2)));
// + {2} -- Target opponent loses half their life, rounded up.
this.getSpellAbility().addMode(new Mode(new LoseHalfLifeTargetEffect())
.addTarget(new TargetOpponent())
.withCost(new GenericManaCost(2)));
}
private RushOfDread(final RushOfDread card) {
super(card);
}
@Override
public RushOfDread copy() {
return new RushOfDread(this);
}
}
class RushOfDreadSacrificeEffect extends OneShotEffect {
RushOfDreadSacrificeEffect() {
super(Outcome.Benefit);
staticText = "target opponent sacrifices half the creatures they control, rounded up";
}
private RushOfDreadSacrificeEffect(final RushOfDreadSacrificeEffect effect) {
super(effect);
}
@Override
public RushOfDreadSacrificeEffect copy() {
return new RushOfDreadSacrificeEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source));
if (opponent == null) {
return false;
}
int creatures = game
.getBattlefield()
.count(StaticFilters.FILTER_CONTROLLED_CREATURES, opponent.getId(), source, game);
int toSac = Math.floorDiv(creatures, 2) + creatures % 2;
return new SacrificeEffect(StaticFilters.FILTER_PERMANENT_CREATURE, toSac, "")
.setTargetPointer(new FixedTarget(opponent.getId()))
.apply(game, source);
}
}
class RushOfDreadDiscardEffect extends OneShotEffect {
RushOfDreadDiscardEffect() {
super(Outcome.Benefit);
staticText = "target opponent discards half the cards in their hand, rounded up";
}
private RushOfDreadDiscardEffect(final RushOfDreadDiscardEffect effect) {
super(effect);
}
@Override
public RushOfDreadDiscardEffect copy() {
return new RushOfDreadDiscardEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source));
return opponent != null
&& !opponent.getHand().isEmpty()
&& opponent.discard(
Math.floorDiv(opponent.getHand().size(), 2) +
opponent.getHand().size() % 2,
false, false, source, game
).size() > 0;
}
}

View file

@ -185,6 +185,7 @@ public final class OutlawsOfThunderJunction extends ExpansionSet {
cards.add(new SetCardInfo("Rodeo Pyromancers", 143, Rarity.COMMON, mage.cards.r.RodeoPyromancers.class));
cards.add(new SetCardInfo("Rooftop Assassin", 103, Rarity.COMMON, mage.cards.r.RooftopAssassin.class));
cards.add(new SetCardInfo("Roxanne, Starfall Savant", 228, Rarity.RARE, mage.cards.r.RoxanneStarfallSavant.class));
cards.add(new SetCardInfo("Rush of Dread", 104, Rarity.RARE, mage.cards.r.RushOfDread.class));
cards.add(new SetCardInfo("Rustler Rampage", 27, Rarity.UNCOMMON, mage.cards.r.RustlerRampage.class));
cards.add(new SetCardInfo("Ruthless Lawbringer", 229, Rarity.UNCOMMON, mage.cards.r.RuthlessLawbringer.class));
cards.add(new SetCardInfo("Sandstorm Verge", 263, Rarity.UNCOMMON, mage.cards.s.SandstormVerge.class));