From 8c4e5c3a91a3a78cdd8ed1960f03bcddc681016f Mon Sep 17 00:00:00 2001 From: LevelX2 <ludwig.hirth@online.de> Date: Sun, 13 Jan 2013 10:43:52 +0100 Subject: [PATCH] [GTC] Luminate Primortial, Giant Adephage, Pit Fight, Simic Keyrune, Zameck Guildmage --- .../mage/sets/gatecrash/GiantAdephage.java | 114 +++++++++++++ .../sets/gatecrash/LuminatePrimordial.java | 130 +++++++++++++++ .../src/mage/sets/gatecrash/PitFight.java | 65 ++++++++ .../src/mage/sets/gatecrash/SimicKeyrune.java | 85 ++++++++++ .../mage/sets/gatecrash/ZameckGuildmage.java | 150 ++++++++++++++++++ 5 files changed, 544 insertions(+) create mode 100644 Mage.Sets/src/mage/sets/gatecrash/GiantAdephage.java create mode 100644 Mage.Sets/src/mage/sets/gatecrash/LuminatePrimordial.java create mode 100644 Mage.Sets/src/mage/sets/gatecrash/PitFight.java create mode 100644 Mage.Sets/src/mage/sets/gatecrash/SimicKeyrune.java create mode 100644 Mage.Sets/src/mage/sets/gatecrash/ZameckGuildmage.java diff --git a/Mage.Sets/src/mage/sets/gatecrash/GiantAdephage.java b/Mage.Sets/src/mage/sets/gatecrash/GiantAdephage.java new file mode 100644 index 0000000000..8322d4c1d0 --- /dev/null +++ b/Mage.Sets/src/mage/sets/gatecrash/GiantAdephage.java @@ -0,0 +1,114 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.sets.gatecrash; + +import java.util.UUID; +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Outcome; +import mage.Constants.Rarity; +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.keyword.TrampleAbility; +import mage.cards.CardImpl; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.sets.tokens.EmptyToken; +import mage.util.CardUtil; + +/** + * + * @author LevelX2 + */ +public class GiantAdephage extends CardImpl<GiantAdephage> { + + public GiantAdephage(UUID ownerId) { + super(ownerId, 121, "Giant Adephage", Rarity.MYTHIC, new CardType[]{CardType.CREATURE}, "{5}{G}{G}"); + this.expansionSetCode = "GTC"; + this.subtype.add("Insect"); + this.color.setGreen(true); + this.power = new MageInt(7); + this.toughness = new MageInt(7); + + // Trample + this.addAbility(TrampleAbility.getInstance()); + + // Whenever Giant Adephage deals combat damage to a player, put a token onto the battlefield that is a copy of Giant Adephage. + this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new GiantAdephageCopyEffect(), false)); + + } + + public GiantAdephage(final GiantAdephage card) { + super(card); + } + + @Override + public GiantAdephage copy() { + return new GiantAdephage(this); + } +} + +class GiantAdephageCopyEffect extends OneShotEffect<GiantAdephageCopyEffect> { + + public GiantAdephageCopyEffect() { + super(Outcome.Copy); + this.staticText = "put a token onto the battlefield that is a copy of Giant Adephage"; + } + + public GiantAdephageCopyEffect(final GiantAdephageCopyEffect effect) { + super(effect); + } + + @Override + public GiantAdephageCopyEffect copy() { + return new GiantAdephageCopyEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + MageObject thisCard = game.getLastKnownInformation(source.getSourceId(), Constants.Zone.BATTLEFIELD); + if (thisCard != null && thisCard instanceof Permanent) { + EmptyToken token = new EmptyToken(); + CardUtil.copyTo(token).from((Permanent)thisCard); + token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId()); + return true; + } else { // maybe it's token + Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId()); + if (permanent != null) { + EmptyToken token = new EmptyToken(); + CardUtil.copyTo(token).from(permanent); + token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId()); + return true; + } + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/gatecrash/LuminatePrimordial.java b/Mage.Sets/src/mage/sets/gatecrash/LuminatePrimordial.java new file mode 100644 index 0000000000..dd5f417a15 --- /dev/null +++ b/Mage.Sets/src/mage/sets/gatecrash/LuminatePrimordial.java @@ -0,0 +1,130 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.sets.gatecrash; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Outcome; +import mage.Constants.Rarity; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.keyword.VigilanceAbility; +import mage.cards.CardImpl; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.ControllerIdPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.Target; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author LevelX2 + */ +public class LuminatePrimordial extends CardImpl<LuminatePrimordial> { + + public LuminatePrimordial(UUID ownerId) { + super(ownerId, 20, "Luminate Primordial", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{5}{W}{W}"); + this.expansionSetCode = "GTC"; + this.subtype.add("Avatar"); + + this.color.setWhite(true); + this.power = new MageInt(4); + this.toughness = new MageInt(7); + + //Vigilance + this.addAbility(VigilanceAbility.getInstance()); + + // When Luminate Primordial enters the battlefield, for each opponent, exile up to one target creature + // that player controls and that player gains life equal to its power. + this.addAbility(new EntersBattlefieldTriggeredAbility(new LuminatePrimordialEffect(),false)); + } + + @Override + public void adjustTargets(Ability ability, Game game) { + if (ability instanceof EntersBattlefieldTriggeredAbility) { + for(UUID opponentId : game.getOpponents(ability.getControllerId())) { + Player opponent = game.getPlayer(opponentId); + if (opponent != null) { + ability.getTargets().clear(); + FilterCreaturePermanent filter = new FilterCreaturePermanent(new StringBuilder("creature from opponent ").append(opponent.getName()).toString()); + filter.add(new ControllerIdPredicate(opponentId)); + TargetCreaturePermanent target = new TargetCreaturePermanent(0,1, filter,false); + ability.addTarget(target); + } + } + } + } + + public LuminatePrimordial(final LuminatePrimordial card) { + super(card); + } + + @Override + public LuminatePrimordial copy() { + return new LuminatePrimordial(this); + } +} + +class LuminatePrimordialEffect extends OneShotEffect<LuminatePrimordialEffect> { + + public LuminatePrimordialEffect() { + super(Outcome.Benefit); + this.staticText = "for each opponent, exile up to one target creature that player controls and that player gains life equal to its power"; + } + + public LuminatePrimordialEffect(final LuminatePrimordialEffect effect) { + super(effect); + } + + @Override + public LuminatePrimordialEffect copy() { + return new LuminatePrimordialEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + for (Target target: source.getTargets()) { + if (target instanceof TargetCreaturePermanent) { + Permanent targetCreature = game.getPermanent(target.getFirstTarget()); + if (targetCreature != null && !targetCreature.getControllerId().equals(source.getControllerId())) { + int amountLife = targetCreature.getPower().getValue(); + Player controller = game.getPlayer(targetCreature.getControllerId()); + targetCreature.moveToExile(null, null, source.getSourceId(), game); + if (controller != null && amountLife != 0) { + controller.gainLife(amountLife, game); + } + } + } + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/gatecrash/PitFight.java b/Mage.Sets/src/mage/sets/gatecrash/PitFight.java new file mode 100644 index 0000000000..47039721f1 --- /dev/null +++ b/Mage.Sets/src/mage/sets/gatecrash/PitFight.java @@ -0,0 +1,65 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.sets.gatecrash; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.abilities.effects.common.FightTargetsEffect; +import mage.cards.CardImpl; +import mage.target.common.TargetControlledCreaturePermanent; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author LevelX2 + */ +public class PitFight extends CardImpl<PitFight> { + + public PitFight(UUID ownerId) { + super(ownerId, 225, "Pit Fight", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{R/G}"); + this.expansionSetCode = "GTC"; + + this.color.setRed(true); + this.color.setGreen(true); + + // Target creature you control fights another target creature. + this.getSpellAbility().addEffect(new FightTargetsEffect()); + this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent()); + this.getSpellAbility().addTarget(new TargetCreaturePermanent()); + } + + public PitFight(final PitFight card) { + super(card); + } + + @Override + public PitFight copy() { + return new PitFight(this); + } +} diff --git a/Mage.Sets/src/mage/sets/gatecrash/SimicKeyrune.java b/Mage.Sets/src/mage/sets/gatecrash/SimicKeyrune.java new file mode 100644 index 0000000000..6b131d92a4 --- /dev/null +++ b/Mage.Sets/src/mage/sets/gatecrash/SimicKeyrune.java @@ -0,0 +1,85 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.sets.gatecrash; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Duration; +import mage.Constants.Rarity; +import mage.Constants.Zone; +import mage.MageInt; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.common.continious.BecomesCreatureSourceEffect; +import mage.abilities.keyword.HexproofAbility; +import mage.abilities.mana.BlueManaAbility; +import mage.abilities.mana.GreenManaAbility; +import mage.cards.CardImpl; +import mage.game.permanent.token.Token; + +/** + * + * @author LevelX2 + */ +public class SimicKeyrune extends CardImpl<SimicKeyrune> { + + public SimicKeyrune(UUID ownerId) { + super(ownerId, 237, "Simic Keyrune", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT}, "{3}"); + this.expansionSetCode = "GTC"; + + // {T}: Add {G} or {U} to your mana pool. + this.addAbility(new GreenManaAbility()); + this.addAbility(new BlueManaAbility()); + + // {G}{U}: Simic Keyrune becomes a 2/3 green and blue Crab artifact creature with hexproof until end of turn. + this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesCreatureSourceEffect(new SimicKeyruneToken(), "", Duration.EndOfTurn), new ManaCostsImpl("{G}{U}"))); + } + + public SimicKeyrune(final SimicKeyrune card) { + super(card); + } + + @Override + public SimicKeyrune copy() { + return new SimicKeyrune(this); + } + + private class SimicKeyruneToken extends Token { + SimicKeyruneToken() { + super("Crab", "2/3 green and blue Crab artifact creature with hexproof"); + cardType.add(CardType.ARTIFACT); + cardType.add(CardType.CREATURE); + color.setGreen(true); + color.setBlue(true); + subtype.add("Crab"); + power = new MageInt(2); + toughness = new MageInt(3); + this.addAbility(HexproofAbility.getInstance()); + } + } +} diff --git a/Mage.Sets/src/mage/sets/gatecrash/ZameckGuildmage.java b/Mage.Sets/src/mage/sets/gatecrash/ZameckGuildmage.java new file mode 100644 index 0000000000..da4a9b586f --- /dev/null +++ b/Mage.Sets/src/mage/sets/gatecrash/ZameckGuildmage.java @@ -0,0 +1,150 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.sets.gatecrash; + +import java.util.UUID; +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.Constants.Zone; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.RemoveCounterCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.Effect; +import mage.abilities.effects.Effects; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.common.DrawCardControllerEffect; +import mage.abilities.effects.common.counter.AddCountersTargetEffect; +import mage.cards.CardImpl; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.target.common.TargetControlledCreaturePermanent; +import mage.target.targetpointer.FixedTarget; + +/** + * + * @author LevelX2 + */ +public class ZameckGuildmage extends CardImpl<ZameckGuildmage> { + + private static final String ruleText = "This turn, each creature you control enters the battlefield with an additional +1/+1 counter on it"; + + public ZameckGuildmage(UUID ownerId) { + super(ownerId, 209, "Zameck Guildmage", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{G}{U}"); + this.expansionSetCode = "GTC"; + this.subtype.add("Elf"); + this.subtype.add("Wizard"); + + this.color.setGreen(true); + this.color.setBlue(true); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + + // {G}{U}: This turn, each creature you control enters the battlefield with an additional +1/+1 counter on it. + this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new EntersBattlefieldEffect(new AddCountersTargetEffect(CounterType.P1P1.createInstance(1)), ruleText),new ManaCostsImpl("{G}{U}"))); + + // {G}{U}, Remove a +1/+1 counter from a creature you control: Draw a card. + this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new DrawCardControllerEffect(1),new RemoveCounterCost(new TargetControlledCreaturePermanent(), CounterType.P1P1))); + } + + public ZameckGuildmage(final ZameckGuildmage card) { + super(card); + } + + @Override + public ZameckGuildmage copy() { + return new ZameckGuildmage(this); + } +} + +class EntersBattlefieldEffect extends ReplacementEffectImpl<EntersBattlefieldEffect> { + + protected Effects baseEffects = new Effects(); + protected String text; + + public EntersBattlefieldEffect(Effect baseEffect, String text) { + super(Constants.Duration.EndOfTurn, baseEffect.getOutcome()); + this.baseEffects.add(baseEffect); + this.text = text; + } + + public EntersBattlefieldEffect(EntersBattlefieldEffect effect) { + super(effect); + this.baseEffects = effect.baseEffects.copy(); + this.text = effect.text; + } + + public void addEffect(Effect effect) { + baseEffects.add(effect); + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) { + Permanent permanent = game.getPermanent(event.getTargetId()); + if (permanent != null && permanent.getControllerId().equals(source.getControllerId())) { + return true; + } + } + return false; + } + + @Override + public boolean apply(Game game, Ability source) { + return false; + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + for (Effect effect: baseEffects) { + Permanent target = game.getPermanent(event.getTargetId()); + if (target != null) { + effect.setTargetPointer(new FixedTarget(target.getId())); + effect.apply(game, source); + } + } + return false; + } + + @Override + public String getText(Mode mode) { + return (text == null || text.isEmpty()) ? baseEffects.getText(mode) : text; + } + + @Override + public EntersBattlefieldEffect copy() { + return new EntersBattlefieldEffect(this); + } +}