diff --git a/.gitattributes b/.gitattributes index 89141dba641..beb70b76cd8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5625,7 +5625,6 @@ src/forge/ComputerAI_General.java -text svneol=native#text/plain src/forge/ComputerAI_Input.java svneol=native#text/plain src/forge/ComputerAI_Rats2.java svneol=native#text/plain src/forge/ComputerAI_StackNotEmpty.java svneol=native#text/plain -src/forge/ComputerAI_counterSpells.java -text svneol=native#text/plain src/forge/ComputerAI_counterSpells2.java -text svneol=native#text/plain src/forge/ComputerUtil.java -text svneol=native#text/plain src/forge/ComputerUtil_Attack2.java svneol=native#text/plain diff --git a/forge.preferences b/forge.preferences index f6892371084..e69de29bb2d 100644 --- a/forge.preferences +++ b/forge.preferences @@ -1,12 +0,0 @@ -#Forge -#Mon Nov 08 21:31:15 CET 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.scale.larger.than.original=true -card.overlay=true -stack.max.size=3 -loss.condition.milling=false -gui.laf.fonts=false diff --git a/src/forge/AbilityFactory_PermanentState.java b/src/forge/AbilityFactory_PermanentState.java index 9b55ef4aed1..bab07ebc3ef 100644 --- a/src/forge/AbilityFactory_PermanentState.java +++ b/src/forge/AbilityFactory_PermanentState.java @@ -151,7 +151,7 @@ public class AbilityFactory_PermanentState { @Override public String getStackDescription(){ // when getStackDesc is called, just build exactly what is happening - StringBuilder sb = new StringBuilder("Untap "); + StringBuilder sb = new StringBuilder("Tap "); String name = af.getHostCard().getName(); Card tgt = getTargetCard(); if (tgt != null) diff --git a/src/forge/CardFactory.java b/src/forge/CardFactory.java index 852a84d022f..d5fe9f7dc64 100644 --- a/src/forge/CardFactory.java +++ b/src/forge/CardFactory.java @@ -12211,34 +12211,13 @@ public class CardFactory implements NewConstants { private static final long serialVersionUID = 98743547743456L; public void execute() { - card.setSVar("HSStamp","" + Input_Cleanup.GetHandSizeStamp()); - if(card.getController() == AllZone.HumanPlayer) { - //System.out.println("Human played me! Mode(" + Mode + ") Amount(" + Amount + ") Target(" + Target + ")" ); - if(Target.equals("Self")) { - Input_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp")))); - } - else if(Target.equals("Opponent")) { - Computer_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp")))); - } - else if(Target.equals("All")) { - Computer_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp")))); - Input_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp")))); - } - } - else - { - //System.out.println("Compy played me! Mode(" + Mode + ") Amount(" + Amount + ") Target(" + Target + ")" ); - if(Target.equals("Self")) { - Computer_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp")))); - } - else if(Target.equals("Opponent")) { - Input_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp")))); - } - else if(Target.equals("All")) { - Computer_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp")))); - Input_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp")))); - } - } + card.setSVar("HSStamp","" + Player.getHandSizeStamp()); + if(Target.equals("Self") || Target.equals("All")) { + card.getController().addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp")))); + } + if(Target.equals("Opponent") || Target.equals("All")) { + card.getController().getOpponent().addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp")))); + } } }; @@ -12246,31 +12225,12 @@ public class CardFactory implements NewConstants { private static final long serialVersionUID = -6843545358873L; public void execute() { - if(card.getController() == AllZone.HumanPlayer) { - if(Target.equals("Self")) { - Input_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp"))); - } - else if(Target.equals("Opponent")) { - Computer_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp"))); - } - else if(Target.equals("All")) { - Computer_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp"))); - Input_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp"))); - } - } - else - { - if(Target.equals("Self")) { - Computer_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp"))); - } - else if(Target.equals("Opponent")) { - Input_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp"))); - } - else if(Target.equals("All")) { - Computer_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp"))); - Input_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp"))); - } - } + if(Target.equals("Self") || Target.equals("All")) { + card.getController().removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp"))); + } + if(Target.equals("Opponent") || Target.equals("All")) { + card.getController().getOpponent().removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp"))); + } } }; @@ -12280,16 +12240,16 @@ public class CardFactory implements NewConstants { public void execute() { Log.debug("HandSize", "Control changed: " + card.getController()); if(card.getController().equals(AllZone.HumanPlayer)) { - Input_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp"))); - Computer_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp")))); + AllZone.HumanPlayer.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp"))); + AllZone.ComputerPlayer.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp")))); - Computer_Cleanup.sortHandSizeOperations(); + AllZone.ComputerPlayer.sortHandSizeOperations(); } else if(card.getController().equals(AllZone.ComputerPlayer)) { - Computer_Cleanup.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp"))); - Input_Cleanup.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp")))); + AllZone.ComputerPlayer.removeHandSizeOperation(Integer.parseInt(card.getSVar("HSStamp"))); + AllZone.HumanPlayer.addHandSizeOperation(new HandSizeOp(Mode,Amount,Integer.parseInt(card.getSVar("HSStamp")))); - Input_Cleanup.sortHandSizeOperations(); + AllZone.HumanPlayer.sortHandSizeOperations(); } } }; diff --git a/src/forge/ComputerAI_counterSpells.java b/src/forge/ComputerAI_counterSpells.java deleted file mode 100644 index de9811b9767..00000000000 --- a/src/forge/ComputerAI_counterSpells.java +++ /dev/null @@ -1,118 +0,0 @@ -package forge; - -public class ComputerAI_counterSpells { - - public static void counter_Spell(SpellAbility sa) - { - if (sa.getSourceCard().isCreature()) - counter_CreatureSpell(sa); - - else - counter_NonCreatureSpell(sa); - } - - public static void counter_CreatureSpell(SpellAbility sa) - { - if (!hasPlayableCounterSpells() && !hasPlayableCreatureCounterSpells()) - return; - - CardList counterSpells; - if (hasPlayableCreatureCounterSpells()) - counterSpells = getPlayableCreatureCounterSpells(); - else - counterSpells = getPlayableCounterSpells(); - - boolean countered = false; - for (Card var:counterSpells) - { - if (countered) - break; - else if (CardUtil.getConvertedManaCost(var.getManaCost()) <= CardUtil.getConvertedManaCost(sa) || - (var.getName().equals("Overwhelming Intellect") && CardUtil.getConvertedManaCost(sa) >= 3 )) - { - SpellAbility sp = var.getSpellAbility()[0]; - //ComputerUtil.playNoStack(sp); - ComputerUtil.playStack(sp); - countered = true; - } - } - - } - - public static void counter_NonCreatureSpell(SpellAbility sa) - { - if (!hasPlayableCounterSpells()) - return; - - CardList counterSpells; - counterSpells = getPlayableCounterSpells(); - - boolean countered = false; - for (Card var:counterSpells) - { - if (countered) - break; - else if (CardUtil.getConvertedManaCost(var.getManaCost()) <= CardUtil.getConvertedManaCost(sa)) - { - SpellAbility sp = var.getSpellAbility()[0]; - //ComputerUtil.playNoStack(sp); - ComputerUtil.playStack(sp); - countered = true; - } - } - } - - public static boolean hasPlayableCounterSpells() - { - return getPlayableCounterSpells().size() > 0; - } - - public static boolean hasPlayableCreatureCounterSpells() - { - return getPlayableCreatureCounterSpells().size() > 0; - } - - public static CardList getPlayableCounterSpells() - { - PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, AllZone.ComputerPlayer); - CardList list = new CardList(hand.getCards()); - list = list.filter(new CardListFilter() - { - - - public boolean addCard(Card c) { - if (c.getSpellAbility().length == 0) - return false; - - SpellAbility sa = c.getSpellAbility()[0]; - return c.getName().equals("Counterspell") || c.getName().equals("Cancel") || - c.getName().equals("Remand") || c.getName().equals("Mystic Snake") || - c.getName().equals("Absorb") || c.getName().equals("Undermine") || - c.getName().equals("Punish Ignorance") || c.getName().equals("Dismiss") || - c.getName().equals("Last Word") || c.getName().equals("Dissipate") - && ComputerUtil.canPayCost(sa); - } - }); - - return list; - } - public static CardList getPlayableCreatureCounterSpells() - { - PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, AllZone.ComputerPlayer); - CardList list = new CardList(hand.getCards()); - list = list.filter(new CardListFilter() - { - public boolean addCard(Card c) { - if (c.getSpellAbility().length == 0) - return false; - SpellAbility sa = c.getSpellAbility()[0]; - return c.getName().equals("Exclude") || c.getName().equals("Overwhelming Intellect") || - c.getName().equals("Preemptive Strike") || c.getName().equals("False Summoning") || - c.getName().equals("Essence Scatter") || c.getName().equals("Remove Soul") - && ComputerUtil.canPayCost(sa); - } - }); - - return list; - } -} diff --git a/src/forge/Computer_Cleanup.java b/src/forge/Computer_Cleanup.java index 42de763633b..79136c38594 100644 --- a/src/forge/Computer_Cleanup.java +++ b/src/forge/Computer_Cleanup.java @@ -1,85 +1,10 @@ package forge; - -import java.util.LinkedList; import java.util.Random; - public class Computer_Cleanup extends Input { - private static LinkedList handSizeOperations = new LinkedList(); - private static int MaxHandSize = 7; - - public static void clearHandSizeOperations() { - handSizeOperations.clear(); - } - - public static void sortHandSizeOperations() { - if(handSizeOperations.size() < 2) { - return; - } - - Object arr[] = handSizeOperations.toArray(); - int changes = 1; - - while(changes > 0) { - changes = 0; - for(int i=1;i= 0) - { - ret = ret + handSizeOperations.get(i).Amount; - } - else if(handSizeOperations.get(i).Mode.equals("-") && ret >= 0) - { - ret = ret - handSizeOperations.get(i).Amount; - if(ret < 0) { - ret = 0; - } - } - } - MaxHandSize = ret; - } - public static void addHandSizeOperation(HandSizeOp theNew) - { - handSizeOperations.add(theNew); - } - public static void removeHandSizeOperation(int timestamp) - { - for(int i=0;i handSizeOperations = new LinkedList(); - private static int MaxHandSize = 7; - - public static void clearHandSizeOperations() { - handSizeOperations.clear(); - NextHandSizeStamp = 0; - } - - public static void sortHandSizeOperations() { - if(handSizeOperations.size() < 2) { - return; - } - - Object arr[] = handSizeOperations.toArray(); - int changes = 1; - - while(changes > 0) { - changes = 0; - for(int i=1;i= 0) - { - ret = ret + handSizeOperations.get(i).Amount; - } - else if(handSizeOperations.get(i).Mode.equals("-") && ret >= 0) - { - ret = ret - handSizeOperations.get(i).Amount; - if(ret < 0) { - ret = 0; - } - } - } - MaxHandSize = ret; - } - public static void addHandSizeOperation(HandSizeOp theNew) - { - handSizeOperations.add(theNew); - } - public static void removeHandSizeOperation(int timestamp) - { - for(int i=0;i(); } public void reset(){ @@ -637,6 +639,76 @@ public abstract class Player extends MyObservable{ return list.size() >= 3; } + private ArrayList handSizeOperations; + + public int getMaxHandSize() { + + int ret = 7; + for(int i=0;i= 0) + { + ret = ret + handSizeOperations.get(i).Amount; + } + else if(handSizeOperations.get(i).Mode.equals("-") && ret >= 0) + { + ret = ret - handSizeOperations.get(i).Amount; + if(ret < 0) { + ret = 0; + } + } + } + return ret; + } + + public void sortHandSizeOperations() { + if(handSizeOperations.size() < 2) { + return; + } + + int changes = 1; + + while(changes > 0) { + changes = 0; + for(int i=1;i