From 1d2962bd05a61b16dbcd5d7a8b295451eec1b0e6 Mon Sep 17 00:00:00 2001 From: jendave Date: Sat, 6 Aug 2011 03:10:24 +0000 Subject: [PATCH] - Added Collective Restraint, Mana Leak, Daze, Force Spike, Convolute, Rune Boggle, Spell Snip. - Fixed an issue with the Propaganda cards. - Fixed Merrow Harbinger. - Fixed Cloudseeder. - Goblin Chieftain should only pump controlled Goblins. --- res/cards.txt | 37 ++++++++ res/main.properties | 2 +- src/forge/CardFactory.java | 135 +++++++++++++++++++++++++++ src/forge/CardFactoryUtil.java | 37 ++++++++ src/forge/CardFactory_Creatures.java | 4 +- src/forge/CombatUtil.java | 6 +- src/forge/GameActionUtil.java | 6 +- 7 files changed, 219 insertions(+), 8 deletions(-) diff --git a/res/cards.txt b/res/cards.txt index 39930028af5..d05dc332187 100644 --- a/res/cards.txt +++ b/res/cards.txt @@ -1,3 +1,40 @@ +Collective Restraint +3 U +Enchantment +Domain - Creatures can't attack you unless their controller pays {X} for each creature he or she controls that's attacking you, where X is the number of basic land types among lands you control. + +Force Spike +U +Instant +Counter target spell unless its controller pays 1. + +Daze +1 U +Instant +no text + +Convolute +2 U +Instant +Counter target spell unless its controller pays 4. + +Rune Boggle +2 U +Instant +Counter target spell unless its controller pays 1. +Cantrip + +Spell Snip +2 U +Instant +Counter target spell unless its controller pays 1. +Cycling:2 + +Mana Leak +1 U +Instant +Counter target spell unless its controller pays 3. + Windborn Muse 3 W Creature Spirit diff --git a/res/main.properties b/res/main.properties index a580e26caae..aad0438bb96 100644 --- a/res/main.properties +++ b/res/main.properties @@ -1,6 +1,6 @@ program/mail=mtgerror@yahoo.com program/forum=http://www.slightlymagic.net/forum/viewforum.php?f=26 -program/version=Forge -- official beta: 10/01/01, SVN revision: 257 +program/version=Forge -- official beta: 10/01/01, SVN revision: 258 tokens--file=AllTokens.txt diff --git a/src/forge/CardFactory.java b/src/forge/CardFactory.java index 9f831baa4cd..35eeb7d653d 100644 --- a/src/forge/CardFactory.java +++ b/src/forge/CardFactory.java @@ -9478,6 +9478,141 @@ public class CardFactory implements NewConstants { }//*************** END ************ END ************************** + //*************** START *********** START ************************** + else if(cardName.equals("Mana Leak") || cardName.equals("Convolute") || cardName.equals("Daze") || cardName.equals("Force Spike") || + cardName.equals("Rune Boggle") || cardName.equals("Spell Snip")) + { + SpellAbility spell = new Spell(card) + { + private static final long serialVersionUID = 6139754377230333678L; + public void resolve() + { + String manaCost = "1"; + if (cardName.equals("Mana Leak")) + manaCost = "3"; + else if (cardName.equals("Convolute")) + manaCost = "4"; + Ability ability = new Ability(card, manaCost){ + public void resolve() + { + ; + } + }; + + final Command unpaidCommand = new Command() + { + private static final long serialVersionUID = 8094833091127334678L; + + public void execute() + { + SpellAbility sa = AllZone.Stack.pop(); + AllZone.GameAction.moveToGraveyard(sa.getSourceCard()); + } + }; + + if (card.getController().equals(Constant.Player.Computer)) + { + AllZone.InputControl.setInput(new Input_PayManaCost_Ability(card +"\r\n", ability.getManaCost(), Command.Blank, unpaidCommand)); + } + else + { + if (ComputerUtil.canPayCost(ability)) + ComputerUtil.playNoStack(ability); + else + { + SpellAbility sa = AllZone.Stack.pop(); + AllZone.GameAction.moveToGraveyard(sa.getSourceCard()); + } + } + + } + public boolean canPlay() + { + if(AllZone.Stack.size() == 0) + return false; + + //see if spell is on stack and that opponent played it + String opponent = AllZone.GameAction.getOpponent(card.getController()); + SpellAbility sa = AllZone.Stack.peek(); + + return sa.isSpell() && opponent.equals(sa.getSourceCard().getController()) + && CardFactoryUtil.isCounterable(sa.getSourceCard()); + } + }; + card.clearSpellAbility(); + card.addSpellAbility(spell); + + if (cardName.equals("Daze")) + { + spell.setDescription("Counter target spell unless its controller pays 1."); + spell.setStackDescription(card.getName() + " - Counter target spell unless its controller pays 1."); + final SpellAbility bounce = new Spell(card) + { + private static final long serialVersionUID = -8310299673731730438L; + + public void resolve() + { + SpellAbility sa = AllZone.Stack.pop(); + AllZone.GameAction.moveToGraveyard(sa.getSourceCard()); + } + public boolean canPlay() + { + if(AllZone.Stack.size() == 0) + return false; + + //see if spell is on stack and that opponent played it + String opponent = AllZone.GameAction.getOpponent(card.getController()); + SpellAbility sa = AllZone.Stack.peek(); + + PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController()); + CardList list = new CardList(play.getCards()); + list = list.getType("Island"); + return sa.isSpell() && opponent.equals(sa.getSourceCard().getController()) + && CardFactoryUtil.isCounterable(sa.getSourceCard()) && list.size() >= 1; + } + + public boolean canPlayAI() + { + return false; + } + + }; + bounce.setDescription("You may return an Island you control to their owner's hand rather than pay Daze's mana cost."); + bounce.setStackDescription(card.getName() + " - Counter target spell unless its controller pays 1."); + bounce.setManaCost("0"); + + final Input bounceIslands = new Input() + { + private static final long serialVersionUID = 7624182730685889456L; + int stop = 1; + int count = 0; + + public void showMessage() + { + AllZone.Display.showMessage("Select an Island"); + ButtonUtil.disableAll(); + } + public void selectButtonCancel() {stop();} + public void selectCard(Card c, PlayerZone zone) + { + if(c.getType().contains("Island") && zone.is(Constant.Zone.Play)) + { + AllZone.GameAction.moveToHand(c); + + count++; + if(count == stop) { + AllZone.Stack.add(bounce); + stop(); + } + } + }//selectCard() + }; + + bounce.setBeforePayMana(bounceIslands); + card.addSpellAbility(bounce); + }//if Daze + }//*************** END ************ END ************************** + //*************** START *********** START ************************** else if(cardName.equals("Remand")) diff --git a/src/forge/CardFactoryUtil.java b/src/forge/CardFactoryUtil.java index 8d69169a0d1..5023554f910 100644 --- a/src/forge/CardFactoryUtil.java +++ b/src/forge/CardFactoryUtil.java @@ -3032,6 +3032,20 @@ public class CardFactoryUtil return list; } + public static int countBasicLandTypes(String player) + { + String basic[] = {"Forest", "Plains", "Mountain", "Island", "Swamp"}; + PlayerZone play = AllZone.getZone(Constant.Zone.Play, player); + CardList list = new CardList(play.getCards()); + int count = 0; + + for(int i = 0; i < basic.length; i++) + if (! list.getType(basic[i]).isEmpty()) + count++; + + return count; + } + //total cost to pay for an attacker c, cards like Propaganda, Ghostly Prison, Collective Restraint, ... public static String getPropagandaCost(Card c) { @@ -3048,11 +3062,34 @@ public class CardFactoryUtil }); int cost = list.size() * 2; + list = new CardList(play.getCards()); + list = list.getName("Collective Restraint"); + + int domain = countBasicLandTypes(AllZone.GameAction.getOpponent(c.getController())); + + cost += domain * list.size(); + s = Integer.toString(cost); return s; } + public static int getUsableManaSources(String player) + { + PlayerZone play = AllZone.getZone(Constant.Zone.Play, player); + CardList list = new CardList(play.getCards()); + list = list.filter(new CardListFilter() + { + public boolean addCard(Card c) + { + for (Ability_Mana am : c.getBasicMana()) + if (am.canPlay()) return true; + return false; + } + }); + + return list.size(); + } //do card1 and card2 share any colors? public static boolean sharesColorWith(Card card1, Card card2) diff --git a/src/forge/CardFactory_Creatures.java b/src/forge/CardFactory_Creatures.java index 521df7e2fdb..543d31fbf8a 100644 --- a/src/forge/CardFactory_Creatures.java +++ b/src/forge/CardFactory_Creatures.java @@ -10264,7 +10264,7 @@ public class CardFactory_Creatures { c.setName("Cloud Sprite"); c.setImageName("U 1 1 Cloud Sprite"); c.addIntrinsicKeyword("Flying"); - c.addIntrinsicKeyword("This creature can block only creatures with flying"); + c.addIntrinsicKeyword("This creature can block only creatures with flying."); play.add(c); }//makeToken() @@ -17188,7 +17188,7 @@ public class CardFactory_Creatures { }//*************** END ************ END ************************** //*************** START *********** START ************************** - else if(cardName.equals("Merfolk Harbinger")) + else if(cardName.equals("Merrow Harbinger")) { final SpellAbility ability = new Ability(card, "0") { diff --git a/src/forge/CombatUtil.java b/src/forge/CombatUtil.java index b8888b7dcad..8bcf80cf169 100644 --- a/src/forge/CombatUtil.java +++ b/src/forge/CombatUtil.java @@ -723,7 +723,6 @@ public class CombatUtil private static final long serialVersionUID = -6483405139208343935L; public void execute() { - //AllZone.GameAction.sacrifice(c); canAttack[0] = false; AllZone.Combat.removeFromCombat(crd); crd.untap(); @@ -745,8 +744,11 @@ public class CombatUtil { if (ComputerUtil.canPayCost(ability)) ComputerUtil.playNoStack(ability); - else + else { canAttack[0] = false; + AllZone.Combat.removeFromCombat(crd); + crd.untap(); + } } } } diff --git a/src/forge/GameActionUtil.java b/src/forge/GameActionUtil.java index a4a0f55934e..790e099975a 100644 --- a/src/forge/GameActionUtil.java +++ b/src/forge/GameActionUtil.java @@ -12655,9 +12655,9 @@ public class GameActionUtil // for each zone found add +1/+1 to each card for (int outer = 0; outer < zone.length; outer++) { - CardList creature = new CardList(); - creature.addAll(AllZone.Human_Play.getCards()); - creature.addAll(AllZone.Computer_Play.getCards()); + CardList creature = new CardList(zone[outer].getCards()); + //creature.addAll(AllZone.Human_Play.getCards()); + //creature.addAll(AllZone.Computer_Play.getCards()); creature = creature.getType("Goblin"); for (int i = 0; i < creature.size(); i++)