Merge pull request #7285 from weirddan455/surtland-elementalist

[KHM] Implemented Surtland Elementalist
This commit is contained in:
Oleg Agafonov 2020-12-25 07:38:12 +01:00 committed by GitHub
commit fdcf2c616b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 99 additions and 0 deletions

View file

@ -0,0 +1,98 @@
package mage.cards.s;
import java.util.UUID;
import mage.ApprovingObject;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.AttacksTriggeredAbility;
import mage.abilities.costs.OrCost;
import mage.abilities.costs.common.RevealTargetFromHandCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.filter.FilterCard;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInHand;
/**
*
* @author weirddan455
*/
public final class SurtlandElementalist extends CardImpl {
private static final FilterCard filter = new FilterCard("a Giant card from your hand");
static {
filter.add(SubType.GIANT.getPredicate());
}
public SurtlandElementalist(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{U}{U}");
this.subtype.add(SubType.GIANT);
this.subtype.add(SubType.WIZARD);
this.power = new MageInt(8);
this.toughness = new MageInt(8);
// As an additional cost to cast this spell, reveal a Giant card from your hand or pay {2}.
this.getSpellAbility().addCost(new OrCost(
new RevealTargetFromHandCost(new TargetCardInHand(filter)),
new GenericManaCost(2),
"reveal a Giant card from your hand or pay {2}"));
// Whenever Surtland Elementalist attacks, you may cast an instant or sorcery spell from your hand without paying its mana cost.
this.addAbility(new AttacksTriggeredAbility(new SurtlandElementalistEffect(), true));
}
private SurtlandElementalist(final SurtlandElementalist card) {
super(card);
}
@Override
public SurtlandElementalist copy() {
return new SurtlandElementalist(this);
}
}
class SurtlandElementalistEffect extends OneShotEffect {
public SurtlandElementalistEffect () {
super(Outcome.PlayForFree);
this.staticText = "cast an instant or sorcery spell from your hand without paying its mana cost";
}
private SurtlandElementalistEffect(final SurtlandElementalistEffect effect) {
super(effect);
}
@Override
public SurtlandElementalistEffect copy() {
return new SurtlandElementalistEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
TargetCardInHand target = new TargetCardInHand(0, 1, StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY);
if (player.chooseTarget(Outcome.PlayForFree, target, source, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
boolean cardWasCast = player.cast(player.chooseAbilityForCast(card, game, true),
game, true, new ApprovingObject(source, game));
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
return cardWasCast;
}
}
}
return false;
}
}

View file

@ -47,6 +47,7 @@ public final class Kaldheim extends ExpansionSet {
cards.add(new SetCardInfo("Renegade Reaper", 386, Rarity.UNCOMMON, mage.cards.r.RenegadeReaper.class));
cards.add(new SetCardInfo("Showdown of the Skalds", 229, Rarity.RARE, mage.cards.s.ShowdownOfTheSkalds.class));
cards.add(new SetCardInfo("Starnheim Aspirant", 380, Rarity.UNCOMMON, mage.cards.s.StarnheimAspirant.class));
cards.add(new SetCardInfo("Surtland Elementalist", 375, Rarity.RARE, mage.cards.s.SurtlandElementalist.class));
cards.add(new SetCardInfo("Surtland Flinger", 377, Rarity.RARE, mage.cards.s.SurtlandFlinger.class));
}
}