[WOE] Implement Talion, the Kindly Lord

This commit is contained in:
theelk801 2023-08-06 13:13:15 -04:00
parent 7f20d2fecb
commit c07e6be92b
2 changed files with 123 additions and 0 deletions

View file

@ -0,0 +1,122 @@
package mage.cards.t;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SpellCastOpponentTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.LoseLifeTargetControllerEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.filter.FilterSpell;
import mage.filter.predicate.ObjectSourcePlayer;
import mage.filter.predicate.ObjectSourcePlayerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.stack.StackObject;
import mage.players.Player;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class TalionTheKindlyLord extends CardImpl {
private static final FilterSpell filter
= new FilterSpell("a spell with mana value, power, or toughness equal to the chosen number");
static {
filter.add(TalionTheKindlyLordPredicate.instance);
}
public TalionTheKindlyLord(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{U}{B}");
this.supertype.add(SuperType.LEGENDARY);
this.subtype.add(SubType.FAERIE);
this.subtype.add(SubType.NOBLE);
this.power = new MageInt(3);
this.toughness = new MageInt(4);
// Flying
this.addAbility(FlyingAbility.getInstance());
// As Talion, the Kindly Lord enters the battlefield, choose a number between 1 and 10.
this.addAbility(new AsEntersBattlefieldAbility(new TalionTheKindlyLordEffect()));
// Whenever an opponent casts a spell with mana value, power, or toughness equal to the chosen number, that player loses 2 life and you draw a card.
Ability ability = new SpellCastOpponentTriggeredAbility(
Zone.BATTLEFIELD, new LoseLifeTargetControllerEffect(2)
.setText("that player loses 2 life"),
filter, false, SetTargetPointer.PLAYER
);
ability.addEffect(new DrawCardSourceControllerEffect(1).concatBy("and"));
this.addAbility(ability);
}
private TalionTheKindlyLord(final TalionTheKindlyLord card) {
super(card);
}
@Override
public TalionTheKindlyLord copy() {
return new TalionTheKindlyLord(this);
}
}
enum TalionTheKindlyLordPredicate implements ObjectSourcePlayerPredicate<StackObject> {
instance;
@Override
public boolean apply(ObjectSourcePlayer<StackObject> input, Game game) {
Object obj = game.getState().getValue(
"chosenNumber_" + input.getSource().getSourceId()
+ '_' + input.getSource().getSourceObjectZoneChangeCounter()
);
if (obj == null) {
return false;
}
int value = (Integer) obj;
return input.getObject().getManaValue() == value
|| input.getObject().getPower().getValue() == value
|| input.getObject().getToughness().getValue() == value;
}
}
class TalionTheKindlyLordEffect extends OneShotEffect {
TalionTheKindlyLordEffect() {
super(Outcome.Benefit);
staticText = "choose a number between 1 and 10";
}
private TalionTheKindlyLordEffect(final TalionTheKindlyLordEffect effect) {
super(effect);
}
@Override
public TalionTheKindlyLordEffect copy() {
return new TalionTheKindlyLordEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return true;
}
int numberChoice = controller.getAmount(1, 10, "Choose a number.", game);
game.getState().setValue("chosenNumber_" + source.getSourceId()
+ '_' + source.getSourceObjectZoneChangeCounter(), numberChoice);
Permanent permanent = game.getPermanentEntering(source.getSourceId());
if (permanent != null) {
permanent.addInfo("chosen players", "<font color = 'blue'>Chosen Number: " + numberChoice + "</font>", game);
game.informPlayers(permanent.getLogName() + ", chosen number: " + numberChoice);
}
return true;
}
}

View file

@ -29,6 +29,7 @@ public final class WildsOfEldraine extends ExpansionSet {
cards.add(new SetCardInfo("Restless Fortress", 259, Rarity.RARE, mage.cards.r.RestlessFortress.class)); cards.add(new SetCardInfo("Restless Fortress", 259, Rarity.RARE, mage.cards.r.RestlessFortress.class));
cards.add(new SetCardInfo("Sleight of Hand", 67, Rarity.COMMON, mage.cards.s.SleightOfHand.class)); cards.add(new SetCardInfo("Sleight of Hand", 67, Rarity.COMMON, mage.cards.s.SleightOfHand.class));
cards.add(new SetCardInfo("Swamp", 264, Rarity.LAND, mage.cards.basiclands.Swamp.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Swamp", 264, Rarity.LAND, mage.cards.basiclands.Swamp.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Talion, the Kindly Lord", 215, Rarity.MYTHIC, mage.cards.t.TalionTheKindlyLord.class));
cards.add(new SetCardInfo("Tough Cookie", 193, Rarity.UNCOMMON, mage.cards.t.ToughCookie.class)); cards.add(new SetCardInfo("Tough Cookie", 193, Rarity.UNCOMMON, mage.cards.t.ToughCookie.class));
} }