[ISD] Garruk Relentless // Garruk, the Veil-Cursed

This commit is contained in:
magenoxx 2011-09-21 23:38:24 +04:00
parent c386e15dff
commit 8aed187209
5 changed files with 378 additions and 24 deletions

View file

@ -0,0 +1,158 @@
/*
* 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.innistrad;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.LoyaltyAbility;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.TransformSourceEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.keyword.TransformAbility;
import mage.cards.CardImpl;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.WolfToken;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
* @author nantuko
*/
public class GarrukRelentless extends CardImpl<GarrukRelentless> {
public GarrukRelentless(UUID ownerId) {
super(ownerId, 181, "Garruk Relentless", Rarity.MYTHIC, new CardType[]{CardType.PLANESWALKER}, "{3}{G}");
this.expansionSetCode = "ISD";
this.subtype.add("Garruk");
this.color.setGreen(true);
this.canTransform = true;
this.secondSideCard = new GarrukTheVeilCursed(ownerId);
this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.LOYALTY.createInstance(3)), ""));
// When Garruk Relentless has two or fewer loyalty counters on him, transform him.
this.addAbility(new TransformAbility());
this.addAbility(new GarrukRelentlessTriggeredAbility());
// 0: Garruk Relentless deals 3 damage to target creature. That creature deals damage equal to its power to him
LoyaltyAbility ability1 = new LoyaltyAbility(new GarrukRelentlessDamageEffect(), 0);
ability1.addTarget(new TargetCreaturePermanent());
this.addAbility(ability1);
// 0: Put a 2/2 green Wolf creature token onto the battlefield.
LoyaltyAbility ability2 = new LoyaltyAbility(new CreateTokenEffect(new WolfToken()), 0);
this.addAbility(ability2);
}
public GarrukRelentless(final GarrukRelentless card) {
super(card);
}
@Override
public GarrukRelentless copy() {
return new GarrukRelentless(this);
}
}
class GarrukRelentlessTriggeredAbility extends TriggeredAbilityImpl<GarrukRelentlessTriggeredAbility> {
public GarrukRelentlessTriggeredAbility() {
super(Constants.Zone.BATTLEFIELD, new TransformSourceEffect(), true);
}
public GarrukRelentlessTriggeredAbility(GarrukRelentlessTriggeredAbility ability) {
super(ability);
}
@Override
public GarrukRelentlessTriggeredAbility copy() {
return new GarrukRelentlessTriggeredAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER && event.getTargetId().equals(sourceId)) {
Permanent permanent = game.getPermanent(sourceId);
if (permanent != null && !permanent.isTransformed() && permanent.getCounters().getCount(CounterType.LOYALTY) <= 2) {
return true;
}
}
return false;
}
@Override
public String getRule() {
return "When Garruk Relentless has two or fewer loyalty counters on him, transform him";
}
}
class GarrukRelentlessDamageEffect extends OneShotEffect<GarrukRelentlessDamageEffect> {
public GarrukRelentlessDamageEffect() {
super(Constants.Outcome.Damage);
staticText = "Garruk Relentless deals 3 damage to target creature. That creature deals damage equal to its power to him";
}
public GarrukRelentlessDamageEffect(GarrukRelentlessDamageEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(targetPointer.getFirst(source));
if (permanent != null) {
int damage = permanent.getPower().getValue();
permanent.damage(3, source.getSourceId(), game, true, false);
if (damage > 0) {
Permanent garruk = game.getPermanent(source.getSourceId());
if (garruk != null) {
garruk.damage(damage, permanent.getId(), game, true, false);
}
}
return true;
}
return false;
}
@Override
public GarrukRelentlessDamageEffect copy() {
return new GarrukRelentlessDamageEffect(this);
}
}

View file

@ -0,0 +1,205 @@
/*
* 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.innistrad;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.LoyaltyAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.Effects;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.continious.BoostControlledEffect;
import mage.abilities.effects.common.continious.GainAbilityControlledEffect;
import mage.abilities.keyword.TrampleAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.filter.Filter;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreatureCard;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.WolfTokenWithDeathtouch;
import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetCardInLibrary;
import mage.target.common.TargetControlledPermanent;
import java.util.UUID;
/**
* @author nantuko
*/
public class GarrukTheVeilCursed extends CardImpl<GarrukTheVeilCursed> {
public GarrukTheVeilCursed(UUID ownerId) {
super(ownerId, 1181, "Garruk, the Veil-Cursed", Rarity.MYTHIC, new CardType[]{CardType.PLANESWALKER}, "");
this.expansionSetCode = "ISD";
this.subtype.add("Garruk");
// this card is the second face of double-faced card
this.nightCard = true;
this.canTransform = true;
this.color.setGreen(true);
this.color.setBlack(true);
// +1 : Put a 1/1 black Wolf creature token with deathtouch onto the battlefield.
LoyaltyAbility ability1 = new LoyaltyAbility(new CreateTokenEffect(new WolfTokenWithDeathtouch()), 1);
this.addAbility(ability1);
// -1 : Sacrifice a creature. If you do, search your library for a creature card, reveal it, put it into your hand, then shuffle your library.
LoyaltyAbility ability2 = new LoyaltyAbility(new GarrukTheVeilCursedEffect(), -1);
this.addAbility(ability2);
// -3 : Creatures you control gain trample and get +X/+X until end of turn, where X is the number of creature cards in your graveyard.
Effects effects1 = new Effects();
BoostControlledEffect effect = new BoostControlledEffect(new GarrukTheVeilCursedValue(), new GarrukTheVeilCursedValue(), Constants.Duration.EndOfTurn);
effect.setRule("Creatures you control get +X/+X until end of turn, where X is the number of creature cards in your graveyard");
effects1.add(effect);
effects1.add(new GainAbilityControlledEffect(TrampleAbility.getInstance(), Constants.Duration.EndOfTurn, FilterCreaturePermanent.getDefault()));
this.addAbility(new LoyaltyAbility(effects1, -3));
}
public GarrukTheVeilCursed(final GarrukTheVeilCursed card) {
super(card);
}
@Override
public GarrukTheVeilCursed copy() {
return new GarrukTheVeilCursed(this);
}
}
class GarrukTheVeilCursedValue implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility) {
Player player = game.getPlayer(sourceAbility.getControllerId());
if (player != null) {
return player.getGraveyard().getCards(FilterCreatureCard.getDefault(), game).size();
}
return 0;
}
@Override
public DynamicValue clone() {
return this;
}
@Override
public String getMessage() {
return "the number of creature cards in your graveyard";
}
@Override
public String toString() {
return "+X";
}
}
class GarrukTheVeilCursedEffect extends OneShotEffect<GarrukTheVeilCursedEffect> {
private static FilterPermanent filterCreature = new FilterPermanent("a creature you control");
static {
filterCreature.getCardType().add(CardType.CREATURE);
filterCreature.setScopeCardType(Filter.ComparisonScope.Any);
filterCreature.setTargetController(Constants.TargetController.YOU);
}
public GarrukTheVeilCursedEffect() {
super(Constants.Outcome.Benefit);
staticText = "Sacrifice a creature. If you do, search your library for a creature card, reveal it, put it into your hand, then shuffle your library";
}
public GarrukTheVeilCursedEffect(final GarrukTheVeilCursedEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
// sacrifice a creature
Target target = new TargetControlledPermanent(1, 1, filterCreature, false);
boolean sacrificed = false;
if (target.canChoose(player.getId(), game)) {
while (!target.isChosen() && target.canChoose(player.getId(), game)) {
player.choose(Constants.Outcome.Sacrifice, target, game);
}
for (int idx = 0; idx < target.getTargets().size(); idx++) {
Permanent permanent = game.getPermanent((UUID) target.getTargets().get(idx));
if (permanent != null) {
sacrificed |= permanent.sacrifice(source.getSourceId(), game);
}
}
}
if (sacrificed) {
// search
FilterCreatureCard filter = new FilterCreatureCard();
TargetCardInLibrary targetInLibrary = new TargetCardInLibrary(filter);
Cards cards = new CardsImpl();
if (player.searchLibrary(targetInLibrary, game)) {
for (UUID cardId : target.getTargets()) {
Card card = player.getLibrary().remove(cardId, game);
if (card != null) {
card.moveToZone(Constants.Zone.HAND, source.getId(), game, false);
cards.add(card);
}
}
}
// reveal
if (cards.size() > 0) {
player.revealCards("Garruk, the Veil-Cursed", cards, game);
}
// shuffle
player.shuffleLibrary(game);
return true;
}
return false;
}
@Override
public GarrukTheVeilCursedEffect copy() {
return new GarrukTheVeilCursedEffect(this);
}
}

View file

@ -28,23 +28,15 @@
package mage.sets.scarsofmirrodin;
import java.util.UUID;
import mage.Constants.AttachmentType;
import mage.Constants.CardType;
import mage.Constants.Outcome;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt;
import mage.ObjectColor;
import mage.Constants.*;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continious.BoostEquippedEffect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.continious.GainAbilityAttachedEffect;
import mage.abilities.effects.common.PutLibraryIntoGraveTargetEffect;
import mage.abilities.effects.common.continious.BoostEquippedEffect;
import mage.abilities.effects.common.continious.GainAbilityAttachedEffect;
import mage.abilities.keyword.EquipAbility;
import mage.abilities.keyword.ProtectionAbility;
import mage.cards.CardImpl;
@ -54,10 +46,11 @@ import mage.game.Game;
import mage.game.events.DamagedPlayerEvent;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.Token;
import mage.target.TargetPlayer;
import mage.game.permanent.token.WolfToken;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/**
*
* @author Loki
@ -129,15 +122,4 @@ class SwordOfBodyAndMindAbility extends TriggeredAbilityImpl<SwordOfBodyAndMindA
public String getRule() {
return "Whenever equipped creature deals combat damage to a player, you put a 2/2 green Wolf creature token onto the battlefield and that player puts the top ten cards of his or her library into his or her graveyard.";
}
}
class WolfToken extends Token {
public WolfToken() {
super("Wolf", "a 2/2 green Wolf creature token");
cardType.add(CardType.CREATURE);
color = ObjectColor.GREEN;
subtype.add("Wolf");
power = new MageInt(2);
toughness = new MageInt(2);
}
}

View file

@ -144,4 +144,8 @@ public class BoostControlledEffect extends ContinuousEffectImpl<BoostControlledE
staticText = sb.toString();
}
public void setRule(String rule) {
staticText = rule;
}
}

View file

@ -37,6 +37,8 @@ import mage.filter.FilterCard;
*/
public class FilterCreatureCard extends FilterCard<FilterCreatureCard> {
protected static FilterCreatureCard defaultFilter = new FilterCreatureCard();
public FilterCreatureCard() {
this("creature card");
}
@ -55,4 +57,7 @@ public class FilterCreatureCard extends FilterCard<FilterCreatureCard> {
return new FilterCreatureCard(this);
}
public static FilterCreatureCard getDefault() {
return defaultFilter;
}
}