1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-01 19:07:57 -09:00

[RTR] 6 cards

This commit is contained in:
LevelX2 2012-10-18 23:13:23 +02:00
parent e6a8223fb9
commit 1a06d4a8c2
6 changed files with 675 additions and 0 deletions

View file

@ -0,0 +1,109 @@
/*
* 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.returntoravnica;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CounterTargetEffect;
import mage.cards.CardImpl;
import mage.filter.FilterSpell;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.game.Game;
import mage.game.stack.Spell;
import mage.players.Player;
import mage.target.TargetSpell;
/**
*
* @author LevelX2
*/
public class EssenceBacklash extends CardImpl<EssenceBacklash> {
private static final FilterSpell filter = new FilterSpell("creature spell");
static {
filter.add(new CardTypePredicate(CardType.CREATURE));
}
public EssenceBacklash(UUID ownerId) {
super(ownerId, 160, "Essence Backlash", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{2}{U}{R}");
this.expansionSetCode = "RTR";
this.color.setBlue(true);
this.color.setRed(true);
// Counter target creature spell. Essence Backlash deals damage equal to that spell's power to its controller.
this.getSpellAbility().addTarget(new TargetSpell(filter));
this.getSpellAbility().addEffect(new EssenceBacklashEffect());
}
public EssenceBacklash(final EssenceBacklash card) {
super(card);
}
@Override
public EssenceBacklash copy() {
return new EssenceBacklash(this);
}
}
class EssenceBacklashEffect extends OneShotEffect<EssenceBacklashEffect> {
public EssenceBacklashEffect() {
super(Constants.Outcome.Damage);
staticText = "Counter target creature spell. Essence Backlash deals damage equal to that spell's power to its controller";
}
public EssenceBacklashEffect(final EssenceBacklashEffect effect) {
super(effect);
}
@Override
public EssenceBacklashEffect copy() {
return new EssenceBacklashEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Boolean result = false;
Spell spell = game.getStack().getSpell(source.getFirstTarget());
if (spell != null) {
Player spellController = game.getPlayer(spell.getControllerId());
result = game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game);
if (spellController != null) {
spellController.damage(spell.getPower().getValue(), source.getSourceId(), game, false, true);
}
}
return result;
}
}

View file

@ -0,0 +1,86 @@
/*
* 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.returntoravnica;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.MageInt;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.common.search.SearchLibraryPutInHandEffect;
import mage.abilities.keyword.DefenderAbility;
import mage.cards.CardImpl;
import mage.filter.FilterCard;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.filter.predicate.mageobject.SupertypePredicate;
import mage.target.common.TargetCardInLibrary;
/**
*
* @author LevelX2
*/
public class GatecreeperVine extends CardImpl<GatecreeperVine> {
private static final FilterCard filter = new FilterCard("basic land card or a Gate card");
static {
filter.add(
Predicates.or(
Predicates.and(
new CardTypePredicate(CardType.LAND),
new SupertypePredicate("Basic")),
new SubtypePredicate("Gate")));
}
public GatecreeperVine(UUID ownerId) {
super(ownerId, 124, "Gatecreeper Vine", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{1}{G}");
this.expansionSetCode = "RTR";
this.subtype.add("Plant");
this.color.setGreen(true);
this.power = new MageInt(0);
this.toughness = new MageInt(2);
// Defender
this.addAbility(DefenderAbility.getInstance());
// When Gatecreeper Vine enters the battlefield, you may search your library for a basic land card or a Gate card, reveal it, put it into your hand, then shuffle your library.
TargetCardInLibrary target = new TargetCardInLibrary(filter);
this.addAbility(new EntersBattlefieldTriggeredAbility(new SearchLibraryPutInHandEffect(target, true, true)));
}
public GatecreeperVine(final GatecreeperVine card) {
super(card);
}
@Override
public GatecreeperVine copy() {
return new GatecreeperVine(this);
}
}

View file

@ -0,0 +1,79 @@
/*
* 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.returntoravnica;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.MageInt;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.cost.SpellsCostReductionEffect;
import mage.cards.CardImpl;
import mage.filter.FilterCard;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
/**
*
* @author LevelX2
*/
public class GoblinElectromancer extends CardImpl<GoblinElectromancer> {
private static final FilterCard filter = new FilterCard("instant and sorcery spells");
static {
filter.add(Predicates.or(
new CardTypePredicate(CardType.INSTANT),
new CardTypePredicate(CardType.SORCERY)
));
}
public GoblinElectromancer(UUID ownerId) {
super(ownerId, 163, "Goblin Electromancer", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{U}{R}");
this.expansionSetCode = "RTR";
this.subtype.add("Goblin");
this.subtype.add("Wizard");
this.color.setBlue(true);
this.color.setRed(true);
this.power = new MageInt(2);
this.toughness = new MageInt(2);
// Instant and sorcery spells you cast cost {1} less to cast.
this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new SpellsCostReductionEffect(filter, 1)));
}
public GoblinElectromancer(final GoblinElectromancer card) {
super(card);
}
@Override
public GoblinElectromancer copy() {
return new GoblinElectromancer(this);
}
}

View file

@ -0,0 +1,132 @@
/*
* 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.returntoravnica;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.filter.FilterCard;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
/**
*
* @author LevelX2
*/
public class GrislySalvage extends CardImpl<GrislySalvage> {
public GrislySalvage(UUID ownerId) {
super(ownerId, 165, "Grisly Salvage", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{B}{G}");
this.expansionSetCode = "RTR";
this.color.setBlack(true);
this.color.setGreen(true);
// Reveal the top five cards of your library. You may put a creature or land card from among them into your hand. Put the rest into your graveyard.
this.getSpellAbility().addEffect(new GrislySalvageEffect());
}
public GrislySalvage(final GrislySalvage card) {
super(card);
}
@Override
public GrislySalvage copy() {
return new GrislySalvage(this);
}
}
class GrislySalvageEffect extends OneShotEffect<GrislySalvageEffect> {
public GrislySalvageEffect() {
super(Constants.Outcome.DrawCard);
this.staticText = "Reveal the top five cards of your library. You may put a creature or land card from among them into your hand. Put the rest into your graveyard";
}
public GrislySalvageEffect(final GrislySalvageEffect effect) {
super(effect);
}
@Override
public GrislySalvageEffect copy() {
return new GrislySalvageEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
Cards cards = new CardsImpl(Constants.Zone.PICK);
boolean properCardFound = false;
int count = Math.min(player.getLibrary().size(), 5);
for (int i = 0; i < count; i++) {
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
if (card.getCardType().contains(CardType.CREATURE) || card.getCardType().contains(CardType.LAND)) {
properCardFound = true;
}
}
}
if (!cards.isEmpty()) {
player.revealCards("Grisly Salvage", cards, game);
FilterCard filter = new FilterCard("creature or land card to put in hand");
filter.add(Predicates.or(new CardTypePredicate(CardType.CREATURE), new CardTypePredicate(CardType.LAND)));
TargetCard target = new TargetCard(Constants.Zone.PICK, filter);
if (properCardFound && player.choose(Constants.Outcome.DrawCard, cards, target, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
cards.remove(card);
card.moveToZone(Constants.Zone.HAND, source.getId(), game, false);
}
}
for (UUID cardId : cards) {
Card card = game.getCard(cardId);
if (card != null) {
card.moveToZone(Constants.Zone.GRAVEYARD, source.getId(), game, true);
}
}
}
return true;
}
return false;
}
}

View file

@ -0,0 +1,146 @@
/*
* 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.returntoravnica;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Outcome;
import mage.Constants.Rarity;
import mage.Constants.TargetController;
import mage.Constants.Zone;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.game.Game;
import mage.players.Player;
/**
*
* @author LevelX2
*/
public class HavocFestival extends CardImpl<HavocFestival> {
static final String rule = "Mana Bloom enters the battlefield with X charge counters on it";
public HavocFestival (UUID ownerId) {
super(ownerId, 166, "Havoc Festival", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{4}{B}{R}");
this.expansionSetCode = "RTR";
this.color.setBlack(true);
this.color.setRed(true);
// Players can't gain life.
this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new HavocFestivalEffect()));
// At the beginning of each player's upkeep, that player loses half his or her life, rounded up.
Ability ability = new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new HavocFestivalLoseLifeEffect(), TargetController.ANY, false);
this.addAbility(ability);
}
public HavocFestival (final HavocFestival card) {
super(card);
}
@Override
public HavocFestival copy() {
return new HavocFestival(this);
}
}
class HavocFestivalEffect extends ContinuousEffectImpl<HavocFestivalEffect> {
public HavocFestivalEffect() {
super(Constants.Duration.WhileOnBattlefield, Constants.Layer.PlayerEffects, Constants.SubLayer.NA, Outcome.Benefit);
staticText = "Players can't gain life";
}
public HavocFestivalEffect(final HavocFestivalEffect effect) {
super(effect);
}
@Override
public HavocFestivalEffect copy() {
return new HavocFestivalEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (UUID playerId: controller.getInRange()) {
Player player = game.getPlayer(playerId);
if (player != null)
{
player.setCanGainLife(false);
}
}
return true;
}
return false;
}
}
class HavocFestivalLoseLifeEffect extends OneShotEffect<HavocFestivalLoseLifeEffect> {
public HavocFestivalLoseLifeEffect() {
super(Outcome.Damage);
staticText = "that player loses half his or her life, rounded up";
}
public HavocFestivalLoseLifeEffect(final HavocFestivalLoseLifeEffect effect) {
super(effect);
}
@Override
public HavocFestivalLoseLifeEffect copy() {
return new HavocFestivalLoseLifeEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (player != null) {
Integer amount = (int) Math.ceil(player.getLife() / 2f);
if (amount > 0) {
player.loseLife(amount, game);
return true;
}
}
return false;
}
}

View file

@ -0,0 +1,123 @@
/*
* 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.returntoravnica;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Outcome;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.TriggeredAbility;
import mage.abilities.common.ActivateOncePerTurnActivatedAbility;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.condition.common.HasCounterCondition;
import mage.abilities.costs.common.RemoveCountersSourceCost;
import mage.abilities.decorator.ConditionalTriggeredAbility;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.AddManaOfAnyColorEffect;
import mage.abilities.effects.common.ReturnToHandSourceEffect;
import mage.cards.CardImpl;
import mage.choices.ChoiceColor;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author LevelX2
*/
public class ManaBloom extends CardImpl<ManaBloom> {
static final String rule = "with X charge counters on it";
public ManaBloom (UUID ownerId) {
super(ownerId, 130, "Mana Bloom", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{X}{G}");
this.expansionSetCode = "RTR";
this.color.setGreen(true);
// Mana Bloom enters the battlefield with X charge counters on it.
this.addAbility(new EntersBattlefieldAbility(new ManaBloomEffect(),rule));
// Remove a charge counter from Mana Bloom: Add one mana of any color to your mana pool. Activate this ability only once each turn.
Ability ability = new ActivateOncePerTurnActivatedAbility(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(), new RemoveCountersSourceCost(CounterType.CHARGE.createInstance()));
ability.addChoice(new ChoiceColor());
this.addAbility(ability);
// At the beginning of your upkeep, if Mana Bloom has no charge counters on it, return it to its owner's hand.
TriggeredAbility triggeredAbility = new BeginningOfUpkeepTriggeredAbility(new ReturnToHandSourceEffect(), Constants.TargetController.YOU, false);
this.addAbility(new ConditionalTriggeredAbility(triggeredAbility, new HasCounterCondition(CounterType.CHARGE, 0,0), "At the beginning of your upkeep, if Mana Bloom has no charge counters on it, return it to its owner's hand."));
}
public ManaBloom (final ManaBloom card) {
super(card);
}
@Override
public ManaBloom copy() {
return new ManaBloom(this);
}
}
class ManaBloomEffect extends OneShotEffect<ManaBloomEffect> {
public ManaBloomEffect() {
super(Outcome.Benefit);
}
public ManaBloomEffect(final ManaBloomEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) {
int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
if (amount > 0) {
permanent.addCounters(CounterType.CHARGE.createInstance(amount), game);
return true;
}
}
}
return true;
}
@Override
public ManaBloomEffect copy() {
return new ManaBloomEffect(this);
}
}