diff --git a/Mage.Sets/src/mage/cards/g/GilanraCallerOfWirewood.java b/Mage.Sets/src/mage/cards/g/GilanraCallerOfWirewood.java new file mode 100644 index 00000000000..cd88edbe23a --- /dev/null +++ b/Mage.Sets/src/mage/cards/g/GilanraCallerOfWirewood.java @@ -0,0 +1,100 @@ +package mage.cards.g; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.DelayedTriggeredAbility; +import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.keyword.PartnerAbility; +import mage.abilities.mana.GreenManaAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +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 java.util.UUID; + +/** + * @author TheElk801 + */ +public final class GilanraCallerOfWirewood extends CardImpl { + + public GilanraCallerOfWirewood(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.ELF); + this.subtype.add(SubType.DRUID); + this.power = new MageInt(1); + this.toughness = new MageInt(2); + + // {T}: Add {G}. When you spend this mana to cast a spell with converted mana cost 6 or greater, draw a card. + Ability ability = new GreenManaAbility(); + ability.addEffect(new CreateDelayedTriggeredAbilityEffect(new GilanraCallerOfWirewoodTriggeredAbility())); + this.addAbility(ability); + + // Partner + this.addAbility(PartnerAbility.getInstance()); + } + + private GilanraCallerOfWirewood(final GilanraCallerOfWirewood card) { + super(card); + } + + @Override + public GilanraCallerOfWirewood copy() { + 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 = game.getPermanentOrLKIBattlefield(getSourceId()); + if (sourcePermanent == null + || sourcePermanent + .getAbilities(game) + .stream() + .filter(GreenManaAbility.class::isInstance) + .map(Ability::getOriginalId) + .map(UUID::toString) + .noneMatch(event.getData()::equals)) { + return false; + } + Spell spell = game.getStack().getSpell(event.getTargetId()); + return spell != null && spell.getConvertedManaCost() >= 6; + } + + @Override + public String getRule() { + return "When you spend this mana to cast a spell with converted mana cost 6 or greater, draw a card."; + } +} diff --git a/Mage.Sets/src/mage/cards/p/PathOfAncestry.java b/Mage.Sets/src/mage/cards/p/PathOfAncestry.java index ee0be6c4478..6e54b879984 100644 --- a/Mage.Sets/src/mage/cards/p/PathOfAncestry.java +++ b/Mage.Sets/src/mage/cards/p/PathOfAncestry.java @@ -72,18 +72,14 @@ class PathOfAncestryTriggeredAbility extends DelayedTriggeredAbility { return false; } Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(getSourceId()); - if (sourcePermanent == null) { - return false; - } - boolean found = false; - for (Ability ability : sourcePermanent.getAbilities()) { - if (ability instanceof CommanderColorIdentityManaAbility - && ability.getOriginalId().toString().equals(event.getData())) { - found = true; - break; - } - } - if (!found) { + if (sourcePermanent == null + || sourcePermanent + .getAbilities(game) + .stream() + .filter(CommanderColorIdentityManaAbility.class::isInstance) + .map(Ability::getOriginalId) + .map(UUID::toString) + .noneMatch(event.getData()::equals)) { return false; } Spell spell = game.getStack().getSpell(event.getTargetId()); @@ -94,7 +90,6 @@ class PathOfAncestryTriggeredAbility extends DelayedTriggeredAbility { if (player == null) { return false; } - boolean isAllA = false; for (UUID commanderId : game.getCommandersIds(player)) { Card commander = game.getPermanent(commanderId); if (commander == null) { diff --git a/Mage.Sets/src/mage/sets/CommanderLegends.java b/Mage.Sets/src/mage/sets/CommanderLegends.java index 37ba014c5c3..bc6fd501932 100644 --- a/Mage.Sets/src/mage/sets/CommanderLegends.java +++ b/Mage.Sets/src/mage/sets/CommanderLegends.java @@ -107,6 +107,7 @@ public final class CommanderLegends extends ExpansionSet { cards.add(new SetCardInfo("Ghen, Arcanum Weaver", 275, Rarity.RARE, mage.cards.g.GhenArcanumWeaver.class)); cards.add(new SetCardInfo("Ghost of Ramirez DePietro", 71, Rarity.UNCOMMON, mage.cards.g.GhostOfRamirezDePietro.class)); cards.add(new SetCardInfo("Gift of Paradise", 229, Rarity.COMMON, mage.cards.g.GiftOfParadise.class)); + cards.add(new SetCardInfo("Gilanra, Caller of Wirewood", 230, Rarity.UNCOMMON, mage.cards.g.GilanraCallerOfWirewood.class)); cards.add(new SetCardInfo("Gnostro, Voice of the Crags", 276, Rarity.RARE, mage.cards.g.GnostroVoiceOfTheCrags.class)); cards.add(new SetCardInfo("Gor Muldrak, Amphinologist", 277, Rarity.RARE, mage.cards.g.GorMuldrakAmphinologist.class)); cards.add(new SetCardInfo("Halana, Kessig Ranger", 231, Rarity.UNCOMMON, mage.cards.h.HalanaKessigRanger.class));