diff --git a/forge.preferences b/forge.preferences index e69de29bb2d..4b4935b3dce 100644 --- a/forge.preferences +++ b/forge.preferences @@ -0,0 +1,12 @@ +#Forge +#Mon Aug 16 20:50:29 CEST 2010 +gui.laf=com.sun.java.swing.plaf.windows.WindowsLookAndFeel +AI.stack.land=false +gui.new=true +stack.offset=tiny +card.images.size=medium +card.overlay=true +card.scale.larger.than.original=true +stack.max.size=3 +gui.laf.fonts=false +loss.condition.milling=false diff --git a/res/cards.txt b/res/cards.txt index a4a5e452b0a..6f67704069a 100644 --- a/res/cards.txt +++ b/res/cards.txt @@ -1,3 +1,18 @@ +Cancel +1 U U +Instant +Counter target spell. +spCounter:Spell:None:Graveyard:None +SVar:Rarity:Common +SVar:Picture:http://www.wizards.com/global/images/magic/general/cancel.jpg + +Dream Fracture +1 U U +Instant +Counter target spell. Its controller draws a card. Draw a card. +spCounter:Spell:None:Graveyard:My-Draw(1) CC-Draw(1) +SVar:Rarity:Uncommon + Hallowed Burial 3 W W Sorcery @@ -1493,13 +1508,6 @@ SVar:PlayMain1:TRUE SVar:Rarity:Common SVar:Picture:http://www.wizards.com/global/images/magic/general/umara_raptor.jpg -Dream Fracture -1 U U -Instant -Counter target spell. Its controller draws a card. Draw a card. -spCounter:Spell:None:Graveyard:My-Draw(1) Opp-Draw(1) -SVar:Rarity:Uncommon - Absorb W U U Instant @@ -1545,14 +1553,6 @@ Counter target activated ability. Draw a card. spCounter:Ability:None:None:My-Draw(1) SVar:Rarity:Rare -Cancel -1 U U -Instant -Counter target spell. -spCounter:Spell::Graveyard:None -SVar:Rarity:Common -SVar:Picture:http://www.wizards.com/global/images/magic/general/cancel.jpg - Confound 1 U Instant diff --git a/res/gui/display_new_layout.xml b/res/gui/display_new_layout.xml index 24db87518d8..1dd024493fe 100644 --- a/res/gui/display_new_layout.xml +++ b/res/gui/display_new_layout.xml @@ -1,12 +1,12 @@ - + 0 0 - 1289 - 932 + 1600 + 1123 @@ -17,7 +17,7 @@ 0 0 197 - 932 + 1123 @@ -28,7 +28,7 @@ 0 0 197 - 184 + 199 @@ -47,7 +47,7 @@ 0 - 184 + 199 197 5 @@ -62,9 +62,9 @@ 0 - 189 + 204 197 - 260 + 280 @@ -83,7 +83,7 @@ 0 - 449 + 484 197 5 @@ -98,9 +98,9 @@ 0 - 454 + 489 197 - 120 + 159 @@ -119,7 +119,7 @@ 0 - 574 + 648 197 5 @@ -134,9 +134,9 @@ 0 - 579 + 653 197 - 165 + 182 @@ -155,7 +155,7 @@ 0 - 744 + 835 197 5 @@ -170,9 +170,9 @@ 0 - 749 + 840 197 - 183 + 283 @@ -205,7 +205,7 @@ 197 0 5 - 932 + 1123 @@ -219,8 +219,8 @@ 202 0 - 772 - 932 + 1083 + 1123 @@ -230,8 +230,8 @@ 202 0 - 772 - 381 + 1083 + 501 @@ -250,8 +250,8 @@ 202 - 381 - 772 + 501 + 1083 5 @@ -265,9 +265,9 @@ 202 - 386 - 772 - 378 + 506 + 1083 + 404 @@ -286,8 +286,8 @@ 202 - 764 - 772 + 910 + 1083 5 @@ -301,9 +301,9 @@ 202 - 769 - 772 - 163 + 915 + 1083 + 208 @@ -336,10 +336,10 @@ - 974 + 1285 0 5 - 932 + 1123 @@ -351,10 +351,10 @@ - 979 + 1290 0 310 - 932 + 1123 @@ -362,10 +362,10 @@ - 979 + 1290 0 310 - 496 + 622 @@ -383,8 +383,8 @@ - 979 - 496 + 1290 + 622 310 5 @@ -398,10 +398,10 @@ - 979 - 501 + 1290 + 627 310 - 431 + 496 diff --git a/src/forge/CardFactory.java b/src/forge/CardFactory.java index d49175cd1af..e2ff62c650d 100644 --- a/src/forge/CardFactory.java +++ b/src/forge/CardFactory.java @@ -277,6 +277,318 @@ public class CardFactory implements NewConstants { } }); }//if "Comes into play tapped." + if(hasKeyword(card,"spCounter") != -1) { + System.out.println("Processing spCounter for card " + card.getName()); + ComputerAI_counterSpells2.KeywordedCounterspells.add(card.getName()); + String keyword = card.getKeyword().get(hasKeyword(card,"spCounter")); + if(keyword.contains("X")) + { + keyword = keyword.replace("X", card.getSVar("X")); + } + card.removeIntrinsicKeyword(keyword); + + String[] splitkeyword = keyword.split(":"); + + final String TargetType = splitkeyword[1]; + final String TargetingRestrictions = splitkeyword[2]; + final String Destination = splitkeyword[3]; + final String ExtraActions = splitkeyword[4]; + + final String[] SplitTargetingRestrictions = TargetingRestrictions.split(" "); + final String[] SplitExtraActions = ExtraActions.split(" "); + + SpellAbility spCounterAbility = new Spell(card) + { + private static final long serialVersionUID = 9763720166553L; + + @Override + public boolean canPlayAI() + { + System.out.println("AI is pondering us..."); + return canPlay(); + } + + @Override + public boolean canPlay() + { + if(AllZone.Stack.size() == 0) + { + return false; + } + + boolean fullResult = true; + SpellAbility sa = AllZone.Stack.peek(); + Card tgtCard = sa.getSourceCard(); + + if(TargetType.equals("Spell")) + { + if(sa.isAbility()) + { + System.out.println(card.getName() + " can only counter spells, not abilities."); + return false; + + } + } + else if(TargetType.equals("Ability")) + { + if(sa.isSpell()) + { + System.out.println(card.getName() + " can only counter abilities, not spells."); + return false; + } + } + else if(TargetType.equals("SpellOrAbility")) + { + //Do nothing. This block is only for clarity and enforcing parameters. + } + else + { + throw new IllegalArgumentException("Invalid target type for card " + card.getName()); + } + + for(int i=0;i")) + { + subResult |= (CardUtil.getConvertedManaCost(tgtCard) > value); + } + else if(mode.equals("==")) + { + subResult |= (CardUtil.getConvertedManaCost(tgtCard) == value); + } + else if(mode.equals("!=")) + { + subResult |= (CardUtil.getConvertedManaCost(tgtCard) != value); + } + else if(mode.equals("<=")) + { + subResult |= (CardUtil.getConvertedManaCost(tgtCard) <= value); + } + else if(mode.equals(">=")) + { + subResult |= (CardUtil.getConvertedManaCost(tgtCard) >= value); + } + else + { + throw new IllegalArgumentException("spCounter: Invalid mode parameter to CMC restriction in card " + card.getName()); + } + } + else if(RestrictionID.equals("Targets")) + { + for(int p=0;p permanent + { + if(sa.getTargetCard().getController() != card.getController()) + { + return false; + } + if(SplitParameters[p].contains("Non-")) + { + subResult |= !sa.getTargetCard().getType().contains(SplitParameters[p].substring(7)); + } + else + { + subResult |= (sa.getTargetCard().getType().contains(SplitParameters[p].substring(3))); + } + } + else if(SplitParameters[p].startsWith("Opp-")) //Targets opponent's permanent + { + if(sa.getTargetCard().getController() == card.getController()) + { + return false; + } + + if(SplitParameters[p].contains("Non-")) + { + subResult |= !(sa.getTargetCard().getType().contains(SplitParameters[p].substring(8))); + } + else + { + subResult |= (sa.getTargetCard().getType().contains(SplitParameters[p].substring(4))); + } + } + else + { + if(SplitParameters[p].contains("Non-")) + { + subResult |= !(sa.getTargetCard().getType().contains(SplitParameters[p].substring(4))); + } + else + { + subResult |= (sa.getTargetCard().getType().contains(SplitParameters[p])); + } + } + } + } + System.out.println("Sub: " + Boolean.toString(subResult)); + fullResult &= subResult; + } //End Targeting parsing + System.out.println("Success: " + Boolean.toString(fullResult)); + return fullResult; + } + + @Override + public void resolve() + { + System.out.println("Resolving " + card.getName()); + SpellAbility sa = AllZone.Stack.pop(); + + System.out.println("Send countered spell to " + Destination); + + if(Destination.equals("None") || TargetType.contains("Ability")) //For Ability-targeting counterspells + { + + } + else if(Destination.equals("Graveyard")) + { + AllZone.GameAction.moveToGraveyard(sa.getSourceCard()); + } + else if(Destination.equals("Exile")) + { + AllZone.GameAction.exile(sa.getSourceCard()); + } + else if(Destination.equals("Topdeck")) + { + AllZone.GameAction.moveToTopOfLibrary(sa.getSourceCard()); + } + else if(Destination.equals("Hand")) + { + AllZone.GameAction.moveToHand(sa.getSourceCard()); + } + else if(Destination.equals("BottomDeck")) + { + AllZone.GameAction.moveToBottomOfLibrary(sa.getSourceCard()); + } + else if(Destination.equals("Shuffle")) + { + AllZone.GameAction.moveToBottomOfLibrary(sa.getSourceCard()); + AllZone.GameAction.shuffle(sa.getSourceCard().getController()); + } + else + { + throw new IllegalArgumentException("spCounter: Invalid Destination argument for card " + card.getName()); + } + + for(int ea = 0;ea")) - { - subResult |= (CardUtil.getConvertedManaCost(tgtCard) > value); - } - else if(mode.equals("==")) - { - subResult |= (CardUtil.getConvertedManaCost(tgtCard) == value); - } - else if(mode.equals("!=")) - { - subResult |= (CardUtil.getConvertedManaCost(tgtCard) != value); - } - else if(mode.equals("<=")) - { - subResult |= (CardUtil.getConvertedManaCost(tgtCard) <= value); - } - else if(mode.equals(">=")) - { - subResult |= (CardUtil.getConvertedManaCost(tgtCard) >= value); - } - else - { - throw new IllegalArgumentException("spCounter: Invalid mode parameter to CMC restriction in card " + card.getName()); - } - } - else if(RestrictionID.equals("Targets")) - { - for(int p=0;p permanent - { - if(sa.getTargetCard().getController() != card.getController()) - { - return false; - } - if(SplitParameters[p].contains("Non-")) - { - subResult |= !sa.getTargetCard().getType().contains(SplitParameters[p].substring(7)); - } - else - { - subResult |= (sa.getTargetCard().getType().contains(SplitParameters[p].substring(3))); - } - } - else if(SplitParameters[p].startsWith("Opp-")) //Targets opponent's permanent - { - if(sa.getTargetCard().getController() == card.getController()) - { - return false; - } - - if(SplitParameters[p].contains("Non-")) - { - subResult |= !(sa.getTargetCard().getType().contains(SplitParameters[p].substring(8))); - } - else - { - subResult |= (sa.getTargetCard().getType().contains(SplitParameters[p].substring(4))); - } - } - else - { - if(SplitParameters[p].contains("Non-")) - { - subResult |= !(sa.getTargetCard().getType().contains(SplitParameters[p].substring(4))); - } - else - { - subResult |= (sa.getTargetCard().getType().contains(SplitParameters[p])); - } - } - } - } - System.out.println("Sub: " + Boolean.toString(subResult)); - fullResult &= subResult; - } //End Targeting parsing - System.out.println("Success: " + Boolean.toString(fullResult)); - return fullResult; - } - - @Override - public void resolve() - { - System.out.println("Resolving " + card.getName()); - SpellAbility sa = AllZone.Stack.pop(); - - System.out.println("Send countered spell to " + Destination); - - if(Destination.equals("None") || TargetType.contains("Ability")) //For Ability-targeting counterspells - { - - } - else if(Destination.equals("Graveyard")) - { - AllZone.GameAction.moveToGraveyard(sa.getSourceCard()); - } - else if(Destination.equals("Exile")) - { - AllZone.GameAction.exile(sa.getSourceCard()); - } - else if(Destination.equals("Topdeck")) - { - AllZone.GameAction.moveToTopOfLibrary(sa.getSourceCard()); - } - else if(Destination.equals("Hand")) - { - AllZone.GameAction.moveToHand(sa.getSourceCard()); - } - else if(Destination.equals("BottomDeck")) - { - AllZone.GameAction.moveToBottomOfLibrary(sa.getSourceCard()); - } - else if(Destination.equals("Shuffle")) - { - AllZone.GameAction.moveToBottomOfLibrary(sa.getSourceCard()); - AllZone.GameAction.shuffle(sa.getSourceCard().getController()); - } - else - { - throw new IllegalArgumentException("spCounter: Invalid Destination argument for card " + card.getName()); - } - - for(int ea = 0;ea