mirror of
https://github.com/magefree/mage.git
synced 2026-01-24 12:19:59 -08:00
[ECL] Implement Requiting Hex
This commit is contained in:
parent
c60a4cfe60
commit
68b30daac1
4 changed files with 176 additions and 0 deletions
53
Mage.Sets/src/mage/cards/r/RequitingHex.java
Normal file
53
Mage.Sets/src/mage/cards/r/RequitingHex.java
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
package mage.cards.r;
|
||||
|
||||
import mage.abilities.condition.common.BlightedCondition;
|
||||
import mage.abilities.decorator.ConditionalOneShotEffect;
|
||||
import mage.abilities.effects.common.DestroyTargetEffect;
|
||||
import mage.abilities.effects.common.GainLifeEffect;
|
||||
import mage.abilities.keyword.BlightAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.ComparisonType;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.mageobject.ManaValuePredicate;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class RequitingHex extends CardImpl {
|
||||
|
||||
private static final FilterPermanent filter = new FilterCreaturePermanent("creature with mana value 2 or less");
|
||||
|
||||
static {
|
||||
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, 3));
|
||||
}
|
||||
|
||||
public RequitingHex(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{B}");
|
||||
|
||||
// As an additional cost to cast this spell, you may blight 1.
|
||||
this.addAbility(new BlightAbility(1));
|
||||
|
||||
// Destroy target creature with mana value 2 or less. If this spell's additional cost was paid, you gain 2 life.
|
||||
this.getSpellAbility().addEffect(new DestroyTargetEffect());
|
||||
this.getSpellAbility().addTarget(new TargetPermanent(filter));
|
||||
this.getSpellAbility().addEffect(new ConditionalOneShotEffect(
|
||||
new GainLifeEffect(2), BlightedCondition.instance,
|
||||
"If this spell's additional cost was paid, you gain 2 life"
|
||||
));
|
||||
}
|
||||
|
||||
private RequitingHex(final RequitingHex card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RequitingHex copy() {
|
||||
return new RequitingHex(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -156,6 +156,7 @@ public final class LorwynEclipsed extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Plains", 274, Rarity.LAND, mage.cards.basiclands.Plains.class, NON_FULL_USE_VARIOUS));
|
||||
cards.add(new SetCardInfo("Plains", 279, Rarity.LAND, mage.cards.basiclands.Plains.class, NON_FULL_USE_VARIOUS));
|
||||
cards.add(new SetCardInfo("Prideful Feastling", 238, Rarity.COMMON, mage.cards.p.PridefulFeastling.class));
|
||||
cards.add(new SetCardInfo("Requiting Hex", 116, Rarity.UNCOMMON, mage.cards.r.RequitingHex.class));
|
||||
cards.add(new SetCardInfo("Rhys, the Evermore", 32, Rarity.RARE, mage.cards.r.RhysTheEvermore.class, NON_FULL_USE_VARIOUS));
|
||||
cards.add(new SetCardInfo("Rhys, the Evermore", 354, Rarity.RARE, mage.cards.r.RhysTheEvermore.class, NON_FULL_USE_VARIOUS));
|
||||
cards.add(new SetCardInfo("Rooftop Percher", 2, Rarity.COMMON, mage.cards.r.RooftopPercher.class));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
package mage.abilities.condition.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.keyword.BlightAbility;
|
||||
import mage.game.Game;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
* Checks if the spell was cast with the alternate blight cost
|
||||
*
|
||||
* @author TheElk801
|
||||
*/
|
||||
public enum BlightedCondition implements Condition {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return CardUtil.checkSourceCostsTagExists(game, source, BlightAbility.BLIGHT_ACTIVATION_VALUE_KEY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "creature was blighted";
|
||||
}
|
||||
}
|
||||
96
Mage/src/main/java/mage/abilities/keyword/BlightAbility.java
Normal file
96
Mage/src/main/java/mage/abilities/keyword/BlightAbility.java
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
package mage.abilities.keyword;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.StaticAbility;
|
||||
import mage.abilities.costs.*;
|
||||
import mage.abilities.costs.common.BlightCost;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public class BlightAbility extends StaticAbility implements OptionalAdditionalSourceCosts {
|
||||
|
||||
public static final String BLIGHT_ACTIVATION_VALUE_KEY = "blightActivation";
|
||||
|
||||
protected OptionalAdditionalCost additionalCost;
|
||||
|
||||
public static OptionalAdditionalCost makeCost(int amount) {
|
||||
OptionalAdditionalCost cost = new OptionalAdditionalCostImpl(
|
||||
"As an additional cost to cast this spell, you may blight " + amount,
|
||||
"You may put " + CardUtil.numberToText(amount, "a") +
|
||||
" -1/-1 counter" + (amount > 1 ? "s" : "") + "on a creature you control.",
|
||||
new BlightCost(amount)
|
||||
);
|
||||
cost.setRepeatable(false);
|
||||
return cost;
|
||||
}
|
||||
|
||||
private final int amount;
|
||||
private final String rule;
|
||||
|
||||
public BlightAbility(int amount) {
|
||||
super(Zone.STACK, null);
|
||||
this.amount = amount;
|
||||
this.additionalCost = makeCost(amount);
|
||||
this.rule = additionalCost.getName() + ". " + additionalCost.getReminderText();
|
||||
this.setRuleAtTheTop(true);
|
||||
}
|
||||
|
||||
private BlightAbility(final BlightAbility ability) {
|
||||
super(ability);
|
||||
this.amount = ability.amount;
|
||||
this.rule = ability.rule;
|
||||
this.additionalCost = ability.additionalCost.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlightAbility copy() {
|
||||
return new BlightAbility(this);
|
||||
}
|
||||
|
||||
public void resetCost() {
|
||||
if (additionalCost != null) {
|
||||
additionalCost.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addOptionalAdditionalCosts(Ability ability, Game game) {
|
||||
if (!(ability instanceof SpellAbility)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = game.getPlayer(ability.getControllerId());
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.resetCost();
|
||||
boolean canPay = additionalCost.canPay(ability, this, ability.getControllerId(), game);
|
||||
if (!canPay || !player.chooseUse(Outcome.Exile, "Blight " + amount + '?', ability, game)) {
|
||||
return;
|
||||
}
|
||||
|
||||
additionalCost.activate();
|
||||
for (Cost cost : ((Costs<Cost>) additionalCost)) {
|
||||
ability.getCosts().add(cost.copy());
|
||||
}
|
||||
ability.setCostsTag(BLIGHT_ACTIVATION_VALUE_KEY, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCastMessageSuffix() {
|
||||
return additionalCost.getCastSuffixMessage(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return rule;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue