[CLB] Implemented Scaled Nurturer

This commit is contained in:
Evan Kranzler 2022-06-01 20:22:02 -04:00
parent 62f5ec51c6
commit 921865a8f9
4 changed files with 152 additions and 72 deletions

View file

@ -1,8 +1,7 @@
package mage.cards.g;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.delayed.ManaSpentDelayedTriggeredAbility;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.keyword.PartnerAbility;
@ -11,15 +10,11 @@ import mage.abilities.mana.GreenManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.ComparisonType;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.game.stack.Spell;
import mage.players.ManaPoolItem;
import mage.players.Player;
import mage.filter.FilterSpell;
import mage.filter.predicate.mageobject.ManaValuePredicate;
import java.util.UUID;
@ -28,6 +23,12 @@ import java.util.UUID;
*/
public final class GilanraCallerOfWirewood extends CardImpl {
private static final FilterSpell filter = new FilterSpell("a spell with mana value 6 or greater");
static {
filter.add(new ManaValuePredicate(ComparisonType.MORE_THAN, 5));
}
public GilanraCallerOfWirewood(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}");
@ -39,7 +40,9 @@ public final class GilanraCallerOfWirewood extends CardImpl {
// {T}: Add {G}. When you spend this mana to cast a spell with converted mana cost 6 or greater, draw a card.
BasicManaAbility ability = new GreenManaAbility();
ability.addEffect(new CreateDelayedTriggeredAbilityEffect(new GilanraCallerOfWirewoodTriggeredAbility()));
ability.addEffect(new CreateDelayedTriggeredAbilityEffect(
new ManaSpentDelayedTriggeredAbility(new DrawCardSourceControllerEffect(1), filter)
));
ability.setUndoPossible(false);
this.addAbility(ability);
@ -56,65 +59,3 @@ public final class GilanraCallerOfWirewood extends CardImpl {
return new GilanraCallerOfWirewood(this);
}
}
class GilanraCallerOfWirewoodTriggeredAbility extends DelayedTriggeredAbility {
GilanraCallerOfWirewoodTriggeredAbility() {
super(new DrawCardSourceControllerEffect(1), Duration.Custom, true, false);
}
private GilanraCallerOfWirewoodTriggeredAbility(final GilanraCallerOfWirewoodTriggeredAbility ability) {
super(ability);
}
@Override
public GilanraCallerOfWirewoodTriggeredAbility copy() {
return new GilanraCallerOfWirewoodTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.MANA_PAID;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!getSourceId().equals(event.getSourceId())) {
return false;
}
Permanent sourcePermanent = getSourcePermanentOrLKI(game);
if (sourcePermanent == null
|| sourcePermanent
.getAbilities(game)
.stream()
.map(Ability::getOriginalId)
.map(UUID::toString)
.noneMatch(event.getData()::equals)) {
return false;
}
Spell spell = game.getStack().getSpell(event.getTargetId());
return spell != null && spell.getManaValue() >= 6;
}
@Override
public boolean isInactive(Game game) {
if (super.isInactive(game)) {
return true;
}
// must remove effect on empty mana pool to fix accumulate bug
// if no mana in pool then it can be discarded
Player player = game.getPlayer(this.getControllerId());
return player == null
|| player
.getManaPool()
.getManaItems()
.stream()
.map(ManaPoolItem::getSourceId)
.noneMatch(getSourceId()::equals);
}
@Override
public String getRule() {
return "When you spend this mana to cast a spell with mana value 6 or greater, draw a card.";
}
}

View file

@ -0,0 +1,54 @@
package mage.cards.s;
import mage.MageInt;
import mage.abilities.common.delayed.ManaSpentDelayedTriggeredAbility;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.mana.BasicManaAbility;
import mage.abilities.mana.GreenManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.filter.FilterSpell;
import mage.filter.common.FilterCreatureSpell;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class ScaledNurturer extends CardImpl {
private static final FilterSpell filter = new FilterCreatureSpell("a Dragon creature spell");
static {
filter.add(SubType.DRAGON.getPredicate());
}
public ScaledNurturer(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}");
this.subtype.add(SubType.DRAGON);
this.subtype.add(SubType.DRUID);
this.power = new MageInt(0);
this.toughness = new MageInt(2);
// {T}: Add {G}. When you spend this mana to cast a Dragon creature spell, you gain 2 life.
BasicManaAbility ability = new GreenManaAbility();
ability.addEffect(new CreateDelayedTriggeredAbilityEffect(
new ManaSpentDelayedTriggeredAbility(new GainLifeEffect(2), filter)
));
ability.setUndoPossible(false);
this.addAbility(ability);
}
private ScaledNurturer(final ScaledNurturer card) {
super(card);
}
@Override
public ScaledNurturer copy() {
return new ScaledNurturer(this);
}
}

View file

@ -265,6 +265,7 @@ public final class CommanderLegendsBattleForBaldursGate extends ExpansionSet {
cards.add(new SetCardInfo("Sailors' Bane", 93, Rarity.UNCOMMON, mage.cards.s.SailorsBane.class));
cards.add(new SetCardInfo("Sapphire Dragon", 94, Rarity.UNCOMMON, mage.cards.s.SapphireDragon.class));
cards.add(new SetCardInfo("Sarevok, Deathbringer", 144, Rarity.UNCOMMON, mage.cards.s.SarevokDeathbringer.class));
cards.add(new SetCardInfo("Scaled Nurturer", 252, Rarity.COMMON, mage.cards.s.ScaledNurturer.class));
cards.add(new SetCardInfo("Scouting Hawk", 41, Rarity.COMMON, mage.cards.s.ScoutingHawk.class));
cards.add(new SetCardInfo("Sea Gate", 359, Rarity.COMMON, mage.cards.s.SeaGate.class));
cards.add(new SetCardInfo("Sea Hag", 95, Rarity.COMMON, mage.cards.s.SeaHag.class));

View file

@ -0,0 +1,84 @@
package mage.abilities.common.delayed;
import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.constants.Duration;
import mage.filter.FilterSpell;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.game.stack.Spell;
import mage.players.ManaPoolItem;
import mage.players.Player;
import java.util.UUID;
/**
* @author TheElk801
*/
public class ManaSpentDelayedTriggeredAbility extends DelayedTriggeredAbility {
private final FilterSpell filter;
public ManaSpentDelayedTriggeredAbility(Effect effect, FilterSpell filter) {
super(effect, Duration.Custom, true, false);
this.filter = filter;
}
private ManaSpentDelayedTriggeredAbility(final ManaSpentDelayedTriggeredAbility ability) {
super(ability);
this.filter = ability.filter;
}
@Override
public ManaSpentDelayedTriggeredAbility copy() {
return new ManaSpentDelayedTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.MANA_PAID;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!getSourceId().equals(event.getSourceId())) {
return false;
}
Permanent sourcePermanent = getSourcePermanentOrLKI(game);
if (sourcePermanent == null
|| sourcePermanent
.getAbilities(game)
.stream()
.map(Ability::getOriginalId)
.map(UUID::toString)
.noneMatch(event.getData()::equals)) {
return false;
}
Spell spell = game.getStack().getSpell(event.getTargetId());
return spell != null && filter.match(spell, spell.getControllerId(), this, game);
}
@Override
public boolean isInactive(Game game) {
if (super.isInactive(game)) {
return true;
}
// must remove effect on empty mana pool to fix accumulate bug
// if no mana in pool then it can be discarded
Player player = game.getPlayer(this.getControllerId());
return player == null
|| player
.getManaPool()
.getManaItems()
.stream()
.map(ManaPoolItem::getSourceId)
.noneMatch(getSourceId()::equals);
}
@Override
public String getTriggerPhrase() {
return "When you spend this mana to cast " + filter.getMessage() + ", ";
}
}