diff --git a/src/main/java/forge/IPlayerZone.java b/src/main/java/forge/IPlayerZone.java index 5b3a6578cfd..006de0d8f84 100644 --- a/src/main/java/forge/IPlayerZone.java +++ b/src/main/java/forge/IPlayerZone.java @@ -3,130 +3,208 @@ package forge; import java.util.List; /** - *

IPlayerZone interface.

- * + *

+ * IPlayerZone interface. + *

+ * * @author Forge * @version $Id$ */ interface IPlayerZone { /** - *

setUpdate.

- * - * @param b a boolean. + *

+ * setUpdate. + *

+ * + * @param b + * a boolean. */ void setUpdate(boolean b); /** - *

getUpdate.

- * + *

+ * getUpdate. + *

+ * * @return a boolean. */ boolean getUpdate(); /** - *

size.

- * + *

+ * size. + *

+ * * @return a int. */ int size(); /** - *

add.

- * - * @param o a {@link java.lang.Object} object. + *

+ * add. + *

+ * + * @param o + * a {@link java.lang.Object} object. */ void add(Object o); /** - *

add.

- * - * @param c a {@link forge.Card} object. - * @param index a int. + *

+ * add. + *

+ * + * @param c + * a {@link forge.Card} object. + * @param index + * a int. */ void add(Card c, int index); /** - *

get.

- * - * @param index a int. + *

+ * get. + *

+ * + * @param index + * a int. * @return a {@link forge.Card} object. */ Card get(int index); /** - *

remove.

- * - * @param o a {@link java.lang.Object} object. + *

+ * remove. + *

+ * + * @param o + * a {@link java.lang.Object} object. */ void remove(Object o); /** - *

setCards.

- * - * @param c an array of {@link forge.Card} objects. + *

+ * setCards. + *

+ * + * @param c + * an array of {@link forge.Card} objects. */ void setCards(Card[] c); /** - *

getCards.

- * + *

+ * getCards. + *

+ * + * @param filter + * the filter * @return an array of {@link forge.Card} objects. */ Card[] getCards(boolean filter); + + /** + * Gets the cards. + * + * @return the cards + */ Card[] getCards(); + + /** + * Gets the cards. + * + * @param n + * the n + * @return the cards + */ Card[] getCards(int n); - + + /** + * Contains. + * + * @param c + * the c + * @return true, if successful + */ boolean contains(Card c); - - /** isEmpty returns true if given zone contains no cards */ + + /** + * isEmpty returns true if given zone contains no cards. + * + * @return true, if is empty + */ boolean isEmpty(); - //removes all cards + // removes all cards /** - *

reset.

+ *

+ * reset. + *

*/ void reset(); /** - *

is.

- * - * @param zone a {@link java.lang.String} object. + *

+ * is. + *

+ * + * @param zone + * a {@link java.lang.String} object. * @return a boolean. */ boolean is(Constant.Zone zone); + + /** + * Checks if is. + * + * @param zones + * the zones + * @return true, if successful + */ boolean is(List zones); /** - *

is.

- * - * @param zone a {@link java.lang.String} object. - * @param player a {@link forge.Player} object. + *

+ * is. + *

+ * + * @param zone + * a {@link java.lang.String} object. + * @param player + * a {@link forge.Player} object. * @return a boolean. */ boolean is(Constant.Zone zone, Player player); /** - *

getPlayer.

- * + *

+ * getPlayer. + *

+ * * @return a {@link forge.Player} object. */ - Player getPlayer(); //the Player that owns this zone + Player getPlayer(); // the Player that owns this zone /** - *

getZoneName.

- * + *

+ * getZoneName. + *

+ * * @return a {@link java.lang.String} object. */ - Constant.Zone getZoneType(); //returns the Zone's name like Graveyard + Constant.Zone getZoneType(); // returns the Zone's name like Graveyard /** - *

toString.

- * + *

+ * toString. + *

+ * * @return a {@link java.lang.String} object. */ String toString(); - - + + /** + * Reset cards added this turn. + */ void resetCardsAddedThisTurn(); } - diff --git a/src/main/java/forge/MagicStack.java b/src/main/java/forge/MagicStack.java index a921e3a4bee..dc249d8f903 100644 --- a/src/main/java/forge/MagicStack.java +++ b/src/main/java/forge/MagicStack.java @@ -26,8 +26,10 @@ import forge.gui.input.Input; import forge.gui.input.Input_PayManaCost_Ability; /** - *

MagicStack class.

- * + *

+ * MagicStack class. + *

+ * * @author Forge * @version $Id$ */ @@ -40,13 +42,15 @@ public class MagicStack extends MyObservable { private boolean frozen = false; private boolean bResolving = false; private int splitSecondOnStack = 0; - + private CardList thisTurnCast = new CardList(); private CardList lastTurnCast = new CardList(); /** - *

isFrozen.

- * + *

+ * isFrozen. + *

+ * * @return a boolean. */ public final boolean isFrozen() { @@ -54,16 +58,21 @@ public class MagicStack extends MyObservable { } /** - *

Setter for the field frozen.

- * - * @param frozen0 a boolean. + *

+ * Setter for the field frozen. + *

+ * + * @param frozen0 + * a boolean. */ public final void setFrozen(final boolean frozen0) { this.frozen = frozen0; } /** - *

reset.

+ *

+ * reset. + *

*/ public final void reset() { getStack().clear(); @@ -74,8 +83,10 @@ public class MagicStack extends MyObservable { } /** - *

isSplitSecondOnStack.

- * + *

+ * isSplitSecondOnStack. + *

+ * * @return a boolean. */ public final boolean isSplitSecondOnStack() { @@ -83,9 +94,12 @@ public class MagicStack extends MyObservable { } /** - *

incrementSplitSecond.

- * - * @param sp a {@link forge.card.spellability.SpellAbility} object. + *

+ * incrementSplitSecond. + *

+ * + * @param sp + * a {@link forge.card.spellability.SpellAbility} object. */ public final void incrementSplitSecond(final SpellAbility sp) { if (sp.getSourceCard().hasKeyword("Split second")) { @@ -94,9 +108,12 @@ public class MagicStack extends MyObservable { } /** - *

decrementSplitSecond.

- * - * @param sp a {@link forge.card.spellability.SpellAbility} object. + *

+ * decrementSplitSecond. + *

+ * + * @param sp + * a {@link forge.card.spellability.SpellAbility} object. */ public final void decrementSplitSecond(final SpellAbility sp) { if (sp.getSourceCard().hasKeyword("Split second")) { @@ -109,23 +126,27 @@ public class MagicStack extends MyObservable { } /** - *

freezeStack.

+ *

+ * freezeStack. + *

*/ public final void freezeStack() { frozen = true; } /** - *

addAndUnfreeze.

- * - * @param ability a {@link forge.card.spellability.SpellAbility} object. + *

+ * addAndUnfreeze. + *

+ * + * @param ability + * a {@link forge.card.spellability.SpellAbility} object. */ public final void addAndUnfreeze(final SpellAbility ability) { ability.getRestrictions().abilityActivated(); if (ability.getRestrictions().getActivationNumberSacrifice() != -1 - && ability.getRestrictions().getNumberTurnActivations() - >= ability.getRestrictions().getActivationNumberSacrifice()) - { + && ability.getRestrictions().getNumberTurnActivations() >= ability.getRestrictions() + .getActivationNumberSacrifice()) { ability.getSourceCard().addExtrinsicKeyword("At the beginning of the end step, sacrifice CARDNAME."); } // triggered abilities should go on the frozen stack @@ -135,7 +156,8 @@ public class MagicStack extends MyObservable { this.add(ability); - // if the ability is a spell, but not a copied spell and its not already on the stack zone, move there + // if the ability is a spell, but not a copied spell and its not already + // on the stack zone, move there if (ability.isSpell()) { Card source = ability.getSourceCard(); if (!source.isCopiedSpell() && !AllZone.getZoneOf(source).is(Constant.Zone.Stack)) { @@ -149,7 +171,9 @@ public class MagicStack extends MyObservable { } /** - *

unfreezeStack.

+ *

+ * unfreezeStack. + *

*/ public final void unfreezeStack() { frozen = false; @@ -164,18 +188,24 @@ public class MagicStack extends MyObservable { } /** - *

clearFrozen.

+ *

+ * clearFrozen. + *

*/ public final void clearFrozen() { - // TODO: frozen triggered abilities and undoable costs have nasty consequences + // TODO: frozen triggered abilities and undoable costs have nasty + // consequences frozen = false; getFrozenStack().clear(); } /** - *

setResolving.

- * - * @param b a boolean. + *

+ * setResolving. + *

+ * + * @param b + * a boolean. */ public final void setResolving(final boolean b) { bResolving = b; @@ -185,8 +215,10 @@ public class MagicStack extends MyObservable { } /** - *

getResolving.

- * + *

+ * getResolving. + *

+ * * @return a boolean. */ public final boolean getResolving() { @@ -194,33 +226,41 @@ public class MagicStack extends MyObservable { } /** - *

add.

- * - * @param sp a {@link forge.card.spellability.SpellAbility} object. - * @param useX a boolean. + *

+ * add. + *

+ * + * @param sp + * a {@link forge.card.spellability.SpellAbility} object. + * @param useX + * a boolean. */ public final void add(final SpellAbility sp, final boolean useX) { if (!useX) { this.add(sp); - } - else { + } else { // TODO: make working triggered abilities! if (sp instanceof Ability_Mana || sp instanceof Ability_Triggered) { sp.resolve(); - } - else { + } else { push(sp); - /*if (sp.getTargetCard() != null) - CardFactoryUtil.checkTargetingEffects(sp, sp.getTargetCard());*/ + /* + * if (sp.getTargetCard() != null) + * CardFactoryUtil.checkTargetingEffects(sp, + * sp.getTargetCard()); + */ } } } /** - *

getMultiKickerSpellCostChange.

- * - * @param sa a {@link forge.card.spellability.SpellAbility} object. + *

+ * getMultiKickerSpellCostChange. + *

+ * + * @param sa + * a {@link forge.card.spellability.SpellAbility} object. * @return a {@link forge.card.mana.ManaCost} object. */ public final ManaCost getMultiKickerSpellCostChange(final SpellAbility sa) { @@ -239,11 +279,9 @@ public class MagicStack extends MyObservable { if (mana.toString().length() == 1) { numberManaCost = mana.toString().substring(0, 1); - } - else if (mana.toString().length() == 0) { + } else if (mana.toString().length() == 0) { numberManaCost = "0"; // Should Never Occur - } - else { + } else { numberManaCost = mana.toString().substring(0, 2); } @@ -272,42 +310,46 @@ public class MagicStack extends MyObservable { for (int colorCutIx = 0; colorCutIx < colorCut.length(); colorCutIx++) { if ("WUGRB".contains(colorCut.substring(colorCutIx, colorCutIx + 1)) - && !mana.equals(mana.replaceFirst((colorCut.substring(colorCutIx, colorCutIx + 1)), ""))) - { - mana = mana.replaceFirst(colorCut.substring(colorCutIx, colorCutIx + 1), ""); + && !mana.equals(mana.replaceFirst((colorCut.substring(colorCutIx, colorCutIx + 1)), ""))) { + mana = mana.replaceFirst(colorCut.substring(colorCutIx, colorCutIx + 1), ""); - AllZone.getGameAction().CostCutting_GetMultiMickerManaCostPaid_Colored = - AllZone.getGameAction().CostCutting_GetMultiMickerManaCostPaid_Colored - .replaceFirst(colorCut.substring(colorCutIx, colorCutIx + 1), ""); + AllZone.getGameAction().CostCutting_GetMultiMickerManaCostPaid_Colored = AllZone.getGameAction().CostCutting_GetMultiMickerManaCostPaid_Colored + .replaceFirst(colorCut.substring(colorCutIx, colorCutIx + 1), ""); - mana = mana.trim(); - if (mana.equals("")) { - mana = "0"; - } - manaCost = new ManaCost(mana); + mana = mana.trim(); + if (mana.equals("")) { + mana = "0"; + } + manaCost = new ManaCost(mana); } } return manaCost; } - //TODO: this may be able to use a straight copy of MultiKicker cost change + // TODO: this may be able to use a straight copy of MultiKicker cost change /** - *

getReplicateSpellCostChange.

- * - * @param sa a {@link forge.card.spellability.SpellAbility} object. + *

+ * getReplicateSpellCostChange. + *

+ * + * @param sa + * a {@link forge.card.spellability.SpellAbility} object. * @return a {@link forge.card.mana.ManaCost} object. */ public final ManaCost getReplicateSpellCostChange(final SpellAbility sa) { ManaCost manaCost = new ManaCost(sa.getManaCost()); - //String Mana = manaCost.toString(); + // String Mana = manaCost.toString(); return manaCost; } /** - *

add.

+ *

+ * add. + *

* - * @param sp a {@link forge.card.spellability.SpellAbility} object. + * @param sp + * a {@link forge.card.spellability.SpellAbility} object. */ public final void add(final SpellAbility sp) { ArrayList chosenTargets = sp.getAllTargetChoices(); @@ -317,7 +359,7 @@ public class MagicStack extends MyObservable { sp.resetOnceResolved(); return; } - + if (frozen) { SpellAbility_StackInstance si = new SpellAbility_StackInstance(sp); getFrozenStack().push(si); @@ -331,7 +373,10 @@ public class MagicStack extends MyObservable { System.out.println(sp.getSourceCard().getName() + " - activatingPlayer not set before adding to stack."); } - if (AllZone.getPhase().is(Constant.Phase.Cleanup)) { // If something triggers during Cleanup, need to repeat + if (AllZone.getPhase().is(Constant.Phase.Cleanup)) { // If something + // triggers during + // Cleanup, need to + // repeat AllZone.getPhase().repeatPhase(); } @@ -344,8 +389,7 @@ public class MagicStack extends MyObservable { if (sp instanceof Ability_Triggered || sp instanceof Ability_Static) { // TODO: make working triggered ability sp.resolve(); - } - else { + } else { if (sp.isKickerAbility()) { sp.getSourceCard().setKicked(true); SpellAbility[] sa = sp.getSourceCard().getSpellAbility(); @@ -389,18 +433,19 @@ public class MagicStack extends MyObservable { public void execute() { ability.resolve(); Card crd = sa.getSourceCard(); - AllZone.getInputControl().setInput(new Input_PayManaCost_Ability("Pay X cost for " - + crd.getName() - + " (X=" + crd.getXManaCostPaid() + ")\r\n", - ability.getManaCost(), this, unpaidCommand, true)); + AllZone.getInputControl().setInput( + new Input_PayManaCost_Ability("Pay X cost for " + crd.getName() + " (X=" + + crd.getXManaCostPaid() + ")\r\n", ability.getManaCost(), this, unpaidCommand, + true)); } }; Card crd = sa.getSourceCard(); if (sp.getSourceCard().getController().isHuman()) { - AllZone.getInputControl().setInput(new Input_PayManaCost_Ability("Pay X cost for " - + sp.getSourceCard().getName() + " (X=" + crd.getXManaCostPaid() + ")\r\n", - ability.getManaCost(), paidCommand, unpaidCommand, true)); + AllZone.getInputControl().setInput( + new Input_PayManaCost_Ability("Pay X cost for " + sp.getSourceCard().getName() + " (X=" + + crd.getXManaCostPaid() + ")\r\n", ability.getManaCost(), paidCommand, + unpaidCommand, true)); } else { // computer int neededDamage = CardFactoryUtil.getNeededXDamage(sa); @@ -411,7 +456,8 @@ public class MagicStack extends MyObservable { push(sa); } } else if (sp.isMultiKicker()) { - // TODO: convert multikicker support in abCost so this doesn't happen here + // TODO: convert multikicker support in abCost so this doesn't + // happen here // both X and multi is not supported yet final SpellAbility sa = sp; @@ -440,24 +486,27 @@ public class MagicStack extends MyObservable { } else { if (AllZone.getGameAction().CostCutting_GetMultiMickerManaCostPaid == 0 && AllZone.getGameAction().CostCutting_GetMultiMickerManaCostPaid_Colored - .equals("")) - { + .equals("")) { - AllZone.getInputControl().setInput(new Input_PayManaCost_Ability( - "Multikicker for " + sa.getSourceCard() + "\r\n" + AllZone.getInputControl().setInput( + new Input_PayManaCost_Ability("Multikicker for " + sa.getSourceCard() + "\r\n" + "Times Kicked: " + sa.getSourceCard().getMultiKickerMagnitude() - + "\r\n", - manaCost.toString(), this, unpaidCommand)); + + "\r\n", manaCost.toString(), this, unpaidCommand)); } else { - AllZone.getInputControl().setInput(new Input_PayManaCost_Ability("Multikicker for " - + sa.getSourceCard() + "\r\n" + "Mana in Reserve: " - + ((AllZone.getGameAction().CostCutting_GetMultiMickerManaCostPaid != 0) - ? AllZone.getGameAction().CostCutting_GetMultiMickerManaCostPaid - : "") - + AllZone.getGameAction().CostCutting_GetMultiMickerManaCostPaid_Colored - + "\r\n" - + "Times Kicked: " + sa.getSourceCard().getMultiKickerMagnitude() + "\r\n", - manaCost.toString(), this, unpaidCommand)); + AllZone.getInputControl() + .setInput( + new Input_PayManaCost_Ability( + "Multikicker for " + + sa.getSourceCard() + + "\r\n" + + "Mana in Reserve: " + + ((AllZone.getGameAction().CostCutting_GetMultiMickerManaCostPaid != 0) ? AllZone + .getGameAction().CostCutting_GetMultiMickerManaCostPaid + : "") + + AllZone.getGameAction().CostCutting_GetMultiMickerManaCostPaid_Colored + + "\r\n" + "Times Kicked: " + + sa.getSourceCard().getMultiKickerMagnitude() + "\r\n", + manaCost.toString(), this, unpaidCommand)); } } } @@ -470,21 +519,26 @@ public class MagicStack extends MyObservable { paidCommand.execute(); } else { if (AllZone.getGameAction().CostCutting_GetMultiMickerManaCostPaid == 0 - && AllZone.getGameAction().CostCutting_GetMultiMickerManaCostPaid_Colored.equals("")) - { - AllZone.getInputControl().setInput(new Input_PayManaCost_Ability("Multikicker for " - + sa.getSourceCard() + "\r\n" + "Times Kicked: " - + sa.getSourceCard().getMultiKickerMagnitude() + "\r\n", - manaCost.toString(), paidCommand, unpaidCommand)); + && AllZone.getGameAction().CostCutting_GetMultiMickerManaCostPaid_Colored.equals("")) { + AllZone.getInputControl().setInput( + new Input_PayManaCost_Ability("Multikicker for " + sa.getSourceCard() + "\r\n" + + "Times Kicked: " + sa.getSourceCard().getMultiKickerMagnitude() + "\r\n", + manaCost.toString(), paidCommand, unpaidCommand)); } else { - AllZone.getInputControl().setInput(new Input_PayManaCost_Ability("Multikicker for " - + sa.getSourceCard() + "\r\n" + "Mana in Reserve: " - + ((AllZone.getGameAction().CostCutting_GetMultiMickerManaCostPaid != 0) - ? AllZone.getGameAction().CostCutting_GetMultiMickerManaCostPaid - : "") - + AllZone.getGameAction().CostCutting_GetMultiMickerManaCostPaid_Colored - + "\r\n" + "Times Kicked: " + sa.getSourceCard().getMultiKickerMagnitude() + "\r\n", - manaCost.toString(), paidCommand, unpaidCommand)); + AllZone.getInputControl() + .setInput( + new Input_PayManaCost_Ability( + "Multikicker for " + + sa.getSourceCard() + + "\r\n" + + "Mana in Reserve: " + + ((AllZone.getGameAction().CostCutting_GetMultiMickerManaCostPaid != 0) ? AllZone + .getGameAction().CostCutting_GetMultiMickerManaCostPaid + : "") + + AllZone.getGameAction().CostCutting_GetMultiMickerManaCostPaid_Colored + + "\r\n" + "Times Kicked: " + + sa.getSourceCard().getMultiKickerMagnitude() + "\r\n", + manaCost.toString(), paidCommand, unpaidCommand)); } } } else { @@ -497,7 +551,8 @@ public class MagicStack extends MyObservable { push(sa); } } else if (sp.isReplicate()) { - // TODO: convert multikicker/replicate support in abCost so this doesn't happen here + // TODO: convert multikicker/replicate support in abCost so this + // doesn't happen here // X and multi and replicate are not supported yet final SpellAbility sa = sp; @@ -528,26 +583,24 @@ public class MagicStack extends MyObservable { this.execute(); } else { - AllZone.getInputControl().setInput(new Input_PayManaCost_Ability("Replicate for " - + sa.getSourceCard() + "\r\n" - + "Times Replicated: " + sa.getSourceCard().getReplicateMagnitude() + "\r\n", - manaCost.toString(), this, unpaidCommand)); + AllZone.getInputControl().setInput( + new Input_PayManaCost_Ability("Replicate for " + sa.getSourceCard() + "\r\n" + + "Times Replicated: " + sa.getSourceCard().getReplicateMagnitude() + + "\r\n", manaCost.toString(), this, unpaidCommand)); } } }; - if (sp.getSourceCard().getController().equals( - AllZone.getHumanPlayer())) - { + if (sp.getSourceCard().getController().equals(AllZone.getHumanPlayer())) { ManaCost manaCost = getMultiKickerSpellCostChange(ability); if (manaCost.isPaid()) { paidCommand.execute(); } else { - AllZone.getInputControl().setInput(new Input_PayManaCost_Ability("Replicate for " - + sa.getSourceCard() + "\r\n" - + "Times Replicated: " + sa.getSourceCard().getReplicateMagnitude() + "\r\n", - manaCost.toString(), paidCommand, unpaidCommand)); + AllZone.getInputControl().setInput( + new Input_PayManaCost_Ability("Replicate for " + sa.getSourceCard() + "\r\n" + + "Times Replicated: " + sa.getSourceCard().getReplicateMagnitude() + "\r\n", + manaCost.toString(), paidCommand, unpaidCommand)); } } else { // computer @@ -561,9 +614,11 @@ public class MagicStack extends MyObservable { } - if (!sp.getSourceCard().isCopiedSpell()) //Copied spells aren't cast per se so triggers shouldn't run for them. + if (!sp.getSourceCard().isCopiedSpell()) // Copied spells aren't cast + // per se so triggers shouldn't + // run for them. { - //Run SpellAbilityCast triggers + // Run SpellAbilityCast triggers HashMap runParams = new HashMap(); runParams.put("Cost", sp.getPayCosts()); runParams.put("Player", sp.getSourceCard().getController()); @@ -571,24 +626,24 @@ public class MagicStack extends MyObservable { runParams.put("CastSA", sp); AllZone.getTriggerHandler().runTrigger("SpellAbilityCast", runParams); - //Run SpellCast triggers + // Run SpellCast triggers if (sp.isSpell()) { AllZone.getTriggerHandler().runTrigger("SpellCast", runParams); } - //Run AbilityCast triggers + // Run AbilityCast triggers if (sp.isAbility() && !sp.isTrigger()) { AllZone.getTriggerHandler().runTrigger("AbilityCast", runParams); } - //Run Cycled triggers + // Run Cycled triggers if (sp.isCycling()) { runParams.clear(); runParams.put("Card", sp.getSourceCard()); AllZone.getTriggerHandler().runTrigger("Cycled", runParams); } - //Run BecomesTarget triggers + // Run BecomesTarget triggers runParams.clear(); runParams.put("SourceSA", sp); if (chosenTargets.size() > 0) { @@ -609,15 +664,13 @@ public class MagicStack extends MyObservable { runParams.put("Target", sp.getTargetCard()); AllZone.getTriggerHandler().runTrigger("BecomesTarget", runParams); - } - else if (sp.getTargetList() != null && sp.getTargetList().size() > 0) { + } else if (sp.getTargetList() != null && sp.getTargetList().size() > 0) { for (Card ctgt : sp.getTargetList()) { runParams.put("Target", ctgt); AllZone.getTriggerHandler().runTrigger("BecomesTarget", runParams); } - } - else if (sp.getTargetPlayer() != null) { + } else if (sp.getTargetPlayer() != null) { runParams.put("Target", sp.getTargetPlayer()); AllZone.getTriggerHandler().runTrigger("BecomesTarget", runParams); @@ -646,9 +699,7 @@ public class MagicStack extends MyObservable { @Override public void selectCard(final Card c, final PlayerZone zone) { - if (zone.is(Constant.Zone.Battlefield) && c.getController().isHuman() - && c.isLand()) - { + if (zone.is(Constant.Zone.Battlefield) && c.getController().isHuman() && c.isLand()) { AllZone.getGameAction().sacrifice(c); stop(); } @@ -658,7 +709,7 @@ public class MagicStack extends MyObservable { if (prev.isSpell() && prev.getSourceCard().getName().equals("Mana Vortex")) { if (sp.getSourceCard().getController().isHuman()) { AllZone.getInputControl().setInput(in); - } else { //Computer + } else { // Computer CardList lands = AllZoneUtil.getPlayerLandsInPlay(AllZone.getComputerPlayer()); if (!lands.isEmpty()) { AllZone.getComputerPlayer().sacrificePermanent("prompt", lands); @@ -669,8 +720,8 @@ public class MagicStack extends MyObservable { } } - } //resolve() - }; //SpellAbility + } // resolve() + }; // SpellAbility counter.setStackDescription(sp.getSourceCard().getName() + " - counter Mana Vortex unless you sacrifice a land."); @@ -679,9 +730,10 @@ public class MagicStack extends MyObservable { } /* - * Whenever a player casts a spell, counter it if a card with the same name - * is in a graveyard or a nontoken permanent with the same name is on the battlefield. - */ + * Whenever a player casts a spell, counter it if a card with the same + * name is in a graveyard or a nontoken permanent with the same name is + * on the battlefield. + */ if (sp.isSpell() && AllZoneUtil.isCardInPlay("Bazaar of Wonders")) { boolean found = false; CardList all = AllZoneUtil.getCardsIn(Zone.Battlefield); @@ -696,7 +748,10 @@ public class MagicStack extends MyObservable { } if (found) { - CardList bazaars = AllZoneUtil.getCardsIn(Zone.Battlefield, "Bazaar of Wonders"); //should only be 1... + CardList bazaars = AllZoneUtil.getCardsIn(Zone.Battlefield, "Bazaar of Wonders"); // should + // only + // be + // 1... for (final Card bazaar : bazaars) { final SpellAbility counter = new Ability(bazaar, "0") { @Override @@ -704,16 +759,18 @@ public class MagicStack extends MyObservable { if (AllZone.getStack().size() > 0) { AllZone.getStack().pop(); } - } //resolve() - }; //SpellAbility + } // resolve() + }; // SpellAbility counter.setStackDescription(bazaar.getName() + " - counter " + sp.getSourceCard().getName() + "."); add(counter); } } } - /*if (sp.getTargetCard() != null) - CardFactoryUtil.checkTargetingEffects(sp, sp.getTargetCard());*/ + /* + * if (sp.getTargetCard() != null) + * CardFactoryUtil.checkTargetingEffects(sp, sp.getTargetCard()); + */ if (getSimultaneousStackEntryList().size() > 0) { AllZone.getPhase().passPriority(); @@ -721,8 +778,10 @@ public class MagicStack extends MyObservable { } /** - *

size.

- * + *

+ * size. + *

+ * * @return a int. */ public final int size() { @@ -731,9 +790,12 @@ public class MagicStack extends MyObservable { // Push should only be used by add. /** - *

push.

- * - * @param sp a {@link forge.card.spellability.SpellAbility} object. + *

+ * push. + *

+ * + * @param sp + * a {@link forge.card.spellability.SpellAbility} object. */ private void push(final SpellAbility sp) { if (null == sp.getActivatingPlayer()) { @@ -756,7 +818,9 @@ public class MagicStack extends MyObservable { } /** - *

resolveStack.

+ *

+ * resolveStack. + *

*/ public final void resolveStack() { // Resolving the Stack @@ -764,15 +828,17 @@ public class MagicStack extends MyObservable { // TODO: change to use forge.view.FView? GuiDisplayUtil.updateGUI(); - this.freezeStack(); // freeze the stack while we're in the middle of resolving + this.freezeStack(); // freeze the stack while we're in the middle of + // resolving setResolving(true); SpellAbility sa = AllZone.getStack().pop(); - AllZone.getPhase().resetPriority(); // ActivePlayer gains priority first after Resolve + AllZone.getPhase().resetPriority(); // ActivePlayer gains priority first + // after Resolve final Card source = sa.getSourceCard(); - if (hasFizzled(sa, source)) { //Fizzle + if (hasFizzled(sa, source)) { // Fizzle // TODO: Spell fizzles, what's the best way to alert player? Log.debug(source.getName() + " ability fizzles."); finishResolving(sa, true); @@ -783,87 +849,82 @@ public class MagicStack extends MyObservable { sa.resolve(); finishResolving(sa, false); } - - if(source.hasStartOfKeyword("Haunt") && !source.isCreature() && AllZone.getZoneOf(source).is(Constant.Zone.Graveyard)) { + + if (source.hasStartOfKeyword("Haunt") && !source.isCreature() + && AllZone.getZoneOf(source).is(Constant.Zone.Graveyard)) { CardList creats = AllZoneUtil.getCreaturesInPlay(); - for(int i=0;iremoveCardFromStack.

- * - * @param sa a {@link forge.card.spellability.SpellAbility} object. - * @param fizzle a boolean. + *

+ * removeCardFromStack. + *

+ * + * @param sa + * a {@link forge.card.spellability.SpellAbility} object. + * @param fizzle + * a boolean. * @since 1.0.15 */ public final void removeCardFromStack(final SpellAbility sa, final boolean fizzle) { Card source = sa.getSourceCard(); - //do nothing + // do nothing if (sa.getSourceCard().isCopiedSpell() || sa.isAbility()) { } // Handle cards that need to be moved differently @@ -874,23 +935,28 @@ public class MagicStack extends MyObservable { sa.setFlashBackAbility(false); } - // If Spell and still on the Stack then let it goto the graveyard or replace its own movement + // If Spell and still on the Stack then let it goto the graveyard or + // replace its own movement else if (!source.isCopiedSpell() && (source.isInstant() || source.isSorcery() || fizzle) - && AllZone.getZoneOf(source).is(Constant.Zone.Stack)) { + && AllZone.getZoneOf(source).is(Constant.Zone.Stack)) { AllZone.getGameAction().moveToGraveyard(source); } } /** - *

finishResolving.

- * - * @param sa a {@link forge.card.spellability.SpellAbility} object. - * @param fizzle a boolean. + *

+ * finishResolving. + *

+ * + * @param sa + * a {@link forge.card.spellability.SpellAbility} object. + * @param fizzle + * a boolean. * @since 1.0.15 */ public final void finishResolving(final SpellAbility sa, final boolean fizzle) { - //remove card from the stack + // remove card from the stack removeCardFromStack(sa, fizzle); // After SA resolves we have to do a handful of things @@ -909,9 +975,9 @@ public class MagicStack extends MyObservable { // TODO: change to use forge.view.FView? GuiDisplayUtil.updateGUI(); - //TODO: this is a huge hack. Why is this necessary? - //hostCard in AF is not the same object that's on the battlefield - //verified by System.identityHashCode(card); + // TODO: this is a huge hack. Why is this necessary? + // hostCard in AF is not the same object that's on the battlefield + // verified by System.identityHashCode(card); Card tmp = sa.getSourceCard(); if (tmp.getClones().size() > 0) { for (Card c : AllZoneUtil.getCardsIn(Zone.Battlefield)) { @@ -924,10 +990,14 @@ public class MagicStack extends MyObservable { } /** - *

hasFizzled.

- * - * @param sa a {@link forge.card.spellability.SpellAbility} object. - * @param source a {@link forge.Card} object. + *

+ * hasFizzled. + *

+ * + * @param sa + * a {@link forge.card.spellability.SpellAbility} object. + * @param source + * a {@link forge.Card} object. * @return a boolean. */ public final boolean hasFizzled(final SpellAbility sa, final Card source) { @@ -941,18 +1011,19 @@ public class MagicStack extends MyObservable { while (true) { Target tgt = fizzSA.getTarget(); if (tgt != null && tgt.getMinTargets(source, fizzSA) == 0 && tgt.getNumTargeted() == 0) { - // Don't assume fizzled for minTargets == 0 and nothing is targeted - } - else if (firstTarget && (tgt != null || fizzSA.getTargetCard() != null - || fizzSA.getTargetPlayer() != null)) - { - // If there is at least 1 target, fizzle switches because ALL targets need to be invalid + // Don't assume fizzled for minTargets == 0 and nothing is + // targeted + } else if (firstTarget + && (tgt != null || fizzSA.getTargetCard() != null || fizzSA.getTargetPlayer() != null)) { + // If there is at least 1 target, fizzle switches because ALL + // targets need to be invalid fizzle = true; firstTarget = false; } if (tgt != null) { - // With multi-targets, as long as one target is still legal, we'll try to go through as much as possible + // With multi-targets, as long as one target is still legal, + // we'll try to go through as much as possible ArrayList tgts = tgt.getTargets(); for (Object o : tgts) { if (o instanceof Player) { @@ -969,7 +1040,8 @@ public class MagicStack extends MyObservable { } } } else if (fizzSA.getTargetCard() != null) { - // Fizzling will only work for Abilities that use the Target class, + // Fizzling will only work for Abilities that use the Target + // class, // since the info isn't available otherwise fizzle &= !CardFactoryUtil.isTargetStillValid(fizzSA, fizzSA.getTargetCard()); } else if (fizzSA.getTargetPlayer() != null) { @@ -978,8 +1050,7 @@ public class MagicStack extends MyObservable { if (fizzSA.getSubAbility() != null) { fizzSA = fizzSA.getSubAbility(); - } - else { + } else { break; } } @@ -988,8 +1059,10 @@ public class MagicStack extends MyObservable { } /** - *

pop.

- * + *

+ * pop. + *

+ * * @return a {@link forge.card.spellability.SpellAbility} object. */ public final SpellAbility pop() { @@ -1002,19 +1075,26 @@ public class MagicStack extends MyObservable { // CAREFUL! Peeking while an SAs Targets are being choosen may cause issues // index = 0 is the top, index = 1 is the next to top, etc... /** - *

peekInstance.

- * - * @param index a int. - * @return a {@link forge.card.spellability.SpellAbility_StackInstance} object. + *

+ * peekInstance. + *

+ * + * @param index + * a int. + * @return a {@link forge.card.spellability.SpellAbility_StackInstance} + * object. */ public final SpellAbility_StackInstance peekInstance(final int index) { return getStack().get(index); } /** - *

peekAbility.

- * - * @param index a int. + *

+ * peekAbility. + *

+ * + * @param index + * a int. * @return a {@link forge.card.spellability.SpellAbility} object. */ public final SpellAbility peekAbility(final int index) { @@ -1022,17 +1102,22 @@ public class MagicStack extends MyObservable { } /** - *

peekInstance.

- * - * @return a {@link forge.card.spellability.SpellAbility_StackInstance} object. + *

+ * peekInstance. + *

+ * + * @return a {@link forge.card.spellability.SpellAbility_StackInstance} + * object. */ public final SpellAbility_StackInstance peekInstance() { return getStack().peek(); } /** - *

peekAbility.

- * + *

+ * peekAbility. + *

+ * * @return a {@link forge.card.spellability.SpellAbility} object. */ public final SpellAbility peekAbility() { @@ -1040,9 +1125,12 @@ public class MagicStack extends MyObservable { } /** - *

remove.

- * - * @param sa a {@link forge.card.spellability.SpellAbility} object. + *

+ * remove. + *

+ * + * @param sa + * a {@link forge.card.spellability.SpellAbility} object. */ public final void remove(final SpellAbility sa) { SpellAbility_StackInstance si = getInstanceFromSpellAbility(sa); @@ -1055,9 +1143,13 @@ public class MagicStack extends MyObservable { } /** - *

remove.

- * - * @param si a {@link forge.card.spellability.SpellAbility_StackInstance} object. + *

+ * remove. + *

+ * + * @param si + * a {@link forge.card.spellability.SpellAbility_StackInstance} + * object. */ public final void remove(final SpellAbility_StackInstance si) { if (getStack().remove(si)) { @@ -1068,10 +1160,14 @@ public class MagicStack extends MyObservable { } /** - *

getInstanceFromSpellAbility.

- * - * @param sa a {@link forge.card.spellability.SpellAbility} object. - * @return a {@link forge.card.spellability.SpellAbility_StackInstance} object. + *

+ * getInstanceFromSpellAbility. + *

+ * + * @param sa + * a {@link forge.card.spellability.SpellAbility} object. + * @return a {@link forge.card.spellability.SpellAbility_StackInstance} + * object. */ public final SpellAbility_StackInstance getInstanceFromSpellAbility(final SpellAbility sa) { // TODO: Confirm this works! @@ -1084,8 +1180,10 @@ public class MagicStack extends MyObservable { } /** - *

hasSimultaneousStackEntries.

- * + *

+ * hasSimultaneousStackEntries. + *

+ * * @return a boolean. */ public final boolean hasSimultaneousStackEntries() { @@ -1093,16 +1191,21 @@ public class MagicStack extends MyObservable { } /** - *

addSimultaneousStackEntry.

- * - * @param sa a {@link forge.card.spellability.SpellAbility} object. + *

+ * addSimultaneousStackEntry. + *

+ * + * @param sa + * a {@link forge.card.spellability.SpellAbility} object. */ public final void addSimultaneousStackEntry(final SpellAbility sa) { getSimultaneousStackEntryList().add(sa); } /** - *

chooseOrderOfSimultaneousStackEntryAll.

+ *

+ * chooseOrderOfSimultaneousStackEntryAll. + *

*/ public final void chooseOrderOfSimultaneousStackEntryAll() { final Player playerTurn = AllZone.getPhase().getPlayerTurn(); @@ -1115,9 +1218,12 @@ public class MagicStack extends MyObservable { } /** - *

chooseOrderOfSimultaneousStackEntry.

- * - * @param activePlayer a {@link forge.Player} object. + *

+ * chooseOrderOfSimultaneousStackEntry. + *

+ * + * @param activePlayer + * a {@link forge.Player} object. */ public final void chooseOrderOfSimultaneousStackEntry(final Player activePlayer) { if (getSimultaneousStackEntryList().size() == 0) { @@ -1152,9 +1258,8 @@ public class MagicStack extends MyObservable { } else { while (activePlayerSAs.size() > 1) { - SpellAbility next = - (SpellAbility) GuiUtils.getChoice("Choose which spell or ability to put on the stack next.", - activePlayerSAs.toArray()); + SpellAbility next = (SpellAbility) GuiUtils.getChoice( + "Choose which spell or ability to put on the stack next.", activePlayerSAs.toArray()); activePlayerSAs.remove(next); @@ -1169,18 +1274,19 @@ public class MagicStack extends MyObservable { if (activePlayerSAs.get(0).isTrigger()) { AllZone.getGameAction().playSpellAbility(activePlayerSAs.get(0)); - } - else { + } else { add(activePlayerSAs.get(0)); } - //AllZone.getGameAction().playSpellAbility(activePlayerSAs.get(0)); + // AllZone.getGameAction().playSpellAbility(activePlayerSAs.get(0)); } } /** * TODO: Write javadoc for this method. + * * @param triggerID - * @return + * the trigger id + * @return true, if successful */ public final boolean hasStateTrigger(final int triggerID) { for (SpellAbility_StackInstance sasi : getStack()) { @@ -1193,6 +1299,8 @@ public class MagicStack extends MyObservable { } /** + * Gets the simultaneous stack entry list. + * * @return the simultaneousStackEntryList */ public final List getSimultaneousStackEntryList() { @@ -1200,6 +1308,8 @@ public class MagicStack extends MyObservable { } /** + * Gets the stack. + * * @return the stack */ public final Stack getStack() { @@ -1207,6 +1317,8 @@ public class MagicStack extends MyObservable { } /** + * Gets the frozen stack. + * * @return the frozenStack */ public final Stack getFrozenStack() { @@ -1215,6 +1327,7 @@ public class MagicStack extends MyObservable { /** * Accessor for the field thisTurnCast. + * * @return a CardList. */ public final CardList getCardsCastThisTurn() { @@ -1227,7 +1340,7 @@ public class MagicStack extends MyObservable { public final void clearCardsCastThisTurn() { thisTurnCast.clear(); } - + /** * * setCardsCastLastTurn. @@ -1235,9 +1348,10 @@ public class MagicStack extends MyObservable { public final void setCardsCastLastTurn() { lastTurnCast = new CardList(thisTurnCast); } - + /** * Accessor for the field lastTurnCast. + * * @return a CardList. */ public final CardList getCardsCastLastTurn() { diff --git a/src/main/java/forge/MenuItem_HowToPlay.java b/src/main/java/forge/MenuItem_HowToPlay.java index d483f17ab83..920b1d1dd86 100644 --- a/src/main/java/forge/MenuItem_HowToPlay.java +++ b/src/main/java/forge/MenuItem_HowToPlay.java @@ -1,32 +1,38 @@ package forge; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; import forge.properties.ForgeProps; import forge.properties.NewConstants; -import javax.swing.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - - /** - *

MenuItem_HowToPlay class.

- * + *

+ * MenuItem_HowToPlay class. + *

+ * * @author Forge * @version $Id$ */ public class MenuItem_HowToPlay extends JMenuItem implements NewConstants.LANG.HowTo { - /** Constant serialVersionUID=5552000208438248428L */ + /** Constant serialVersionUID=5552000208438248428L. */ private static final long serialVersionUID = 5552000208438248428L; /** - *

Constructor for MenuItem_HowToPlay.

+ *

+ * Constructor for MenuItem_HowToPlay. + *

*/ public MenuItem_HowToPlay() { super(ForgeProps.getLocalized(TITLE)); this.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent a) { + public void actionPerformed(final ActionEvent a) { String text = ForgeProps.getLocalized(MESSAGE); JTextArea area = new JTextArea(text, 25, 40); @@ -40,131 +46,6 @@ public class MenuItem_HowToPlay extends JMenuItem implements NewConstants.LANG.H JOptionPane.INFORMATION_MESSAGE); } }); - }//constructor - - /** - *

getString.

- * - * @return a {@link java.lang.String} object. - */ - @SuppressWarnings("unused") - private String getString() { - String newLine = "\r\n\r\n"; - StringBuffer s = new StringBuffer(); - - s.append("How to Play - (Revised: September 2009.)\r\n\r\n\r\n"); - - s.append("Introduction").append(newLine); - s.append("1. This game is similar to many other trading card games. You start out with 20 life and your goal is to reduce your opponents life to zero by attacking with your creatures. The game will end when your life or the computer's life is reduced to zero. You play \"matches\" against the computer as a set of \"best two out of three\" games.") - .append(newLine); - s.append("2. You use land to pay for spells. You can play one land a turn.").append(newLine); - s.append("3. Each land produces a different magical energy. This magical energy is shortened to one letter on cards.") - .append(newLine); - s.append(" Forests make G\r\n"); - s.append(" Swamps make B\r\n"); - s.append(" Plains make W\r\n"); - s.append(" Islands make U\r\n"); - s.append(" Mountains make R").append(newLine); - s.append("4. Each nonland card has a name and a cost. The cost looks like this \"2GG\" A cost like that would require two Forest lands and two other lands. The number 2 can be paid for by any land. A cost like \"R\", would require a Mountain land.") - .append(newLine); - s.append("5. Creature cards stay in play and can attack on the turn AFTER they are played. A creature's attack and defense is shown like 2/4 meaning that the creature has an attack power of 2 and a defense of 4. If this creature receives 4 damage it is put into the graveyard.") - .append(newLine); - s.append("6. When you attack with your creatures the computer has a chance to block with his creatures. When you attack you \"tap\" your creatures by turning them sideways. Your creatures will untap during your next turn. When you block, only untapped creatures can block. Usually a creature cannot attack and block during the same turn.") - .append(newLine); - s.append("7. Sorcery and Instant cards have an effect on the game. After you play any card it goes on the stack to the left, click OK and the stack will clear. Sorcery cards can only be played during your turn and when the stack is empty. Instant cards can be played at any time and are more versatile.") - .append(newLine); - s.append("8. If a card has a target, you get to choose that target. If the target is a player, click on that player's life points.") - .append(newLine); - s.append("9. When you mulligan, the cards in your hand are shuffled into you deck and you are given 1 less card.\r\n\r\n\r\n"); - - s.append("Legendary Cards").append(newLine); - s.append("Legendary cards are powerful cards that can be either creatures, enchantments, lands, artifacts or planeswalkers. These cards can only exist once in the battlefield, and if another copy of the legendary card is played, all copies of the card are destroyed and sent to the graveyard.\r\n\r\n\r\n"); - - s.append("Planeswalkers").append(newLine); - s.append("There are 6 planeswalkers (Ajani Goldmane; Liliana Vess; Garruk Wildspeaker; Chandra Nalaar; Nicol Bolas; Elspeth, Knight-Errant) and they have specific rules for their special abilities.") - .append(newLine); - s.append("You can only use one ability a turn. A planeswalker can be attacked, but you can also block with your creatures. For each 1 damage a planeswalker receives, you remove 1 counter. When a planeswalker doesn't have any counters, it goes to the graveyard.\r\n\r\n\r\n"); - - s.append("Hybrid Mana and Multicolored Cards").append(newLine); - s.append("1. Hybrid Mana Cards are unique in their casting cost as seen in the card. Instead of seeing a single color per mana symbol, these cards have 2 colors per mana symbol indicating that the player has the choice of playing either of the two. There are also cases where numbers and colors are combined together in one mana symbol, which indicates that either colorless or colored mana can be paid for each symbol. Hybrid cards are treated as two colors and as such can be said to be multicolored.") - .append(newLine); - s.append("2. Multicolored Cards are slightly different than hybrid mana cards, as they require two or more different colors of mana, which may or not be in a single mana symbol. An example would be a card like Lightning Helix which requires one red and one white mana to be played.\r\n\r\n\r\n"); - - s.append("Game Types").append(newLine); - s.append("1. In Constructed Deck mode you can use any of the cards to make your deck. To make a constructed deck, from the Deck Editor select \"New Deck � Constructed\". A list of all the cards will be displayed.") - .append(newLine); - s.append("2. In Sealed Deck mode you are given 75 cards and you have to make your deck from just those cards.") - .append(newLine); - s.append("3. In Booster Draft mode you select 1 card at a time and then make your deck from just those cards. After you are done drafting you have to type in a filename, then go to the Deck Editor and from the menu select \"Open Deck - Draft\" and find the filename. This will allow you to construct your deck. You can then play against the other 7 computer opponents that were drafting with you.") - .append(newLine); - s.append("4. In Quest Mode you start out with 275 cards, 200 are Basic Lands. As you complete matches in your quest you will win more cards. In easy mode you get more cards after every game, whether you win or lose. Your goal is to become world champion. Once you reach the end of your quest you can continue to play additional matches and win even more cards or you can start a new quest at anytime.") - .append(newLine); - s.append("At the Quest Options screen you will be given a choice of four different difficulty levels. These difficulty levels control:") - .append(newLine); - s.append("1) the length of the quest in matches,\r\n"); - s.append("2) the hardness of the AI deck that you will face as an opponent,\r\n"); - s.append("3) the number of wins or loses needed to get more cards,\r\n"); - s.append("4) the number of wins needed to advance a player to the next rank.\r\n\r\n\r\n"); - - s.append("Quick Games").append(newLine); - s.append("There may be occasions where you only have a few minutes to play a quick game or two. At the top of the New Game window you will see the three different game types with radio buttons. Click on the Constructed (Easy) button and it will become highlighted.") - .append(newLine); - s.append("In the middle area of the New Game window you will see two menus, one labeled \"Your Deck\" and the other \"Opponent\". For a quick game you should select the \"Generate Deck\" or the \"Random\" option for both you and the computer.") - .append(newLine); - s.append("1. The \"Generate Deck\" option creates a 2 color deck. This option randomly picks cards and sometimes your mana curve may be too high.") - .append(newLine); - s.append("2. The \"Random\" option will randomly select one of the constructed decks that appear in the two deck menus. You either construct these decks in the Deck Editor or you imported a .deck file from the Deck Editor.") - .append(newLine); - s.append("If you select the \"Random\" option and click on the \"Start Game\" button and the match fails to begin � well, this happens if you fail to have any constructed decks saved to your all-decks2 file. You should choose the \"Generate Deck\" option instead.\r\n\r\n\r\n"); - - s.append("Resizable Game Area & Stack AI Land").append(newLine); - s.append("1. The \"Resizable Game Area\" check box should be set to on if your monitor will display more than 1024 x 768 pixels. The window containing the Battlefield and the informational displays will fill the entire screen.") - .append(newLine); - s.append("2. The \"Stack AI Land\" option will make the computer a more difficult opponent to beat. The computer will draw nonland cards from it's library after it has drawn enough lands to cover the cost of it's spells. Set the check box to on for a stronger opponent and set the check box to off for a weaker opponent.") - .append(newLine); - s.append("At times, you may notice that when you click the \"Start Game\" button that the match fails to begin. In this case you should turn the \"Stack AI Land\" option to off.\r\n\r\n\r\n"); - - s.append("Abilities").append(newLine); - s.append("There are three kinds of abilities: Activated, Triggered, and Static.").append(newLine); - s.append("1. Activated abilities contain a colon that separates cost and effect, these can be played any time you could play an instant. An example is Elvish Piper's ability. That cost also contains the tap symbol. For creatures only, abilities containing the tap- or untap symbol can be played starting the turn after the creature entered the battlefield. Another common cost for an activated ability is sacrificing the card. You do that by putting it into your graveyard. Such abilities can only be played once.") - .append(newLine); - s.append("2. Triggered abilities aren't played, they simply trigger when their condition occurs. An example is Angel of Mercy: You don't play the ability, but gain 3 life when it enters the battlefield.") - .append(newLine); - s.append("3. Static abilities are neither played, nor do they trigger. They still have an effect for as long as they are in play. An example is Glorious Anthem. There is no condition or cost, your creatures are just stronger.\r\n\r\n\r\n"); - - s.append("Keyword Abilities").append(newLine); - s.append("1. Flying: Creatures with flying are harder to block. Only creatures with flying or reach can block other flyers.") - .append(newLine); - s.append("2. Haste: Haste lets a creature attack or use any abilities immediately during this turn.") - .append(newLine); - s.append("3. Fear: Creatures with fear can only be blocked by artifact or black creatures. Creatures with fear are harder to block.") - .append(newLine); - s.append("4. Cycling: When you cycle a card you pay some cost like 2 and then you discard that card, and then draw a new card. Cycling helps make your deck more versatile.") - .append(newLine); - s.append("5. Vigilance: This means that the creature will not tap when attacking. This creature can both attack and block during the same turn.") - .append(newLine); - s.append("6. Trample: If you use 2/1 creature to block an attacking 3/4 creature with trample, you will still receive 2 damage because the 3/4 trampled over your 2/1 creature. Trample damage is calculated by (attack - blocker's defense), in this case 3-1 which is 2.") - .append(newLine); - s.append("7. Deathtouch: When a creatures with deathtouch deals damage to a creature, that creature is destroyed.") - .append(newLine); - s.append("8. Defender: Creatures with defender can not attack, they can only block another attacker.") - .append(newLine); - s.append("9. First Strike and Double Strike: Creatures with first strike deals their combat damage first. Creatures with double strike deals their combat damage first, and then deals their combat damage a second time during the combat damage step.") - .append(newLine); - s.append("10. Flash: You can play a creature with flash anytime that you can play an Instant.").append(newLine); - s.append("11. Landwalk: Allows your creature to attack without being blocked if your opponent controls the appropriate land type.") - .append(newLine); - s.append("12. Lifelink: With lifeline you gain life equal to the amount of damage dealt.").append(newLine); - s.append("13. Protection: Can not be damaged, blocked or targeted by sources that match the protection type.") - .append(newLine); - s.append("14. Reach: Creatures with reach can block flying creatures.").append(newLine); - s.append("15. Shroud: Permanents with shroud can not be targeted by abilities or spells.").append(newLine); - s.append("16. Regenerate: Regenerate is an ability that some creatures have which prevents them from being destroyed and put into the graveyard. When you regenerate a creature, it acts like a shield until end of turn.") - .append(newLine); - s.append("17. Morph: A creature with morph can be played by usually paying 3 mana of any color and be treated as a 2/2 creature with no abilities rather than playing the creature's actual cost. This creature is placed face down in the battlefield and can be flipped face up anytime as long as you pay its morph cost which is indicated on the card. Once flipped face up the card is treated as the original card, the one that you would normally play with its original-full casting cost."); - - - return s.toString(); - } -}//MenuItem_HowToPlay + } // constructor +} // MenuItem_HowToPlay diff --git a/src/main/java/forge/Move.java b/src/main/java/forge/Move.java index 67a5a07fa77..851589122b5 100644 --- a/src/main/java/forge/Move.java +++ b/src/main/java/forge/Move.java @@ -1,34 +1,47 @@ package forge; /** - *

Abstract Move class.

- * + *

+ * Abstract Move class. + *

+ * * @author Forge * @version $Id$ */ public abstract class Move { /** - *

generateMoves.

- * + *

+ * generateMoves. + *

+ * * @return an array of {@link forge.Move} objects. */ public abstract Move[] generateMoves(); /** - *

getScore.

- * + *

+ * getScore. + *

+ * * @return a int. */ public abstract int getScore(); + /** The best move. */ public Move bestMove = null; + + /** The best score. */ public int bestScore = Integer.MIN_VALUE; /** - *

min.

- * - * @param move a {@link forge.Move} object. - * @param depth a int. + *

+ * min. + *

+ * + * @param move + * a {@link forge.Move} object. + * @param depth + * a int. * @return a int. */ public final int min(final Move move, final int depth) { @@ -45,11 +58,16 @@ public abstract class Move { } /** - *

max.

- * - * @param move a {@link forge.Move} object. - * @param depth a int. - * @param first a boolean. + *

+ * max. + *

+ * + * @param move + * a {@link forge.Move} object. + * @param depth + * a int. + * @param first + * a boolean. * @return a int. */ public final int max(final Move move, final int depth, final boolean first) { @@ -66,7 +84,7 @@ public abstract class Move { bestScore = score; bestMove = v[i]; } - } //for + } // for return score; - } //max() + } // max() } diff --git a/src/main/java/forge/MyObservable.java b/src/main/java/forge/MyObservable.java index 28a5083bbe7..1e026720710 100644 --- a/src/main/java/forge/MyObservable.java +++ b/src/main/java/forge/MyObservable.java @@ -3,14 +3,18 @@ package forge; import java.util.Observable; /** - *

MyObservable class.

- * + *

+ * MyObservable class. + *

+ * * @author Forge * @version $Id$ */ public class MyObservable extends Observable { /** - *

updateObservers.

+ *

+ * updateObservers. + *

*/ public final void updateObservers() { this.setChanged(); @@ -25,4 +29,3 @@ public class MyObservable extends Observable { } } } - diff --git a/src/main/java/forge/MyRandom.java b/src/main/java/forge/MyRandom.java index 93d9e620bac..b16355a6391 100644 --- a/src/main/java/forge/MyRandom.java +++ b/src/main/java/forge/MyRandom.java @@ -3,8 +3,11 @@ package forge; import java.util.Random; /** - *

MyRandom class.
Preferably all Random numbers should be retrieved using this wrapper class

- * + *

+ * MyRandom class.
+ * Preferably all Random numbers should be retrieved using this wrapper class + *

+ * * @author Forge * @version $Id$ */ @@ -13,9 +16,13 @@ public class MyRandom { public static Random random = new Random(); /** - *

percentTrue.
If percent is like 30, then 30% of the time it will be true.

- * - * @param percent a int. + *

+ * percentTrue.
+ * If percent is like 30, then 30% of the time it will be true. + *

+ * + * @param percent + * a int. * @return a boolean. */ public static boolean percentTrue(final int percent) { diff --git a/src/main/java/forge/NameChanger.java b/src/main/java/forge/NameChanger.java index 5b81a89f8b4..94ae581ca71 100644 --- a/src/main/java/forge/NameChanger.java +++ b/src/main/java/forge/NameChanger.java @@ -1,10 +1,5 @@ package forge; -import forge.card.spellability.SpellAbility; -import forge.error.ErrorViewer; -import forge.properties.ForgeProps; -import forge.properties.NewConstants; - import java.io.BufferedReader; import java.io.FileReader; import java.util.Map; @@ -18,10 +13,16 @@ import net.slightlymagic.braids.util.lambda.Lambda1; import com.google.code.jyield.Generator; import com.google.code.jyield.YieldUtils; +import forge.card.spellability.SpellAbility; +import forge.error.ErrorViewer; +import forge.properties.ForgeProps; +import forge.properties.NewConstants; /** - *

NameChanger class.

- * + *

+ * NameChanger class. + *

+ * * @author Forge * @version $Id$ */ @@ -32,17 +33,21 @@ public class NameChanger implements NewConstants { private boolean changeCardName; /** - *

Constructor for NameChanger.

+ *

+ * Constructor for NameChanger. + *

*/ public NameChanger() { -// readFile(); + // readFile(); setShouldChangeCardName(false); } - //should change card name? + // should change card name? /** - *

shouldChangeCardName.

- * + *

+ * shouldChangeCardName. + *

+ * * @return a boolean. */ public final boolean shouldChangeCardName() { @@ -50,56 +55,64 @@ public class NameChanger implements NewConstants { } /** - *

setShouldChangeCardName.

- * - * @param b a boolean. + *

+ * setShouldChangeCardName. + *

+ * + * @param b + * a boolean. */ public final void setShouldChangeCardName(final boolean b) { changeCardName = b; } /** - * This change's the inputGenerator's Card instances in place, - * and returns a generator of those same changed instances. + * This change's the inputGenerator's Card instances in place, and returns a + * generator of those same changed instances. * - * TODO Should this method return void, because it side effects - * the contents of its inputGenerator? + * TODO Should this method return void, because it side effects the contents + * of its inputGenerator? * - * @param inputGenerator a Generator of Card objects + * @param inputGenerator + * a Generator of Card objects * @return a Generator of side-effected Card objects */ public final Generator changeCard(final Generator inputGenerator) { - // Create a new Generator by applying a transform to the - // inputGenerator. + // Create a new Generator by applying a transform to the + // inputGenerator. - Lambda1 transform = new Lambda1() { - public Card apply(final Card toChange) { - return changeCard(toChange); - }; - }; + Lambda1 transform = new Lambda1() { + public Card apply(final Card toChange) { + return changeCard(toChange); + }; + }; - return GeneratorFunctions.transformGenerator(transform, inputGenerator); + return GeneratorFunctions.transformGenerator(transform, inputGenerator); } - //changes card name, getText(), and all SpellAbility getStackDescription() and toString() + // changes card name, getText(), and all SpellAbility getStackDescription() + // and toString() /** - *

changeCard.

- * - * @param c a {@link forge.Card} object. + *

+ * changeCard. + *

+ * + * @param c + * a {@link forge.Card} object. * @return a {@link forge.Card} object. */ public final Card changeCard(final Card c) { - //change name + // change name String newName = changeName(c.getName()); c.setName(newName); - //change text + // change text String s; s = c.getSpellText(); c.setText(changeString(c, s)); - //change all SpellAbilities + // change all SpellAbilities SpellAbility[] spell = c.getSpellAbility(); for (int i = 0; i < spell.length; i++) { s = spell[i].getStackDescription(); @@ -110,50 +123,57 @@ public class NameChanger implements NewConstants { } return c; - } //getMutatedCard() + } // getMutatedCard() /** - *

changeString.

- * - * @param c a {@link forge.Card} object. - * @param in a {@link java.lang.String} object. + *

+ * changeString. + *

+ * + * @param c + * a {@link forge.Card} object. + * @param in + * a {@link java.lang.String} object. * @return a {@link java.lang.String} object. */ public final String changeString(final Card c, final String in) { - //String name = getOriginalName(c.getName()); // unused - // in = in.replaceAll(name, changeName(name)); + // String name = getOriginalName(c.getName()); // unused + // in = in.replaceAll(name, changeName(name)); return in; } - /** - * Changes a list of cards if shouldChangeCardName() is true. - * - * If not, we just return list. - * - * TODO Should this method return void, because it side effects the - * contents of its input list? - * - * @param list - * the list of cards to possibly change; while this list is not - * affected, its contents might be - * - * @return either list itself or a new list (possibly wasteful) containing - * the side effected cards - */ - public final CardList changeCardsIfNeeded(CardList list) { - if (shouldChangeCardName()) { + /** + * Changes a list of cards if shouldChangeCardName() is true. + * + * If not, we just return list. + * + * TODO Should this method return void, because it side effects the contents + * of its input list? + * + * @param list + * the list of cards to possibly change; while this list is not + * affected, its contents might be + * + * @return either list itself or a new list (possibly wasteful) containing + * the side effected cards + */ + public final CardList changeCardsIfNeeded(CardList list) { + if (shouldChangeCardName()) { list = new CardList(changeCard(YieldUtils.toGenerator(list))); } - return list; - } + return list; + } - //always returns mutated (alias) for the card name - //if argument is a mutated name, it returns the same mutated name + // always returns mutated (alias) for the card name + // if argument is a mutated name, it returns the same mutated name /** - *

changeName.

- * - * @param originalName a {@link java.lang.String} object. + *

+ * changeName. + *

+ * + * @param originalName + * a {@link java.lang.String} object. * @return a {@link java.lang.String} object. */ public final String changeName(final String originalName) { @@ -164,14 +184,17 @@ public class NameChanger implements NewConstants { } return o.toString(); - } //getMutatedName() + } // getMutatedName() - //always returns the original cardname - //if argument is a original name, it returns the same original name + // always returns the original cardname + // if argument is a original name, it returns the same original name /** - *

getOriginalName.

- * - * @param mutatedName a {@link java.lang.String} object. + *

+ * getOriginalName. + *

+ * + * @param mutatedName + * a {@link java.lang.String} object. * @return a {@link java.lang.String} object. */ public final String getOriginalName(final String mutatedName) { @@ -182,10 +205,12 @@ public class NameChanger implements NewConstants { } return o.toString(); - } //getOriginalName() + } // getOriginalName() /** - *

readFile.

+ *

+ * readFile. + *

*/ @SuppressWarnings("unused") private void readFile() { @@ -194,48 +219,51 @@ public class NameChanger implements NewConstants { String line = in.readLine(); - //stop reading if end of file or blank line is read + // stop reading if end of file or blank line is read while (line != null && (line.trim().length() != 0)) { processLine(line.trim()); line = in.readLine(); - } //while - } //try + } // while + } // try catch (Exception ex) { -//~ throw new RuntimeException("NameMutator : readFile() error, " +ex); + // ~ throw new RuntimeException("NameMutator : readFile() error, " + // +ex); - - //~ (could be cleaner...) + // ~ (could be cleaner...) try { BufferedReader in = new BufferedReader(new FileReader(ForgeProps.getFile(NAME_MUTATOR))); String line; - //stop reading if end of file or blank line is read + // stop reading if end of file or blank line is read while ((line = in.readLine()) != null && (line.trim().length() != 0)) { processLine(line.trim()); - } //while + } // while } catch (Exception ex2) { // Show orig exception ErrorViewer.showError(ex2); throw new RuntimeException(String.format("NameMutator : readFile() error, %s", ex), ex); } - //~ + // ~ } - } //readFile() + } // readFile() - //line is formated "original card name : alias card name" + // line is formated "original card name : alias card name" /** - *

processLine.

- * - * @param line a {@link java.lang.String} object. + *

+ * processLine. + *

+ * + * @param line + * a {@link java.lang.String} object. */ private void processLine(final String line) { StringTokenizer tok = new StringTokenizer(line, ":"); if (tok.countTokens() != 2) { - throw new RuntimeException( - "NameMutator : processLine() error, invalid line in file name-mutator.txt - " + line); + throw new RuntimeException("NameMutator : processLine() error, invalid line in file name-mutator.txt - " + + line); } String original = tok.nextToken().trim(); @@ -246,9 +274,12 @@ public class NameChanger implements NewConstants { } /** - *

printMap.

- * - * @param map a {@link java.util.Map} object. + *

+ * printMap. + *

+ * + * @param map + * a {@link java.util.Map} object. */ @SuppressWarnings("unused") // printMap diff --git a/src/main/java/forge/package-info.java b/src/main/java/forge/package-info.java index c56edf03222..7ce06c513ca 100644 --- a/src/main/java/forge/package-info.java +++ b/src/main/java/forge/package-info.java @@ -1,2 +1,2 @@ -/** Forge Card Game */ +/** Forge Card Game. */ package forge;