Skip to content

Commit

Permalink
[DSC] Implement The Lord of Pain. (#12940)
Browse files Browse the repository at this point in the history
Also adds "their" to the text that CardUtil.addArticle supports and fixes a range of influence bug in SpellCastAllTriggeredAbility.
  • Loading branch information
Grath committed Sep 29, 2024
1 parent 3ed75e6 commit e5a351f
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 1 deletion.
141 changes: 141 additions & 0 deletions Mage.Sets/src/mage/cards/t/TheLordOfPain.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
package mage.cards.t;

import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.common.SpellCastAllTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.CantGainLifeAllEffect;
import mage.constants.*;
import mage.abilities.keyword.MenaceAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.filter.FilterPlayer;
import mage.filter.FilterSpell;
import mage.filter.predicate.Predicate;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.MageObjectReferencePredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.stack.Spell;
import mage.game.stack.StackObject;
import mage.players.Player;
import mage.target.TargetPlayer;
import mage.target.targetpointer.FixedTarget;
import mage.watchers.common.SpellsCastWatcher;

/**
*
* @author Grath
*/
public final class TheLordOfPain extends CardImpl {
public TheLordOfPain(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{B}{R}");

this.supertype.add(SuperType.LEGENDARY);
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.ASSASSIN);
this.power = new MageInt(5);
this.toughness = new MageInt(5);

// Menace
this.addAbility(new MenaceAbility(false));

// Your opponents can't gain life.
this.addAbility(new SimpleStaticAbility(
new CantGainLifeAllEffect(Duration.WhileOnBattlefield, TargetController.OPPONENT)
));

// Whenever a player casts their first spell each turn, choose another target player. The Lord of Pain deals damage equal to that spell's mana value to the chosen player.
this.addAbility(new TheLordOfPainTriggeredAbility());
}

private TheLordOfPain(final TheLordOfPain card) {
super(card);
}

@Override
public TheLordOfPain copy() {
return new TheLordOfPain(this);
}
}

enum TheLordOfPainPredicate implements Predicate<StackObject> {
instance;

@Override
public boolean apply(StackObject input, Game game) {
return game.getState()
.getWatcher(SpellsCastWatcher.class)
.getCount(input.getControllerId()) == 1;
}
}

class TheLordOfPainTriggeredAbility extends SpellCastAllTriggeredAbility {
private static final FilterSpell filter = new FilterSpell("their first spell each turn");

static {
filter.add(TheLordOfPainPredicate.instance);
}

public TheLordOfPainTriggeredAbility() {
super(new TheLordOfPainEffect(), filter, false, SetTargetPointer.PLAYER);
}

protected TheLordOfPainTriggeredAbility(final TheLordOfPainTriggeredAbility ability) {
super(ability);
}

@Override
public TheLordOfPainTriggeredAbility copy() {
return new TheLordOfPainTriggeredAbility(this);
}

@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (super.checkTrigger(event, game)) {
Player controller = game.getPlayer(getControllerId());
Spell spell = (Spell)getEffects().get(0).getValue("spellCast");
if (controller != null) {
FilterPlayer filter2 = new FilterPlayer("another target player");
filter2.add(Predicates.not(new MageObjectReferencePredicate(spell.getControllerId(), game)));
TargetPlayer target = new TargetPlayer(1, 1, false, filter2);
controller.choose(Outcome.Damage, target, this, game);
getEffects().setTargetPointer(new FixedTarget(target.getFirstTarget()));
return true;
}
}
return false;
}
}

class TheLordOfPainEffect extends OneShotEffect {

TheLordOfPainEffect() {
super(Outcome.Benefit);
staticText = "choose another target player. {this} deals damage equal to that spell's mana value to the chosen player";
}

private TheLordOfPainEffect(final TheLordOfPainEffect effect) {
super(effect);
}

@Override
public TheLordOfPainEffect copy() {
return new TheLordOfPainEffect(this);
}

@Override
public boolean apply(Game game, Ability source) {
Spell spell = (Spell)this.getValue("spellCast");
if (spell != null) {
int cost = spell.getManaValue();
Player target = game.getPlayer(getTargetPointer().getFirst(game, source));
if (target != null) {
target.damage(cost, source.getSourceId(), source, game);
return true;
}
}
return false; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ private DuskmournHouseOfHorrorCommander() {
cards.add(new SetCardInfo("Temur War Shaman", 200, Rarity.RARE, mage.cards.t.TemurWarShaman.class));
cards.add(new SetCardInfo("Terminus", 70, Rarity.RARE, mage.cards.t.Terminus.class));
cards.add(new SetCardInfo("The Eldest Reborn", 139, Rarity.UNCOMMON, mage.cards.t.TheEldestReborn.class));
cards.add(new SetCardInfo("The Lord of Pain", 3, Rarity.MYTHIC, mage.cards.t.TheLordOfPain.class));
cards.add(new SetCardInfo("Theater of Horrors", 236, Rarity.RARE, mage.cards.t.TheaterOfHorrors.class));
cards.add(new SetCardInfo("They Came from the Pipes", 14, Rarity.RARE, mage.cards.t.TheyCameFromThePipes.class));
cards.add(new SetCardInfo("Thirst for Meaning", 129, Rarity.COMMON, mage.cards.t.ThirstForMeaning.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public boolean checkEventType(GameEvent event, Game game) {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Spell spell = game.getStack().getSpell(event.getTargetId());
if (!filter.match(spell, getControllerId(), this, game)) {
if (!filter.match(spell, getControllerId(), this, game)
|| !game.getState().getPlayersInRange(getControllerId(), game, false).contains(event.getPlayerId())) {
return false;
}
getEffects().setValue("spellCast", spell);
Expand Down
1 change: 1 addition & 0 deletions Mage/src/main/java/mage/util/CardUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,7 @@ public static String addArticle(String text) {
|| text.startsWith("any ")
|| text.startsWith("{this} ")
|| text.startsWith("your ")
|| text.startsWith("their ")
|| text.startsWith("one ")) {
return text;
}
Expand Down

0 comments on commit e5a351f

Please sign in to comment.