diff --git a/Mage.HumanPlayer/build.xml b/Mage.HumanPlayer/build.xml deleted file mode 100644 index 2dd277d75d9..00000000000 --- a/Mage.HumanPlayer/build.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - Builds, tests, and runs the project Mage.HumanPlayer. - - - diff --git a/Mage.HumanPlayer/nbproject/build-impl.xml b/Mage.HumanPlayer/nbproject/build-impl.xml deleted file mode 100644 index 5dc9358def7..00000000000 --- a/Mage.HumanPlayer/nbproject/build-impl.xml +++ /dev/null @@ -1,704 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - - - - - - java -cp "${run.classpath.with.dist.jar}" ${main.class} - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - diff --git a/Mage.HumanPlayer/nbproject/genfiles.properties b/Mage.HumanPlayer/nbproject/genfiles.properties deleted file mode 100644 index c9c11d536e6..00000000000 --- a/Mage.HumanPlayer/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=3d294c13 -build.xml.script.CRC32=3ec94750 -build.xml.stylesheet.CRC32=958a1d3e@1.26.2.45 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=3d294c13 -nbproject/build-impl.xml.script.CRC32=d6c9afd4 -nbproject/build-impl.xml.stylesheet.CRC32=5c621a33@1.26.2.45 diff --git a/Mage.HumanPlayer/nbproject/project.properties b/Mage.HumanPlayer/nbproject/project.properties deleted file mode 100644 index 75515cb61bb..00000000000 --- a/Mage.HumanPlayer/nbproject/project.properties +++ /dev/null @@ -1,66 +0,0 @@ -application.title=Mage.HumanPlayer -application.vendor=BetaSteward_at_googlemail.com -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -# Uncomment to specify the preferred debugger connection transport: -#debug.transport=dt_socket -debug.classpath=\ - ${run.classpath} -debug.test.classpath=\ - ${run.test.classpath} -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/Mage.HumanPlayer.jar -dist.javadoc.dir=${dist.dir}/javadoc -excludes= -includes=** -jar.compress=false -javac.classpath=\ - ${reference.Mage.jar} -# Space-separated list of extra javac options -javac.compilerargs= -javac.deprecation=false -javac.source=1.6 -javac.target=1.6 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir}:\ - ${libs.junit.classpath}:\ - ${libs.junit_4.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding=${source.encoding} -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -meta.inf.dir=${src.dir}/META-INF -platform.active=default_platform -project.license=bsd -project.Mage=../Mage -reference.Mage.jar=${project.Mage}/dist/Mage.jar -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value -# or test-sys-prop.name=value to set system properties for unit tests): -run.jvmargs= -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -source.encoding=UTF-8 -src.dir=src -test.src.dir=test diff --git a/Mage.HumanPlayer/nbproject/project.xml b/Mage.HumanPlayer/nbproject/project.xml deleted file mode 100644 index 5352390fb03..00000000000 --- a/Mage.HumanPlayer/nbproject/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - org.netbeans.modules.java.j2seproject - - - Mage.HumanPlayer - - - - - - - - - - Mage - jar - - jar - clean - jar - - - - diff --git a/Mage.HumanPlayer/src/mage/human/HumanPlayer.java b/Mage.HumanPlayer/src/mage/human/HumanPlayer.java deleted file mode 100644 index 77be226d7c5..00000000000 --- a/Mage.HumanPlayer/src/mage/human/HumanPlayer.java +++ /dev/null @@ -1,394 +0,0 @@ -/* -* 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.human; - -import java.util.List; -import mage.abilities.effects.ReplacementEffect; -import mage.cards.Cards; -import mage.choices.Choice; -import mage.players.*; -import java.util.Map; -import java.util.UUID; -import mage.Constants.Outcome; -import mage.Constants.TargetController; -import mage.Constants.Zone; -import mage.MageObject; -import mage.abilities.ActivatedAbility; -import mage.abilities.costs.mana.ManaCost; -import mage.abilities.costs.mana.VariableManaCost; -import mage.filter.common.FilterCreatureForCombat; -import mage.game.Game; -import mage.game.permanent.Permanent; -import mage.target.Target; -import mage.target.TargetCard; -import mage.target.TargetPermanent; -import mage.target.common.TargetAttackingCreature; -import mage.target.common.TargetCreatureOrPlayer; -import mage.target.common.TargetDefender; - -/** - * - * @author BetaSteward_at_googlemail.com - */ -public class HumanPlayer extends PlayerImpl { - - final PlayerResponse response = new PlayerResponse(); - - private boolean abort = false; - - protected TargetPermanent targetCombat = new TargetPermanent(new FilterCreatureForCombat(), TargetController.YOU); - - public HumanPlayer(String name) { - super(name); - } - - protected void waitForResponse() { - response.clear(); - synchronized(response) { - try { - response.wait(); - } catch (InterruptedException ex) { } - } - } - - protected void waitForBooleanResponse() { - do { - waitForResponse(); - } while (response.getBoolean() == null && !abort); - } - - protected void waitForUUIDResponse() { - do { - waitForResponse(); - } while (response.getUUID() == null && !abort); - } - - protected void waitForStringResponse() { - do { - waitForResponse(); - } while (response.getString() == null && !abort); - } - - protected void waitForIntegerResponse() { - do { - waitForResponse(); - } while (response.getInteger() == null && !abort); - } - - @Override - public boolean chooseMulligan(Game game) { - game.fireAskPlayerEvent(playerId, "Do you want to take a mulligan?"); - waitForBooleanResponse(); - if (!abort) - return response.getBoolean(); - return false; - } - - @Override - public boolean chooseUse(Outcome outcome, String message, Game game) { - game.fireAskPlayerEvent(playerId, message); - waitForBooleanResponse(); - if (!abort) - return response.getBoolean(); - return false; - } - - @Override - public int chooseEffect(List rEffects, Game game) { - //TODO: implement this - return 0; - } - - @Override - public boolean choose(Outcome outcome, Choice choice, Game game) { - game.fireChooseEvent(playerId, choice); - while (!abort) { - waitForStringResponse(); - choice.setChoice(response.getString()); - return true; - } - return false; - } - - @Override - public boolean chooseTarget(Outcome outcome, Target target, Game game) { - game.fireSelectTargetEvent(playerId, target.getMessage(), target.isRequired()); - while (!abort) { - waitForResponse(); - if (response.getUUID() != null) { - if (target.canTarget(response.getUUID(), game)) { - target.addTarget(response.getUUID(), game); - return true; - } - } else if (!target.isRequired()) { - return false; - } - } - return false; - } - - @Override - public void priority(Game game) { - passed = false; - if (!abort) { - if (passedTurn && game.getStack().isEmpty()) { - passed = true; - return; - } - game.firePriorityEvent(playerId); - waitForResponse(); - if (response.getBoolean() != null) { - passed = true; - } else if (response.getInteger() != null) { - passed = true; - passedTurn = true; - } else if (response.getUUID() != null) { - MageObject object = game.getObject(response.getUUID()); - if (object != null) { - Map useableAbilities = null; - switch (object.getZone()) { - case HAND: - useableAbilities = getUseableAbilities(object.getAbilities().getActivatedAbilities(Zone.HAND), game); - break; - case BATTLEFIELD: - useableAbilities = getUseableAbilities(object.getAbilities().getActivatedAbilities(Zone.BATTLEFIELD), game); - break; - case GRAVEYARD: - useableAbilities = getUseableAbilities(object.getAbilities().getActivatedAbilities(Zone.GRAVEYARD), game); - break; - } - if (useableAbilities != null && useableAbilities.size() > 0) { - activateAbility(useableAbilities, game); - } - } - } - } - } - - @Override - public boolean searchCards(Cards cards, TargetCard target, Game game) { - while (!abort && !target.doneChosing()) { - game.fireSelectTargetEvent(playerId, target.getMessage(), cards, target.isRequired()); - waitForResponse(); - if (response.getUUID() != null && cards.containsKey(response.getUUID())) { - target.addTarget(response.getUUID(), game); - } else if (!target.isRequired()) { - break; - } - } - return target.isChosen(); - } - - @Override - public boolean playMana(ManaCost unpaid, Game game) { - game.firePlayManaEvent(playerId, "Pay " + unpaid.getText()); - waitForResponse(); - if (response.getBoolean() != null) { - return false; - } else if (response.getUUID() != null) { - playManaAbilities(game); - } - return true; - } - - @Override - public boolean playXMana(VariableManaCost cost, Game game) { - game.firePlayXManaEvent(playerId, "Pay {X}: {X}=" + cost.getValue()); - waitForResponse(); - if (response.getBoolean() != null) { - if (!response.getBoolean()) - return false; - cost.setPaid(); - } else if (response.getUUID() != null) { - playManaAbilities(game); - } - return true; - } - - protected void playManaAbilities(Game game) { - MageObject object = game.getObject(response.getUUID()); - Map useableAbilities; - switch (object.getZone()) { - case HAND: - useableAbilities = getUseableAbilities(object.getAbilities().getManaAbilities(Zone.HAND), game); - if (useableAbilities.size() > 0) { - activateAbility(useableAbilities, game); - } - break; - case BATTLEFIELD: - useableAbilities = getUseableAbilities(object.getAbilities().getManaAbilities(Zone.BATTLEFIELD), game); - if (useableAbilities.size() > 0) { - activateAbility(useableAbilities, game); - } - break; - case GRAVEYARD: - useableAbilities = getUseableAbilities(object.getAbilities().getManaAbilities(Zone.GRAVEYARD), game); - if (useableAbilities.size() > 0) { - activateAbility(useableAbilities, game); - } - break; - } - } - - @Override - public void selectAttackers(Game game) { - while (!abort) { - targetCombat.getTargets().clear(); - game.fireSelectEvent(playerId, "Select attackers"); - waitForResponse(); - if (response.getBoolean() != null) { - return; - } else if (response.getUUID() != null) { - if (targetCombat.canTarget(playerId, response.getUUID(), game)) { - selectDefender(game.getCombat().getDefenders(), response.getUUID(), game); - } - } - } - } - - protected boolean selectDefender(List defenders, UUID attackerId, Game game) { - TargetDefender target = new TargetDefender(defenders, attackerId); - if (chooseTarget(Outcome.Damage, target, game)) { - declareAttacker(attackerId, response.getUUID(), game); - return true; - } - return false; - } - - @Override - public void selectBlockers(Game game) { - while (!abort) { - targetCombat.getTargets().clear(); - game.fireSelectEvent(playerId, "Select blockers"); - waitForResponse(); - if (response.getBoolean() != null) { - return; - } else if (response.getUUID() != null) { - if (targetCombat.canTarget(playerId, response.getUUID(), game)) { - selectCombatGroup(response.getUUID(), game); - } - } - } - } - - protected void selectCombatGroup(UUID blockerId, Game game) { - TargetAttackingCreature target = new TargetAttackingCreature(); - game.fireSelectTargetEvent(playerId, "Select attacker to block", target.isRequired()); - waitForResponse(); - if (response.getBoolean() != null) { - return; - } else if (response.getUUID() != null) { - declareBlocker(blockerId, response.getUUID(), game); - } - } - - @Override - public void assignDamage(int damage, List targets, UUID sourceId, Game game) { - int remainingDamage = damage; - while (remainingDamage > 0) { - Target target = new TargetCreatureOrPlayer(); - chooseTarget(Outcome.Damage, target, game); - if (targets.size() == 0 || targets.contains(target.getFirstTarget())) { - int damageAmount = getAmount(0, remainingDamage, "Select amount", game); - Permanent permanent = game.getPermanent(target.getFirstTarget()); - if (permanent != null) { - permanent.damage(damageAmount, sourceId, game); - } - else { - Player player = game.getPlayer(target.getFirstTarget()); - if (player != null) { - player.damage(damageAmount, sourceId, game); - } - } - } - } - } - - @Override - public int getAmount(int min, int max, String message, Game game) { - game.fireGetAmountEvent(playerId, message, min, max); - waitForIntegerResponse(); - return response.getInteger(); - } - - protected void activateAbility(Map abilities, Game game) { - if (abilities.size() == 1) { - activateAbility(abilities.values().iterator().next(), game); - } - else { - game.fireGetChoiceEvent(playerId, name, abilities.values()); - waitForResponse(); - if (response.getUUID() != null) { - if (abilities.containsKey(response.getUUID())) - activateAbility(abilities.get(response.getUUID()), game); - } - } - } - - @Override - public void setResponseString(String responseString) { - synchronized(response) { - response.setString(responseString); - response.notify(); - } - } - - @Override - public void setResponseUUID(UUID responseUUID) { - synchronized(response) { - response.setUUID(responseUUID); - response.notify(); - } - } - - @Override - public void setResponseBoolean(Boolean responseBoolean) { - synchronized(response) { - response.setBoolean(responseBoolean); - response.notify(); - } - } - - @Override - public void setResponseInteger(Integer responseInteger) { - synchronized(response) { - response.setInteger(responseInteger); - response.notify(); - } - } - - @Override - public void abort() { - abort = true; - synchronized(response) { - response.notify(); - } - } - -} diff --git a/Mage.HumanPlayer/src/mage/human/PlayerResponse.java b/Mage.HumanPlayer/src/mage/human/PlayerResponse.java deleted file mode 100644 index 016666ae33e..00000000000 --- a/Mage.HumanPlayer/src/mage/human/PlayerResponse.java +++ /dev/null @@ -1,84 +0,0 @@ -/* -* 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.human; - -import java.io.Serializable; -import java.util.UUID; - -/** - * - * @author BetaSteward_at_googlemail.com - */ -public class PlayerResponse implements Serializable { - - private String responseString; - private UUID responseUUID; - private Boolean responseBoolean; - private Integer responseInteger; - - public void clear() { - responseString = null; - responseUUID = null; - responseBoolean = null; - responseInteger = null; - } - - public String getString() { - return responseString; - } - - public void setString(String responseString) { - this.responseString = responseString; - } - - public UUID getUUID() { - return responseUUID; - } - - public void setUUID(UUID responseUUID) { - this.responseUUID = responseUUID; - } - - public Boolean getBoolean() { - return responseBoolean; - } - - public void setBoolean(Boolean responseBoolean) { - this.responseBoolean = responseBoolean; - } - - public Integer getInteger() { - return responseInteger; - } - - public void setInteger(Integer responseInteger) { - this.responseInteger = responseInteger; - } - -}