From a3fa7b4d609a9c29d7dde2b7be17a590a655ed06 Mon Sep 17 00:00:00 2001 From: Loki Date: Sun, 26 Jun 2011 22:15:24 +0300 Subject: [PATCH] Celestial Mantle, Shrine of Burning Rage, add LKI to CountersCount --- .../sets/newphyrexia/ShrineofBurningRage.java | 84 ++++++++++ .../mage/sets/zendikar/CelestialMantle.java | 143 ++++++++++++++++++ .../dynamicvalue/common/CountersCount.java | 5 + 3 files changed, 232 insertions(+) create mode 100644 Mage.Sets/src/mage/sets/newphyrexia/ShrineofBurningRage.java create mode 100644 Mage.Sets/src/mage/sets/zendikar/CelestialMantle.java diff --git a/Mage.Sets/src/mage/sets/newphyrexia/ShrineofBurningRage.java b/Mage.Sets/src/mage/sets/newphyrexia/ShrineofBurningRage.java new file mode 100644 index 00000000000..01112d04f71 --- /dev/null +++ b/Mage.Sets/src/mage/sets/newphyrexia/ShrineofBurningRage.java @@ -0,0 +1,84 @@ +/* + * 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.newphyrexia; + +import java.util.UUID; + +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.common.SpellCastTriggeredAbility; +import mage.abilities.costs.common.SacrificeSourceCost; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.dynamicvalue.common.CountersCount; +import mage.abilities.effects.common.DamageTargetEffect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.cards.CardImpl; +import mage.counters.CounterType; +import mage.filter.FilterCard; +import mage.target.common.TargetCreatureOrPlayer; + +/** + * + * @author + */ +public class ShrineofBurningRage extends CardImpl { + private final static FilterCard filter = new FilterCard("a red spell"); + + static { + filter.getColor().setRed(true); + filter.setUseColor(true); + } + + public ShrineofBurningRage (UUID ownerId) { + super(ownerId, 153, "Shrine of Burning Rage", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT}, "{2}"); + this.expansionSetCode = "NPH"; + this.addAbility(new BeginningOfUpkeepTriggeredAbility(new AddCountersSourceEffect(CounterType.CHARGE.createInstance()), Constants.TargetController.YOU, false)); + this.addAbility(new SpellCastTriggeredAbility(new AddCountersSourceEffect(CounterType.CHARGE.createInstance()), filter, false)); + Ability ability = new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new DamageTargetEffect(new CountersCount(CounterType.CHARGE)), new GenericManaCost(3)); + ability.addCost(new TapSourceCost()); + ability.addCost(new SacrificeSourceCost()); + ability.addTarget(new TargetCreatureOrPlayer()); + this.addAbility(ability); + } + + public ShrineofBurningRage (final ShrineofBurningRage card) { + super(card); + } + + @Override + public ShrineofBurningRage copy() { + return new ShrineofBurningRage(this); + } + +} diff --git a/Mage.Sets/src/mage/sets/zendikar/CelestialMantle.java b/Mage.Sets/src/mage/sets/zendikar/CelestialMantle.java new file mode 100644 index 00000000000..a961aebb633 --- /dev/null +++ b/Mage.Sets/src/mage/sets/zendikar/CelestialMantle.java @@ -0,0 +1,143 @@ +/* + * 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.zendikar; + +import java.util.UUID; + +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.abilities.Ability; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.DiscardTargetEffect; +import mage.abilities.effects.common.UntapAllLandsControllerEffect; +import mage.abilities.effects.common.continious.BoostEnchantedEffect; +import mage.abilities.keyword.EnchantAbility; +import mage.cards.CardImpl; +import mage.game.Game; +import mage.game.events.DamagedPlayerEvent; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPermanent; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author Loki + */ +public class CelestialMantle extends CardImpl { + + public CelestialMantle (UUID ownerId) { + super(ownerId, 6, "Celestial Mantle", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{3}{W}{W}{W}"); + this.expansionSetCode = "ZEN"; + this.subtype.add("Aura"); + this.color.setWhite(true); + + TargetPermanent auraTarget = new TargetCreaturePermanent(); + this.getSpellAbility().addTarget(auraTarget); + this.getSpellAbility().addEffect(new AttachEffect(Constants.Outcome.BoostCreature)); + Ability ability = new EnchantAbility(auraTarget.getTargetName()); + this.addAbility(ability); + this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new BoostEnchantedEffect(3, 3, Constants.Duration.WhileOnBattlefield))); + this.addAbility(new CelestialMantleAbility()); + } + + public CelestialMantle (final CelestialMantle card) { + super(card); + } + + @Override + public CelestialMantle copy() { + return new CelestialMantle(this); + } + +} + +class CelestialMantleAbility extends TriggeredAbilityImpl { + + public CelestialMantleAbility() { + super(Constants.Zone.BATTLEFIELD, new CelestialMantleEffect()); + this.addEffect(new UntapAllLandsControllerEffect()); + } + + public CelestialMantleAbility(final CelestialMantleAbility ability) { + super(ability); + } + + @Override + public CelestialMantleAbility copy() { + return new CelestialMantleAbility(this); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event instanceof DamagedPlayerEvent) { + DamagedPlayerEvent damageEvent = (DamagedPlayerEvent)event; + Permanent p = game.getPermanent(event.getSourceId()); + if (damageEvent.isCombatDamage() && p != null && p.getAttachments().contains(this.getSourceId())) { + return true; + } + } + return false; + } + + @Override + public String getRule() { + return "Whenever enchanted creature deals combat damage to a player, double its controller's life total."; + } +} + +class CelestialMantleEffect extends OneShotEffect { + CelestialMantleEffect() { + super(Constants.Outcome.GainLife); + } + + CelestialMantleEffect(final CelestialMantleEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player != null) { + player.gainLife(player.getLife(), game); + return true; + } + return false; + } + + @Override + public CelestialMantleEffect copy() { + return new CelestialMantleEffect(this); + } +} \ No newline at end of file diff --git a/Mage/src/mage/abilities/dynamicvalue/common/CountersCount.java b/Mage/src/mage/abilities/dynamicvalue/common/CountersCount.java index ec69a94e0ec..80cb3b824b3 100644 --- a/Mage/src/mage/abilities/dynamicvalue/common/CountersCount.java +++ b/Mage/src/mage/abilities/dynamicvalue/common/CountersCount.java @@ -1,5 +1,6 @@ package mage.abilities.dynamicvalue.common; +import mage.Constants; import mage.abilities.Ability; import mage.abilities.dynamicvalue.DynamicValue; import mage.counters.CounterType; @@ -20,6 +21,10 @@ public class CountersCount implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility) { Permanent p = game.getPermanent(sourceAbility.getSourceId()); + // if permanent already leaves the battlefield, try to find counters count via last known information + if (p == null) { + p = (Permanent) game.getLastKnownInformation(sourceAbility.getSourceId(), Constants.Zone.BATTLEFIELD); + } if (p != null) { return p.getCounters().getCount(counter.getName()); }