diff --git a/.gitattributes b/.gitattributes index 939c298476c..487b9834217 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4759,6 +4759,7 @@ res/cardsfolder/g/guided_strike.txt svneol=native#text/plain res/cardsfolder/g/guiding_spirit.txt -text res/cardsfolder/g/guild_feud.txt -text res/cardsfolder/g/guildscorn_ward.txt -text +res/cardsfolder/g/guile.txt -text res/cardsfolder/g/guiltfeeder.txt svneol=native#text/plain res/cardsfolder/g/guilty_conscience.txt svneol=native#text/plain res/cardsfolder/g/guise_of_fire.txt -text @@ -14302,6 +14303,7 @@ src/main/java/forge/card/mana/ManaCostShard.java -text src/main/java/forge/card/mana/ManaPool.java svneol=native#text/plain src/main/java/forge/card/mana/package-info.java svneol=native#text/plain src/main/java/forge/card/package-info.java svneol=native#text/plain +src/main/java/forge/card/replacement/ReplaceCounter.java -text src/main/java/forge/card/replacement/ReplaceDamage.java -text src/main/java/forge/card/replacement/ReplaceDestroy.java -text src/main/java/forge/card/replacement/ReplaceDiscard.java -text diff --git a/res/cardsfolder/g/guile.txt b/res/cardsfolder/g/guile.txt new file mode 100644 index 00000000000..db85cbad532 --- /dev/null +++ b/res/cardsfolder/g/guile.txt @@ -0,0 +1,12 @@ +Name:Guile +ManaCost:3 U U U +Types:Creature Elemental Incarnation +PT:6/6 +K:CantBeBlockedByAmount LT3 +R:Event$ Counter | ActiveZones$ Battlefield | ValidType$ Spell | ValidCause$ Card.YouCtrl | ReplaceWith$ DBRemove | Description$ If a spell or ability you control would counter a spell, instead exile that spell and you may play that card without paying its mana cost. +SVar:DBRemove:AB$ ChangeZone | Cost$ 0 | Defined$ ReplacedCard | Origin$ Stack | Destination$ Exile | Fizzle$ True | SubAbility$ DBPlay +SVar:DBPlay:DB$ Play | Defined$ ReplacedCard | WithoutManaCost$ True | Optional$ True +T:Mode$ ChangesZone | Origin$ Any | Destination$ Graveyard | ValidCard$ Card.Self | Execute$ TrigShuffle | TriggerDescription$ When CARDNAME is put into a graveyard from anywhere, shuffle it into its owner's library. +SVar:TrigShuffle:AB$ ChangeZone | Cost$ 0 | Origin$ Graveyard | Destination$ Library | Shuffle$ True | Defined$ Self +SVar:Picture:http://www.wizards.com/global/images/magic/general/guile.jpg +Oracle:Guile can't be blocked except by three or more creatures.\nIf a spell or ability you control would counter a spell, instead exile that spell and you may play that card without paying its mana cost.\nWhen Guile is put into a graveyard from anywhere, shuffle it into its owner's library. diff --git a/src/main/java/forge/card/ability/effects/CounterEffect.java b/src/main/java/forge/card/ability/effects/CounterEffect.java index 7bb41e3a411..1818d8c9450 100644 --- a/src/main/java/forge/card/ability/effects/CounterEffect.java +++ b/src/main/java/forge/card/ability/effects/CounterEffect.java @@ -8,6 +8,7 @@ import forge.Card; import forge.card.ability.SpellAbilityEffect; import forge.card.cardfactory.CardFactoryUtil; import forge.game.Game; +import forge.card.replacement.ReplacementResult; import forge.card.spellability.SpellAbility; import forge.card.spellability.SpellAbilityStackInstance; import forge.card.spellability.SpellPermanent; @@ -140,6 +141,15 @@ public class CounterEffect extends SpellAbilityEffect { */ private void removeFromStack(final SpellAbility tgtSA, final SpellAbility srcSA, final SpellAbilityStackInstance si) { final Game game = tgtSA.getActivatingPlayer().getGame(); + // Run any applicable replacement effects. + final HashMap repParams = new HashMap(); + repParams.put("Event", "Counter"); + repParams.put("TgtSA", tgtSA); + repParams.put("Affected", tgtSA.getSourceCard()); + repParams.put("Cause", srcSA.getSourceCard()); + if (game.getReplacementHandler().run(repParams) != ReplacementResult.NotReplaced) { + return; + } game.getStack().remove(si); String destination = srcSA.hasParam("Destination") ? srcSA.getParam("Destination") : "Graveyard"; diff --git a/src/main/java/forge/card/replacement/ReplaceCounter.java b/src/main/java/forge/card/replacement/ReplaceCounter.java new file mode 100644 index 00000000000..68266219b78 --- /dev/null +++ b/src/main/java/forge/card/replacement/ReplaceCounter.java @@ -0,0 +1,77 @@ +/* + * Forge: Play Magic: the Gathering. + * Copyright (C) 2011 Forge Team + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package forge.card.replacement; + +import java.util.Map; + +import forge.Card; +import forge.card.spellability.SpellAbility; + +/** + * TODO: Write javadoc for this type. + * + */ +public class ReplaceCounter extends ReplacementEffect { + + /** + * Instantiates a new replace gain life. + * + * @param map the map + * @param host the host + */ + public ReplaceCounter(Map map, Card host) { + super(map, host); + } + + /* (non-Javadoc) + * @see forge.card.replacement.ReplacementEffect#canReplace(java.util.HashMap) + */ + @Override + public boolean canReplace(Map runParams) { + final SpellAbility spellAbility = (SpellAbility) runParams.get("TgtSA"); + if (!runParams.get("Event").equals("Counter")) { + return false; + } + if (this.getMapParams().containsKey("ValidCard")) { + if (!matchesValid(runParams.get("Affected"), this.getMapParams().get("ValidCard").split(","), this.getHostCard())) { + return false; + } + } + if (this.getMapParams().containsKey("ValidCause")) { + if (!matchesValid(runParams.get("Cause"), this.getMapParams().get("ValidCause").split(","), this.getHostCard())) { + return false; + } + } + if (this.getMapParams().containsKey("ValidType")) { + String type = this.getMapParams().get("ValidType"); + if (type.equals("Spell") && !spellAbility.isSpell()) { + return false; + } + } + return true; + } + + /* (non-Javadoc) + * @see forge.card.replacement.ReplacementEffect#setReplacingObjects(java.util.HashMap, forge.card.spellability.SpellAbility) + */ + @Override + public void setReplacingObjects(Map runParams, SpellAbility sa) { + sa.setReplacingObject("Card", runParams.get("Affected")); + } + +} diff --git a/src/main/java/forge/card/replacement/ReplacementType.java b/src/main/java/forge/card/replacement/ReplacementType.java index 036146a9785..03263218cb4 100644 --- a/src/main/java/forge/card/replacement/ReplacementType.java +++ b/src/main/java/forge/card/replacement/ReplacementType.java @@ -11,6 +11,7 @@ import forge.Card; * */ public enum ReplacementType { + Counter(ReplaceCounter.class), DamageDone(ReplaceDamage.class), Destroy(ReplaceDestroy.class), Discard(ReplaceDiscard.class),