From 87fd7a2ab02818ce80a1001a314546ec356ca211 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sat, 22 Sep 2018 19:25:10 +0200 Subject: [PATCH] [GRN] Added Guildmages' Forum. --- .../src/mage/cards/g/GuildmagesForum.java | 142 ++++++++++++++++++ Mage.Sets/src/mage/sets/GuildsOfRavnica.java | 1 + .../effects/mana/AddManaOfAnyColorEffect.java | 11 +- .../abilities/mana/AnyColorManaAbility.java | 10 +- 4 files changed, 160 insertions(+), 4 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/g/GuildmagesForum.java diff --git a/Mage.Sets/src/mage/cards/g/GuildmagesForum.java b/Mage.Sets/src/mage/cards/g/GuildmagesForum.java new file mode 100644 index 00000000000..1a1792352e0 --- /dev/null +++ b/Mage.Sets/src/mage/cards/g/GuildmagesForum.java @@ -0,0 +1,142 @@ +package mage.cards.g; + +import java.util.UUID; +import mage.MageObject; +import mage.MageObjectReference; +import mage.abilities.Ability; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.mana.AnyColorManaAbility; +import mage.abilities.mana.ColorlessManaAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.WatcherScope; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.events.EntersTheBattlefieldEvent; +import mage.game.events.GameEvent; +import mage.game.events.GameEvent.EventType; +import mage.game.permanent.Permanent; +import mage.game.stack.Spell; +import mage.watchers.Watcher; + +/** + * + * @author LevelX2 + */ +public final class GuildmagesForum extends CardImpl { + + public GuildmagesForum(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.LAND}, ""); + + // {T}: Add {C}. + this.addAbility(new ColorlessManaAbility()); + + // {1}, {T}: Add one mana of any color. If that mana is spent on a multicolored creature spell, that creature enters the battlefield with an additional +1/+1 counter on it. + Ability ability = new AnyColorManaAbility(new GenericManaCost(1), true); + ability.getEffects().get(0).setText("Add one mana of any color. If that mana is spent on a multicolored creature spell, that creature enters the battlefield with an additional +1/+1 counter on it"); + ability.addCost(new TapSourceCost()); + this.addAbility(ability, new GuildmagesForumWatcher(ability)); + } + + public GuildmagesForum(final GuildmagesForum card) { + super(card); + } + + @Override + public GuildmagesForum copy() { + return new GuildmagesForum(this); + } +} + +class GuildmagesForumWatcher extends Watcher { + + private final Ability source; + + GuildmagesForumWatcher(Ability source) { + super("GuildmagesForumWatcher", WatcherScope.CARD); + this.source = source; + } + + GuildmagesForumWatcher(final GuildmagesForumWatcher watcher) { + super(watcher); + this.source = watcher.source; + } + + @Override + public GuildmagesForumWatcher copy() { + return new GuildmagesForumWatcher(this); + } + + @Override + public void watch(GameEvent event, Game game) { + if (event.getType() == EventType.MANA_PAID) { + MageObject target = game.getObject(event.getTargetId()); + if (event.getSourceId() != null + && event.getSourceId().equals(this.getSourceId()) + && target != null && target.isCreature() && target.getColor(game).isMulticolored() + && event.getFlag()) { + if (target instanceof Spell) { + game.getState().addEffect(new GuildmagesForumEntersBattlefieldEffect( + new MageObjectReference(((Spell) target).getSourceId(), target.getZoneChangeCounter(game), game)), source); + } + } + } + } + + @Override + public void reset() { + super.reset(); + } + +} + +class GuildmagesForumEntersBattlefieldEffect extends ReplacementEffectImpl { + + private final MageObjectReference mor; + + public GuildmagesForumEntersBattlefieldEffect(MageObjectReference mor) { + super(Duration.EndOfTurn, Outcome.BoostCreature); + this.staticText = "If that mana is spent on a multicolored creature spell, that creature enters the battlefield with an additional +1/+1 counter on it"; + this.mor = mor; + } + + public GuildmagesForumEntersBattlefieldEffect(GuildmagesForumEntersBattlefieldEffect effect) { + super(effect); + this.mor = effect.mor; + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget(); + return permanent != null && mor.refersTo(permanent, game); + } + + @Override + public boolean apply(Game game, Ability source) { + return false; + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + Permanent target = ((EntersTheBattlefieldEvent) event).getTarget(); + if (target != null) { + target.addCounters(CounterType.P1P1.createInstance(), source, game, event.getAppliedEffects()); + } + return false; + } + + @Override + public GuildmagesForumEntersBattlefieldEffect copy() { + return new GuildmagesForumEntersBattlefieldEffect(this); + } +} diff --git a/Mage.Sets/src/mage/sets/GuildsOfRavnica.java b/Mage.Sets/src/mage/sets/GuildsOfRavnica.java index cc70632a9ad..7685729b563 100644 --- a/Mage.Sets/src/mage/sets/GuildsOfRavnica.java +++ b/Mage.Sets/src/mage/sets/GuildsOfRavnica.java @@ -130,6 +130,7 @@ public final class GuildsOfRavnica extends ExpansionSet { cards.add(new SetCardInfo("Gravitic Punch", 105, Rarity.COMMON, mage.cards.g.GraviticPunch.class)); cards.add(new SetCardInfo("Gruesome Menagerie", 71, Rarity.RARE, mage.cards.g.GruesomeMenagerie.class)); cards.add(new SetCardInfo("Guild Summit", 41, Rarity.UNCOMMON, mage.cards.g.GuildSummit.class)); + cards.add(new SetCardInfo("Guildmages' Forum", 250, Rarity.RARE, mage.cards.g.GuildmagesForum.class)); cards.add(new SetCardInfo("Haazda Marshal", 13, Rarity.UNCOMMON, mage.cards.h.HaazdaMarshal.class)); cards.add(new SetCardInfo("Hammer Dropper", 176, Rarity.COMMON, mage.cards.h.HammerDropper.class)); cards.add(new SetCardInfo("Hatchery Spider", 132, Rarity.RARE, mage.cards.h.HatcherySpider.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/mana/AddManaOfAnyColorEffect.java b/Mage/src/main/java/mage/abilities/effects/mana/AddManaOfAnyColorEffect.java index ae568822690..dc03549ea0f 100644 --- a/Mage/src/main/java/mage/abilities/effects/mana/AddManaOfAnyColorEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/mana/AddManaOfAnyColorEffect.java @@ -16,12 +16,17 @@ public class AddManaOfAnyColorEffect extends BasicManaEffect { protected final int amount; protected final ArrayList netMana = new ArrayList<>(); + protected final boolean setFlag; public AddManaOfAnyColorEffect() { this(1); } public AddManaOfAnyColorEffect(int amount) { + this(amount, false); + } + + public AddManaOfAnyColorEffect(int amount, boolean setFlag) { super(new Mana(0, 0, 0, 0, 0, 0, amount, 0)); this.amount = amount; netMana.add(Mana.GreenMana(amount)); @@ -30,12 +35,14 @@ public class AddManaOfAnyColorEffect extends BasicManaEffect { netMana.add(Mana.WhiteMana(amount)); netMana.add(Mana.RedMana(amount)); this.staticText = "add " + CardUtil.numberToText(amount) + " mana of any " + (amount > 1 ? "one " : "") + "color"; + this.setFlag = setFlag; } public AddManaOfAnyColorEffect(final AddManaOfAnyColorEffect effect) { super(effect); this.amount = effect.amount; this.netMana.addAll(effect.netMana); + this.setFlag = effect.setFlag; } @Override @@ -66,7 +73,9 @@ public class AddManaOfAnyColorEffect extends BasicManaEffect { ChoiceColor choice = new ChoiceColor(true, mes, game.getObject(source.getSourceId())); if (controller.choose(outcome, choice, game)) { if (choice.getColor() != null) { - return choice.getMana(amount); + Mana mana = choice.getMana(amount); + mana.setFlag(setFlag); + return mana; } } } diff --git a/Mage/src/main/java/mage/abilities/mana/AnyColorManaAbility.java b/Mage/src/main/java/mage/abilities/mana/AnyColorManaAbility.java index 8e0720750a2..e22d6b79a4f 100644 --- a/Mage/src/main/java/mage/abilities/mana/AnyColorManaAbility.java +++ b/Mage/src/main/java/mage/abilities/mana/AnyColorManaAbility.java @@ -1,4 +1,3 @@ - package mage.abilities.mana; import mage.Mana; @@ -8,13 +7,18 @@ import mage.abilities.effects.mana.AddManaOfAnyColorEffect; import mage.constants.Zone; public class AnyColorManaAbility extends ActivatedManaAbilityImpl { + public AnyColorManaAbility() { this(new TapSourceCost()); } public AnyColorManaAbility(Cost cost) { - super(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(), cost); - this.netMana.add(new Mana(0,0,0,0,0,0,1, 0)); + this(cost, false); + } + + public AnyColorManaAbility(Cost cost, boolean setFlag) { + super(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(1, setFlag), cost); + this.netMana.add(new Mana(0, 0, 0, 0, 0, 0, 1, 0)); } public AnyColorManaAbility(final AnyColorManaAbility ability) {