checkstyle

This commit is contained in:
jendave
2011-11-01 15:28:24 +00:00
parent 4f800f40b7
commit bcff189989
11 changed files with 270 additions and 267 deletions

View File

@@ -78,7 +78,7 @@ public abstract class Input implements java.io.Serializable {
* stop. * stop.
* </p> * </p>
*/ */
final public void stop() { public final void stop() {
// clears a "temp" Input like Input_PayManaCost if there is one // clears a "temp" Input like Input_PayManaCost if there is one
AllZone.getInputControl().resetInput(); AllZone.getInputControl().resetInput();
@@ -98,8 +98,8 @@ public abstract class Input implements java.io.Serializable {
* @param in * @param in
* a {@link forge.gui.input.Input} object. * a {@link forge.gui.input.Input} object.
*/ */
final public void stopSetNext(Input in) { public final void stopSetNext(final Input in) {
stop(); this.stop();
AllZone.getInputControl().setInput(in); AllZone.getInputControl().setInput(in);
} }
@@ -107,7 +107,7 @@ public abstract class Input implements java.io.Serializable {
@Override @Override
public String toString() { public String toString() {
return "blank"; return "blank";
}// returns the Input name like "EmptyStack" } // returns the Input name like "EmptyStack"
/** /**
* <p> * <p>
@@ -117,7 +117,7 @@ public abstract class Input implements java.io.Serializable {
* @param isFree * @param isFree
* a boolean. * a boolean.
*/ */
public void setFree(boolean isFree) { public void setFree(final boolean isFree) {
this.isFree = isFree; this.isFree = isFree;
} }
@@ -129,6 +129,6 @@ public abstract class Input implements java.io.Serializable {
* @return a boolean. * @return a boolean.
*/ */
public boolean isFree() { public boolean isFree() {
return isFree; return this.isFree;
} }
} }

View File

@@ -25,10 +25,10 @@ public class InputControl extends MyObservable implements java.io.Serializable {
private Input input; private Input input;
/** Constant <code>n=0</code>. */ /** Constant <code>n=0</code>. */
static int n = 0; private static int n = 0;
private Stack<Input> inputStack = new Stack<Input>(); private final Stack<Input> inputStack = new Stack<Input>();
private Stack<Input> resolvingStack = new Stack<Input>(); private final Stack<Input> resolvingStack = new Stack<Input>();
private LinkedList<Input> resolvingQueue = new LinkedList<Input>(); private final LinkedList<Input> resolvingQueue = new LinkedList<Input>();
private final FModel model; private final FModel model;
private ComputerAI_Input aiInput; // initialized at runtime to be the latest private ComputerAI_Input aiInput; // initialized at runtime to be the latest
@@ -41,7 +41,7 @@ public class InputControl extends MyObservable implements java.io.Serializable {
* the f model * the f model
*/ */
public InputControl(final FModel fModel) { public InputControl(final FModel fModel) {
model = fModel; this.model = fModel;
} }
/** /**
@@ -53,12 +53,13 @@ public class InputControl extends MyObservable implements java.io.Serializable {
* a {@link forge.gui.input.Input} object. * a {@link forge.gui.input.Input} object.
*/ */
public final void setInput(final Input in) { public final void setInput(final Input in) {
if (model.getGameState().getStack().getResolving() || !(input == null || input instanceof Input_PassPriority)) { if (this.model.getGameState().getStack().getResolving()
inputStack.add(in); || !((this.input == null) || (this.input instanceof Input_PassPriority))) {
this.inputStack.add(in);
} else { } else {
input = in; this.input = in;
} }
updateObservers(); this.updateObservers();
} }
/** /**
@@ -74,13 +75,13 @@ public class InputControl extends MyObservable implements java.io.Serializable {
public final void setInput(final Input in, final boolean bAddToResolving) { public final void setInput(final Input in, final boolean bAddToResolving) {
// Make this // Make this
if (!bAddToResolving) { if (!bAddToResolving) {
setInput(in); this.setInput(in);
return; return;
} }
Input old = input; final Input old = this.input;
resolvingStack.add(old); this.resolvingStack.add(old);
changeInput(in); this.changeInput(in);
} }
/** /**
@@ -92,8 +93,8 @@ public class InputControl extends MyObservable implements java.io.Serializable {
* a {@link forge.gui.input.Input} object. * a {@link forge.gui.input.Input} object.
*/ */
private void changeInput(final Input in) { private void changeInput(final Input in) {
input = in; this.input = in;
updateObservers(); this.updateObservers();
} }
/** /**
@@ -104,7 +105,7 @@ public class InputControl extends MyObservable implements java.io.Serializable {
* @return a {@link forge.gui.input.Input} object. * @return a {@link forge.gui.input.Input} object.
*/ */
public final Input getInput() { public final Input getInput() {
return input; return this.input;
} }
/** /**
@@ -113,9 +114,9 @@ public class InputControl extends MyObservable implements java.io.Serializable {
* </p> * </p>
*/ */
public final void clearInput() { public final void clearInput() {
input = null; this.input = null;
resolvingQueue.clear(); this.resolvingQueue.clear();
inputStack.clear(); this.inputStack.clear();
} }
/** /**
@@ -124,8 +125,8 @@ public class InputControl extends MyObservable implements java.io.Serializable {
* </p> * </p>
*/ */
public final void resetInput() { public final void resetInput() {
input = null; this.input = null;
updateObservers(); this.updateObservers();
} }
/** /**
@@ -137,9 +138,9 @@ public class InputControl extends MyObservable implements java.io.Serializable {
* a boolean. * a boolean.
*/ */
public final void resetInput(final boolean update) { public final void resetInput(final boolean update) {
input = null; this.input = null;
if (update) { if (update) {
updateObservers(); this.updateObservers();
} }
} }
@@ -151,62 +152,62 @@ public class InputControl extends MyObservable implements java.io.Serializable {
* @return a {@link forge.gui.input.Input} object. * @return a {@link forge.gui.input.Input} object.
*/ */
public final Input updateInput() { public final Input updateInput() {
final String phase = model.getGameState().getPhase().getPhase(); final String phase = this.model.getGameState().getPhase().getPhase();
final Player playerTurn = model.getGameState().getPhase().getPlayerTurn(); final Player playerTurn = this.model.getGameState().getPhase().getPlayerTurn();
final Player priority = model.getGameState().getPhase().getPriorityPlayer(); final Player priority = this.model.getGameState().getPhase().getPriorityPlayer();
// TODO this resolving portion needs more work, but fixes Death Cloud // TODO this resolving portion needs more work, but fixes Death Cloud
// issues // issues
if (resolvingStack.size() > 0) { if (this.resolvingStack.size() > 0) {
if (input != null) { if (this.input != null) {
return input; return this.input;
} }
// if an SA is resolving, only change input for something that is // if an SA is resolving, only change input for something that is
// part of the resolving SA // part of the resolving SA
changeInput(resolvingStack.pop()); this.changeInput(this.resolvingStack.pop());
return input; return this.input;
} }
if (model.getGameState().getStack().getResolving()) { if (this.model.getGameState().getStack().getResolving()) {
return null; return null;
} }
if (input != null) { if (this.input != null) {
return input; return this.input;
} else if (inputStack.size() > 0) { // incoming input to Control } else if (this.inputStack.size() > 0) { // incoming input to Control
changeInput(inputStack.pop()); this.changeInput(this.inputStack.pop());
return input; return this.input;
} }
if (Phase.getGameBegins() != 0 && model.getGameState().getPhase().doPhaseEffects()) { if ((Phase.getGameBegins() != 0) && this.model.getGameState().getPhase().doPhaseEffects()) {
// Handle begin phase stuff, then start back from the top // Handle begin phase stuff, then start back from the top
model.getGameState().getPhase().handleBeginPhase(); this.model.getGameState().getPhase().handleBeginPhase();
return updateInput(); return this.updateInput();
} }
// If the Phase we're in doesn't allow for Priority, return null to move // If the Phase we're in doesn't allow for Priority, return null to move
// to next phase // to next phase
if (model.getGameState().getPhase().isNeedToNextPhase()) { if (this.model.getGameState().getPhase().isNeedToNextPhase()) {
return null; return null;
} }
// Special Inputs needed for the following phases: // Special Inputs needed for the following phases:
if (phase.equals(Constant.Phase.COMBAT_DECLARE_ATTACKERS)) { if (phase.equals(Constant.Phase.COMBAT_DECLARE_ATTACKERS)) {
model.getGameState().getStack().freezeStack(); this.model.getGameState().getStack().freezeStack();
if (playerTurn.isHuman()) { if (playerTurn.isHuman()) {
return new Input_Attack(); return new Input_Attack();
} }
} else if (phase.equals(Constant.Phase.COMBAT_DECLARE_BLOCKERS)) { } else if (phase.equals(Constant.Phase.COMBAT_DECLARE_BLOCKERS)) {
model.getGameState().getStack().freezeStack(); this.model.getGameState().getStack().freezeStack();
if (playerTurn.isHuman()) { if (playerTurn.isHuman()) {
aiInput.getComputer().declareBlockers(); this.aiInput.getComputer().declareBlockers();
return null; return null;
} else { } else {
if (model.getGameState().getCombat().getAttackers().length == 0) { if (this.model.getGameState().getCombat().getAttackers().length == 0) {
// no active attackers, skip the Blocking phase // no active attackers, skip the Blocking phase
model.getGameState().getPhase().setNeedToNextPhase(true); this.model.getGameState().getPhase().setNeedToNextPhase(true);
return null; return null;
} else { } else {
return new Input_Block(); return new Input_Block();
@@ -214,9 +215,9 @@ public class InputControl extends MyObservable implements java.io.Serializable {
} }
} else if (phase.equals(Constant.Phase.CLEANUP)) { } else if (phase.equals(Constant.Phase.CLEANUP)) {
// discard // discard
if (model.getGameState().getStack().size() == 0) { if (this.model.getGameState().getStack().size() == 0) {
// resolve things // resolve things
// like Madness // like Madness
return new Input_Cleanup(); return new Input_Cleanup();
} }
} }
@@ -226,22 +227,22 @@ public class InputControl extends MyObservable implements java.io.Serializable {
// priority // priority
if (priority.isHuman()) { if (priority.isHuman()) {
boolean skip = model.getGameState().getPhase().doSkipPhase(); final boolean skip = this.model.getGameState().getPhase().doSkipPhase();
model.getGameState().getPhase().setSkipPhase(false); this.model.getGameState().getPhase().setSkipPhase(false);
if (model.getGameState().getStack().size() == 0 if ((this.model.getGameState().getStack().size() == 0)
&& !forge.AllZone.getDisplay().stopAtPhase(playerTurn, phase) && skip) { && !forge.AllZone.getDisplay().stopAtPhase(playerTurn, phase) && skip) {
model.getGameState().getPhase().passPriority(); this.model.getGameState().getPhase().passPriority();
return null; return null;
} else { } else {
return new Input_PassPriority(); return new Input_PassPriority();
} }
} else if (playerTurn.isComputer()) { } else if (playerTurn.isComputer()) {
return aiInput; return this.aiInput;
} else { } else {
aiInput.getComputer().stackNotEmpty(); this.aiInput.getComputer().stackNotEmpty();
return null; return null;
} }
}// getInput() } // getInput()
/** /**
* Sets the computer. * Sets the computer.
@@ -250,6 +251,6 @@ public class InputControl extends MyObservable implements java.io.Serializable {
* the new computer * the new computer
*/ */
public final void setComputer(final ComputerAI_Input computerAI_Input) { public final void setComputer(final ComputerAI_Input computerAI_Input) {
aiInput = computerAI_Input; this.aiInput = computerAI_Input;
} }
}// InputControl } // InputControl

View File

@@ -30,12 +30,12 @@ public class Input_Attack extends Input {
ButtonUtil.enableOnlyOK(); ButtonUtil.enableOnlyOK();
Object o = AllZone.getCombat().nextDefender(); final Object o = AllZone.getCombat().nextDefender();
if (o == null) { if (o == null) {
return; return;
} }
StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
sb.append("Declare Attackers: Select Creatures to Attack "); sb.append("Declare Attackers: Select Creatures to Attack ");
sb.append(o.toString()); sb.append(o.toString());
@@ -46,7 +46,7 @@ public class Input_Attack extends Input {
CardList possibleAttackers = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); CardList possibleAttackers = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield);
possibleAttackers = possibleAttackers.getType("Creature"); possibleAttackers = possibleAttackers.getType("Creature");
for (int i = 0; i < possibleAttackers.size(); i++) { for (int i = 0; i < possibleAttackers.size(); i++) {
Card c = possibleAttackers.get(i); final Card c = possibleAttackers.get(i);
if (c.hasKeyword("CARDNAME attacks each turn if able.") && CombatUtil.canAttack(c, AllZone.getCombat()) if (c.hasKeyword("CARDNAME attacks each turn if able.") && CombatUtil.canAttack(c, AllZone.getCombat())
&& !c.isAttacking()) { && !c.isAttacking()) {
AllZone.getCombat().addAttacker(c); AllZone.getCombat().addAttacker(c);
@@ -97,8 +97,8 @@ public class Input_Attack extends Input {
// marked // marked
// for Castle Raptors, since it gets a bonus if untapped // for Castle Raptors, since it gets a bonus if untapped
for (String effect : AllZone.getStaticEffects().getStateBasedMap().keySet()) { for (final String effect : AllZone.getStaticEffects().getStateBasedMap().keySet()) {
Command com = GameActionUtil.getCommands().get(effect); final Command com = GameActionUtil.getCommands().get(effect);
com.execute(); com.execute();
} }

View File

@@ -25,7 +25,7 @@ public class Input_Block extends Input {
private static final long serialVersionUID = 6120743598368928128L; private static final long serialVersionUID = 6120743598368928128L;
private Card currentAttacker = null; private Card currentAttacker = null;
private ArrayList<Card> allBlocking = new ArrayList<Card>(); private final ArrayList<Card> allBlocking = new ArrayList<Card>();
/** /**
* <p> * <p>
@@ -36,22 +36,22 @@ public class Input_Block extends Input {
* a {@link forge.Card} object. * a {@link forge.Card} object.
*/ */
public final void removeFromAllBlocking(final Card c) { public final void removeFromAllBlocking(final Card c) {
allBlocking.remove(c); this.allBlocking.remove(c);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final void showMessage() { public final void showMessage() {
// for Castle Raptors, since it gets a bonus if untapped // for Castle Raptors, since it gets a bonus if untapped
for (String effect : AllZone.getStaticEffects().getStateBasedMap().keySet()) { for (final String effect : AllZone.getStaticEffects().getStateBasedMap().keySet()) {
Command com = GameActionUtil.getCommands().get(effect); final Command com = GameActionUtil.getCommands().get(effect);
com.execute(); com.execute();
} }
// could add "Reset Blockers" button // could add "Reset Blockers" button
ButtonUtil.enableOnlyOK(); ButtonUtil.enableOnlyOK();
if (currentAttacker == null) { if (this.currentAttacker == null) {
/* /*
* //Lure CardList attackers = new * //Lure CardList attackers = new
* CardList(AllZone.getCombat().getAttackers()); for(Card * CardList(AllZone.getCombat().getAttackers()); for(Card
@@ -66,9 +66,11 @@ public class Input_Block extends Input {
AllZone.getDisplay().showMessage("To Block, click on your Opponents attacker first, then your blocker(s)"); AllZone.getDisplay().showMessage("To Block, click on your Opponents attacker first, then your blocker(s)");
} else { } else {
String attackerName = currentAttacker.isFaceDown() ? "Morph" : currentAttacker.getName(); final String attackerName = this.currentAttacker.isFaceDown() ? "Morph" : this.currentAttacker.getName();
AllZone.getDisplay().showMessage( AllZone.getDisplay()
"Select a creature to block " + attackerName + " (" + currentAttacker.getUniqueNumber() + ") "); .showMessage(
"Select a creature to block " + attackerName + " ("
+ this.currentAttacker.getUniqueNumber() + ") ");
} }
CombatUtil.showCombat(); CombatUtil.showCombat();
@@ -90,14 +92,14 @@ public class Input_Block extends Input {
public final void selectCard(final Card card, final PlayerZone zone) { public final void selectCard(final Card card, final PlayerZone zone) {
// is attacking? // is attacking?
if (CardUtil.toList(AllZone.getCombat().getAttackers()).contains(card)) { if (CardUtil.toList(AllZone.getCombat().getAttackers()).contains(card)) {
currentAttacker = card; this.currentAttacker = card;
} else if (zone.is(Constant.Zone.Battlefield, AllZone.getHumanPlayer()) && card.isCreature() } else if (zone.is(Constant.Zone.Battlefield, AllZone.getHumanPlayer()) && card.isCreature()
&& CombatUtil.canBlock(currentAttacker, card, AllZone.getCombat())) { && CombatUtil.canBlock(this.currentAttacker, card, AllZone.getCombat())) {
if (currentAttacker != null && (!allBlocking.contains(card))) { if ((this.currentAttacker != null) && (!this.allBlocking.contains(card))) {
allBlocking.add(card); this.allBlocking.add(card);
AllZone.getCombat().addBlocker(currentAttacker, card); AllZone.getCombat().addBlocker(this.currentAttacker, card);
} }
} }
showMessage(); this.showMessage();
} // selectCard() } // selectCard()
} }

View File

@@ -24,22 +24,22 @@ public class Input_Cleanup extends Input {
@Override @Override
public final void showMessage() { public final void showMessage() {
if (AllZone.getPhase().getPlayerTurn().isComputer()) { if (AllZone.getPhase().getPlayerTurn().isComputer()) {
AI_CleanupDiscard(); this.aiCleanupDiscard();
return; return;
} }
ButtonUtil.disableAll(); ButtonUtil.disableAll();
int n = AllZone.getHumanPlayer().getCardsIn(Zone.Hand).size(); final int n = AllZone.getHumanPlayer().getCardsIn(Zone.Hand).size();
// MUST showMessage() before stop() or it will overwrite the next // MUST showMessage() before stop() or it will overwrite the next
// Input's message // Input's message
StringBuffer sb = new StringBuffer(); final StringBuffer sb = new StringBuffer();
sb.append("Cleanup Phase: You can only have a maximum of ").append(AllZone.getHumanPlayer().getMaxHandSize()); sb.append("Cleanup Phase: You can only have a maximum of ").append(AllZone.getHumanPlayer().getMaxHandSize());
sb.append(" cards, you currently have ").append(n).append(" cards in your hand - select a card to discard"); sb.append(" cards, you currently have ").append(n).append(" cards in your hand - select a card to discard");
AllZone.getDisplay().showMessage(sb.toString()); AllZone.getDisplay().showMessage(sb.toString());
// goes to the next phase // goes to the next phase
if (n <= AllZone.getHumanPlayer().getMaxHandSize() || AllZone.getHumanPlayer().getMaxHandSize() == -1) { if ((n <= AllZone.getHumanPlayer().getMaxHandSize()) || (AllZone.getHumanPlayer().getMaxHandSize() == -1)) {
CombatUtil.removeAllDamage(); CombatUtil.removeAllDamage();
AllZone.getPhase().setNeedToNextPhase(true); AllZone.getPhase().setNeedToNextPhase(true);
@@ -54,7 +54,7 @@ public class Input_Cleanup extends Input {
if (zone.is(Constant.Zone.Hand, AllZone.getHumanPlayer())) { if (zone.is(Constant.Zone.Hand, AllZone.getHumanPlayer())) {
card.getController().discard(card, null); card.getController().discard(card, null);
if (AllZone.getStack().size() == 0) { if (AllZone.getStack().size() == 0) {
showMessage(); this.showMessage();
} }
} }
} // selectCard() } // selectCard()
@@ -64,11 +64,11 @@ public class Input_Cleanup extends Input {
* AI_CleanupDiscard. * AI_CleanupDiscard.
* </p> * </p>
*/ */
public void AI_CleanupDiscard() { public void aiCleanupDiscard() {
int size = AllZone.getComputerPlayer().getCardsIn(Zone.Hand).size(); final int size = AllZone.getComputerPlayer().getCardsIn(Zone.Hand).size();
if (AllZone.getComputerPlayer().getMaxHandSize() != -1) { if (AllZone.getComputerPlayer().getMaxHandSize() != -1) {
int numDiscards = size - AllZone.getComputerPlayer().getMaxHandSize(); final int numDiscards = size - AllZone.getComputerPlayer().getMaxHandSize();
AllZone.getComputerPlayer().discard(numDiscards, null, false); AllZone.getComputerPlayer().discard(numDiscards, null, false);
} }
CombatUtil.removeAllDamage(); CombatUtil.removeAllDamage();

View File

@@ -45,7 +45,7 @@ public class Input_Mulligan extends Input {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final void selectButtonOK() { public final void selectButtonOK() {
end(); this.end();
} }
/** /**
@@ -59,14 +59,14 @@ public class Input_Mulligan extends Input {
* @return an int * @return an int
*/ */
public final int doMulligan(final Player player, final GamePlayerRating playerRating) { public final int doMulligan(final Player player, final GamePlayerRating playerRating) {
CardList hand = player.getCardsIn(Zone.Hand); final CardList hand = player.getCardsIn(Zone.Hand);
for (Card c : hand) { for (final Card c : hand) {
AllZone.getGameAction().moveToLibrary(c); AllZone.getGameAction().moveToLibrary(c);
} }
for (int i = 0; i < MAGIC_NUMBER_OF_SHUFFLES; i++) { for (int i = 0; i < Input_Mulligan.MAGIC_NUMBER_OF_SHUFFLES; i++) {
player.shuffle(); player.shuffle();
} }
int newHand = hand.size() - 1; final int newHand = hand.size() - 1;
for (int i = 0; i < newHand; i++) { for (int i = 0; i < newHand; i++) {
player.drawCard(); player.drawCard();
} }
@@ -78,19 +78,19 @@ public class Input_Mulligan extends Input {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final void selectButtonCancel() { public final void selectButtonCancel() {
Player humanPlayer = AllZone.getHumanPlayer(); final Player humanPlayer = AllZone.getHumanPlayer();
GamePlayerRating humanRating = AllZone.getGameInfo().getPlayerRating(humanPlayer.getName()); final GamePlayerRating humanRating = AllZone.getGameInfo().getPlayerRating(humanPlayer.getName());
int newHand = doMulligan(humanPlayer, humanRating); final int newHand = this.doMulligan(humanPlayer, humanRating);
QuestData quest = AllZone.getQuestData(); final QuestData quest = AllZone.getQuestData();
if (quest != null && quest.getInventory().hasItem("Sleight") && humanRating.getMulliganCount() == 1) { if ((quest != null) && quest.getInventory().hasItem("Sleight") && (humanRating.getMulliganCount() == 1)) {
AllZone.getHumanPlayer().drawCard(); AllZone.getHumanPlayer().drawCard();
humanRating.notifyOpeningHandSize(newHand + 1); humanRating.notifyOpeningHandSize(newHand + 1);
} }
if (newHand == 0) { if (newHand == 0) {
end(); this.end();
} }
} // selectButtonOK() } // selectButtonOK()
@@ -101,37 +101,37 @@ public class Input_Mulligan extends Input {
*/ */
final void end() { final void end() {
// Computer mulligan // Computer mulligan
Player aiPlayer = AllZone.getComputerPlayer(); final Player aiPlayer = AllZone.getComputerPlayer();
GamePlayerRating aiRating = AllZone.getGameInfo().getPlayerRating(aiPlayer.getName()); final GamePlayerRating aiRating = AllZone.getGameInfo().getPlayerRating(aiPlayer.getName());
boolean aiTakesMulligan = true; boolean aiTakesMulligan = true;
// Computer mulligans if there are no cards with converted mana cost of // Computer mulligans if there are no cards with converted mana cost of
// 0 in its hand // 0 in its hand
while (aiTakesMulligan) { while (aiTakesMulligan) {
CardList handList = aiPlayer.getCardsIn(Zone.Hand); final CardList handList = aiPlayer.getCardsIn(Zone.Hand);
boolean hasLittleCmc0Cards = handList.getValidCards("Card.cmcEQ0", aiPlayer, null).size() < 2; final boolean hasLittleCmc0Cards = handList.getValidCards("Card.cmcEQ0", aiPlayer, null).size() < 2;
aiTakesMulligan = handList.size() > AI_MULLIGAN_THRESHOLD && hasLittleCmc0Cards; aiTakesMulligan = (handList.size() > Input_Mulligan.AI_MULLIGAN_THRESHOLD) && hasLittleCmc0Cards;
if (aiTakesMulligan) { if (aiTakesMulligan) {
doMulligan(aiPlayer, aiRating); this.doMulligan(aiPlayer, aiRating);
} }
} }
// Human Leylines & Chancellors // Human Leylines & Chancellors
ButtonUtil.reset(); ButtonUtil.reset();
AbilityFactory af = new AbilityFactory(); final AbilityFactory af = new AbilityFactory();
CardList humanOpeningHand = AllZone.getHumanPlayer().getCardsIn(Zone.Hand); final CardList humanOpeningHand = AllZone.getHumanPlayer().getCardsIn(Zone.Hand);
for (Card c : humanOpeningHand) { for (final Card c : humanOpeningHand) {
ArrayList<String> kws = c.getKeyword(); final ArrayList<String> kws = c.getKeyword();
for (int i = 0; i < kws.size(); i++) { for (int i = 0; i < kws.size(); i++) {
String kw = kws.get(i); final String kw = kws.get(i);
if (kw.startsWith("MayEffectFromOpeningHand")) { if (kw.startsWith("MayEffectFromOpeningHand")) {
String effName = kw.split(":")[1]; final String effName = kw.split(":")[1];
SpellAbility effect = af.getAbility(c.getSVar(effName), c); final SpellAbility effect = af.getAbility(c.getSVar(effName), c);
if (GameActionUtil.showYesNoDialog(c, "Use this card's ability?")) { if (GameActionUtil.showYesNoDialog(c, "Use this card's ability?")) {
// If we ever let the AI memorize cards in the players // If we ever let the AI memorize cards in the players
// hand, this would be a place to do so. // hand, this would be a place to do so.
@@ -147,17 +147,17 @@ public class Input_Mulligan extends Input {
} }
// Computer Leylines & Chancellors // Computer Leylines & Chancellors
CardList aiOpeningHand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); final CardList aiOpeningHand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand);
for (Card c : aiOpeningHand) { for (final Card c : aiOpeningHand) {
if (!c.getName().startsWith("Leyline")) { if (!c.getName().startsWith("Leyline")) {
ArrayList<String> kws = c.getKeyword(); final ArrayList<String> kws = c.getKeyword();
for (int i = 0; i < kws.size(); i++) { for (int i = 0; i < kws.size(); i++) {
String kw = kws.get(i); final String kw = kws.get(i);
if (kw.startsWith("MayEffectFromOpeningHand")) { if (kw.startsWith("MayEffectFromOpeningHand")) {
String effName = kw.split(":")[1]; final String effName = kw.split(":")[1];
SpellAbility effect = af.getAbility(c.getSVar(effName), c); final SpellAbility effect = af.getAbility(c.getSVar(effName), c);
// Is there a better way for the AI to decide this? // Is there a better way for the AI to decide this?
if (effect.doTrigger(false)) { if (effect.doTrigger(false)) {
@@ -169,8 +169,8 @@ public class Input_Mulligan extends Input {
} }
} }
if (c.getName().startsWith("Leyline") if (c.getName().startsWith("Leyline")
&& !(c.getName().startsWith("Leyline of Singularity") && AllZoneUtil.getCardsIn(Zone.Battlefield, && !(c.getName().startsWith("Leyline of Singularity") && (AllZoneUtil.getCardsIn(Zone.Battlefield,
"Leyline of Singularity").size() > 0)) { "Leyline of Singularity").size() > 0))) {
AllZone.getGameAction().moveToPlay(c); AllZone.getGameAction().moveToPlay(c);
AllZone.getGameAction().checkStateEffects(); AllZone.getGameAction().checkStateEffects();
} }
@@ -188,6 +188,6 @@ public class Input_Mulligan extends Input {
AllZone.getGameAction().checkStateEffects(); AllZone.getGameAction().checkStateEffects();
Phase.setGameBegins(1); Phase.setGameBegins(1);
AllZone.getPhase().setNeedToNextPhase(false); AllZone.getPhase().setNeedToNextPhase(false);
stop(); this.stop();
} }
} }

View File

@@ -25,14 +25,14 @@ public class Input_PassPriority extends Input implements java.io.Serializable {
GuiDisplayUtil.updateGUI(); GuiDisplayUtil.updateGUI();
ButtonUtil.enableOnlyOK(); ButtonUtil.enableOnlyOK();
String phase = AllZone.getPhase().getPhase(); final String phase = AllZone.getPhase().getPhase();
Player player = AllZone.getPhase().getPriorityPlayer(); final Player player = AllZone.getPhase().getPriorityPlayer();
if (player.isComputer()) { if (player.isComputer()) {
System.out.println(phase + ": Computer in passpriority"); System.out.println(phase + ": Computer in passpriority");
} }
StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
sb.append("Turn : ").append(AllZone.getPhase().getPlayerTurn()).append("\n"); sb.append("Turn : ").append(AllZone.getPhase().getPlayerTurn()).append("\n");
sb.append("Phase: ").append(phase).append("\n"); sb.append("Phase: ").append(phase).append("\n");
@@ -53,10 +53,10 @@ public class Input_PassPriority extends Input implements java.io.Serializable {
public final void selectButtonOK() { public final void selectButtonOK() {
AllZone.getPhase().passPriority(); AllZone.getPhase().passPriority();
GuiDisplayUtil.updateGUI(); GuiDisplayUtil.updateGUI();
Input in = AllZone.getInputControl().getInput(); final Input in = AllZone.getInputControl().getInput();
if (in == this || in == null) { if ((in == this) || (in == null)) {
AllZone.getInputControl().resetInput(); AllZone.getInputControl().resetInput();
// Clear out PassPriority after clicking button // Clear out PassPriority after clicking button
} }
} }

View File

@@ -31,7 +31,7 @@ public class Input_PayManaCost extends Input {
private final Card originalCard; private final Card originalCard;
/** The mana cost. */ /** The mana cost. */
public ManaCost manaCost; private ManaCost manaCost;
private final SpellAbility spell; private final SpellAbility spell;
@@ -50,25 +50,25 @@ public class Input_PayManaCost extends Input {
* a boolean. * a boolean.
*/ */
public Input_PayManaCost(final SpellAbility sa, final boolean noStack) { public Input_PayManaCost(final SpellAbility sa, final boolean noStack) {
skipStack = noStack; this.skipStack = noStack;
originalManaCost = sa.getManaCost(); // Change this.originalManaCost = sa.getManaCost(); // Change
originalCard = sa.getSourceCard(); this.originalCard = sa.getSourceCard();
spell = sa; this.spell = sa;
if (Phase.getGameBegins() == 1) { if (Phase.getGameBegins() == 1) {
if (sa.getSourceCard().isCopiedSpell() && sa.isSpell()) { if (sa.getSourceCard().isCopiedSpell() && sa.isSpell()) {
if (spell.getAfterPayMana() != null) { if (this.spell.getAfterPayMana() != null) {
stopSetNext(spell.getAfterPayMana()); this.stopSetNext(this.spell.getAfterPayMana());
} else { } else {
manaCost = new ManaCost("0"); this.manaCost = new ManaCost("0");
AllZone.getStack().add(spell); AllZone.getStack().add(this.spell);
} }
} else { } else {
manaCost = AllZone.getGameAction().getSpellCostChange(sa, new ManaCost(originalManaCost)); this.manaCost = AllZone.getGameAction().getSpellCostChange(sa, new ManaCost(this.originalManaCost));
} }
} else { } else {
manaCost = new ManaCost(sa.getManaCost()); this.manaCost = new ManaCost(sa.getManaCost());
} }
} }
@@ -81,24 +81,24 @@ public class Input_PayManaCost extends Input {
* a {@link forge.card.spellability.SpellAbility} object. * a {@link forge.card.spellability.SpellAbility} object.
*/ */
public Input_PayManaCost(final SpellAbility sa) { public Input_PayManaCost(final SpellAbility sa) {
originalManaCost = sa.getManaCost(); // Change this.originalManaCost = sa.getManaCost(); // Change
originalCard = sa.getSourceCard(); this.originalCard = sa.getSourceCard();
spell = sa; this.spell = sa;
if (Phase.getGameBegins() == 1) { if (Phase.getGameBegins() == 1) {
if (sa.getSourceCard().isCopiedSpell() && sa.isSpell()) { if (sa.getSourceCard().isCopiedSpell() && sa.isSpell()) {
if (spell.getAfterPayMana() != null) { if (this.spell.getAfterPayMana() != null) {
stopSetNext(spell.getAfterPayMana()); this.stopSetNext(this.spell.getAfterPayMana());
} else { } else {
manaCost = new ManaCost("0"); this.manaCost = new ManaCost("0");
AllZone.getStack().add(spell); AllZone.getStack().add(this.spell);
} }
} else { } else {
manaCost = AllZone.getGameAction().getSpellCostChange(sa, new ManaCost(originalManaCost)); this.manaCost = AllZone.getGameAction().getSpellCostChange(sa, new ManaCost(this.originalManaCost));
} }
} else { } else {
manaCost = new ManaCost(sa.getManaCost()); this.manaCost = new ManaCost(sa.getManaCost());
} }
} }
@@ -108,8 +108,8 @@ public class Input_PayManaCost extends Input {
* </p> * </p>
*/ */
private void resetManaCost() { private void resetManaCost() {
manaCost = new ManaCost(originalManaCost); this.manaCost = new ManaCost(this.originalManaCost);
phyLifeToLose = 0; this.phyLifeToLose = 0;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@@ -120,22 +120,22 @@ public class Input_PayManaCost extends Input {
// Kher Keep, Pendelhaven, Blinkmoth Nexus, and Mikokoro, Center of the // Kher Keep, Pendelhaven, Blinkmoth Nexus, and Mikokoro, Center of the
// Sea, .... // Sea, ....
if (originalCard.equals(card) && spell.isTapAbility()) { if (this.originalCard.equals(card) && this.spell.isTapAbility()) {
// I'm not sure if this actually prevents anything that wouldn't be // I'm not sure if this actually prevents anything that wouldn't be
// handled by canPlay below // handled by canPlay below
return; return;
} }
manaCost = Input_PayManaCostUtil.activateManaAbility(spell, card, manaCost); this.manaCost = Input_PayManaCostUtil.activateManaAbility(this.spell, card, this.manaCost);
// only show message if this is the active input // only show message if this is the active input
if (AllZone.getInputControl().getInput() == this) { if (AllZone.getInputControl().getInput() == this) {
showMessage(); this.showMessage();
} }
if (manaCost.isPaid()) { if (this.manaCost.isPaid()) {
originalCard.setSunburstValue(manaCost.getSunburst()); this.originalCard.setSunburstValue(this.manaCost.getSunburst());
done(); this.done();
} }
} }
@@ -144,11 +144,11 @@ public class Input_PayManaCost extends Input {
public final void selectPlayer(final Player player) { public final void selectPlayer(final Player player) {
if (player.isHuman()) { if (player.isHuman()) {
if (manaCost.payPhyrexian()) { if (this.manaCost.payPhyrexian()) {
phyLifeToLose += 2; this.phyLifeToLose += 2;
} }
showMessage(); this.showMessage();
} }
} }
@@ -159,40 +159,40 @@ public class Input_PayManaCost extends Input {
* </p> * </p>
*/ */
private void done() { private void done() {
if (phyLifeToLose > 0) { if (this.phyLifeToLose > 0) {
AllZone.getHumanPlayer().payLife(phyLifeToLose, originalCard); AllZone.getHumanPlayer().payLife(this.phyLifeToLose, this.originalCard);
} }
if (spell.getSourceCard().isCopiedSpell()) { if (this.spell.getSourceCard().isCopiedSpell()) {
if (spell.getAfterPayMana() != null) { if (this.spell.getAfterPayMana() != null) {
stopSetNext(spell.getAfterPayMana()); this.stopSetNext(this.spell.getAfterPayMana());
} else { } else {
AllZone.getInputControl().resetInput(); AllZone.getInputControl().resetInput();
} }
} else { } else {
AllZone.getHumanPlayer().getManaPool().clearPay(spell, false); AllZone.getHumanPlayer().getManaPool().clearPay(this.spell, false);
resetManaCost(); this.resetManaCost();
// if tap ability, tap card // if tap ability, tap card
if (spell.isTapAbility()) { if (this.spell.isTapAbility()) {
originalCard.tap(); this.originalCard.tap();
} }
if (spell.isUntapAbility()) { if (this.spell.isUntapAbility()) {
originalCard.untap(); this.originalCard.untap();
} }
// if this is a spell, move it to the Stack ZOne // if this is a spell, move it to the Stack ZOne
if (spell.isSpell()) { if (this.spell.isSpell()) {
spell.setSourceCard(AllZone.getGameAction().moveToStack(originalCard)); this.spell.setSourceCard(AllZone.getGameAction().moveToStack(this.originalCard));
} }
if (spell.getAfterPayMana() != null) { if (this.spell.getAfterPayMana() != null) {
stopSetNext(spell.getAfterPayMana()); this.stopSetNext(this.spell.getAfterPayMana());
} else { } else {
if (skipStack) { if (this.skipStack) {
spell.resolve(); this.spell.resolve();
} else { } else {
AllZone.getStack().add(spell); AllZone.getStack().add(this.spell);
} }
AllZone.getInputControl().resetInput(); AllZone.getInputControl().resetInput();
} }
@@ -202,20 +202,20 @@ public class Input_PayManaCost extends Input {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final void selectButtonCancel() { public final void selectButtonCancel() {
resetManaCost(); this.resetManaCost();
AllZone.getHumanPlayer().getManaPool().unpaid(spell, true); AllZone.getHumanPlayer().getManaPool().unpaid(this.spell, true);
AllZone.getHumanPlayer().getZone(Zone.Battlefield).updateObservers(); // DO AllZone.getHumanPlayer().getZone(Zone.Battlefield).updateObservers(); // DO
// NOT // NOT
// REMOVE // REMOVE
// THIS, // THIS,
// otherwise // otherwise
// the // the
// cards // cards
// don't // don't
// always // always
// tap // tap
stop(); this.stop();
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@@ -223,21 +223,21 @@ public class Input_PayManaCost extends Input {
public final void showMessage() { public final void showMessage() {
ButtonUtil.enableOnlyCancel(); ButtonUtil.enableOnlyCancel();
StringBuilder msg = new StringBuilder("Pay Mana Cost: " + manaCost.toString()); final StringBuilder msg = new StringBuilder("Pay Mana Cost: " + this.manaCost.toString());
if (phyLifeToLose > 0) { if (this.phyLifeToLose > 0) {
msg.append(" ("); msg.append(" (");
msg.append(phyLifeToLose); msg.append(this.phyLifeToLose);
msg.append(" life paid for phyrexian mana)"); msg.append(" life paid for phyrexian mana)");
} }
if (manaCost.containsPhyrexianMana()) { if (this.manaCost.containsPhyrexianMana()) {
msg.append("\n(Click on your life total to pay life for phyrexian mana.)"); msg.append("\n(Click on your life total to pay life for phyrexian mana.)");
} }
AllZone.getDisplay().showMessage(msg.toString()); AllZone.getDisplay().showMessage(msg.toString());
if (manaCost.isPaid() && !new ManaCost(originalManaCost).isPaid()) { if (this.manaCost.isPaid() && !new ManaCost(this.originalManaCost).isPaid()) {
originalCard.setSunburstValue(manaCost.getSunburst()); this.originalCard.setSunburstValue(this.manaCost.getSunburst());
done(); this.done();
} }
} }

View File

@@ -51,28 +51,29 @@ public class Input_PayManaCostUtil {
return ((ManaPool) card).subtractMana(sa, manaCost); return ((ManaPool) card).subtractMana(sa, manaCost);
} }
ArrayList<Ability_Mana> abilities = getManaAbilities(card); ArrayList<Ability_Mana> abilities = Input_PayManaCostUtil.getManaAbilities(card);
StringBuilder cneeded = new StringBuilder(); final StringBuilder cneeded = new StringBuilder();
boolean choice = true; boolean choice = true;
boolean skipExpress = false; boolean skipExpress = false;
for (String color : Constant.Color.MANA_COLORS) { for (final String color : Constant.Color.MANA_COLORS) {
if (manaCost.isNeeded(color)) { if (manaCost.isNeeded(color)) {
cneeded.append(getShortColorString(color)); cneeded.append(Input_PayManaCostUtil.getShortColorString(color));
} }
} }
Iterator<Ability_Mana> it = abilities.iterator(); // you can't remove final Iterator<Ability_Mana> it = abilities.iterator(); // you can't
// unneeded abilities // remove
// inside a // unneeded abilities
// for(am:abilities) // inside a
// loop :( // for(am:abilities)
// loop :(
while (it.hasNext()) { while (it.hasNext()) {
Ability_Mana ma = it.next(); final Ability_Mana ma = it.next();
ma.setActivatingPlayer(AllZone.getHumanPlayer()); ma.setActivatingPlayer(AllZone.getHumanPlayer());
if (!ma.canPlay()) { if (!ma.canPlay()) {
it.remove(); it.remove();
} else if (!canMake(ma, cneeded.toString())) { } else if (!Input_PayManaCostUtil.canMake(ma, cneeded.toString())) {
it.remove(); it.remove();
} }
@@ -95,21 +96,21 @@ public class Input_PayManaCostUtil {
if (!skipExpress) { if (!skipExpress) {
// express Mana Choice // express Mana Choice
ArrayList<Ability_Mana> colorMatches = new ArrayList<Ability_Mana>(); final ArrayList<Ability_Mana> colorMatches = new ArrayList<Ability_Mana>();
for (Ability_Mana am : abilities) { for (final Ability_Mana am : abilities) {
if (am.isReflectedMana()) { if (am.isReflectedMana()) {
ArrayList<String> reflectableColors = AbilityFactory_Mana.reflectableMana(am, final ArrayList<String> reflectableColors = AbilityFactory_Mana.reflectableMana(am,
am.getAbilityFactory(), new ArrayList<String>(), new ArrayList<Card>()); am.getAbilityFactory(), new ArrayList<String>(), new ArrayList<Card>());
for (String color : reflectableColors) { for (final String color : reflectableColors) {
if (manaCost.isColor(color)) { if (manaCost.isColor(color)) {
// checking if color // checking if color
colorMatches.add(am); colorMatches.add(am);
} }
} }
} else { } else {
String[] m = ManaPool.formatMana(am); final String[] m = ManaPool.formatMana(am);
for (String color : m) { for (final String color : m) {
if (manaCost.isColor(color)) { if (manaCost.isColor(color)) {
// checking if color // checking if color
colorMatches.add(am); colorMatches.add(am);
@@ -118,7 +119,7 @@ public class Input_PayManaCostUtil {
} }
} }
if (colorMatches.size() == 0 || colorMatches.size() == abilities.size()) { if ((colorMatches.size() == 0) || (colorMatches.size() == abilities.size())) {
// can only match colorless just grab the first and move on. // can only match colorless just grab the first and move on.
choice = false; choice = false;
} else if (colorMatches.size() < abilities.size()) { } else if (colorMatches.size() < abilities.size()) {
@@ -128,9 +129,9 @@ public class Input_PayManaCostUtil {
} }
Ability_Mana chosen = abilities.get(0); Ability_Mana chosen = abilities.get(0);
if (1 < abilities.size() && choice) { if ((1 < abilities.size()) && choice) {
HashMap<String, Ability_Mana> ability = new HashMap<String, Ability_Mana>(); final HashMap<String, Ability_Mana> ability = new HashMap<String, Ability_Mana>();
for (Ability_Mana am : abilities) { for (final Ability_Mana am : abilities) {
ability.put(am.toString(), am); ability.put(am.toString(), am);
} }
chosen = (Ability_Mana) GuiUtils.getChoice("Choose mana ability", abilities.toArray()); chosen = (Ability_Mana) GuiUtils.getChoice("Choose mana ability", abilities.toArray());
@@ -180,15 +181,15 @@ public class Input_PayManaCostUtil {
} }
if (am.isReflectedMana()) { if (am.isReflectedMana()) {
ArrayList<String> reflectableColors = AbilityFactory_Mana.reflectableMana(am, am.getAbilityFactory(), final ArrayList<String> reflectableColors = AbilityFactory_Mana.reflectableMana(am, am.getAbilityFactory(),
new ArrayList<String>(), new ArrayList<Card>()); new ArrayList<String>(), new ArrayList<Card>());
for (String color : reflectableColors) { for (final String color : reflectableColors) {
if (mana.contains(getShortColorString(color))) { if (mana.contains(Input_PayManaCostUtil.getShortColorString(color))) {
return true; return true;
} }
} }
} else { } else {
for (String color : ManaPool.formatMana(am)) { for (final String color : ManaPool.formatMana(am)) {
if (mana.contains(color)) { if (mana.contains(color)) {
return true; return true;
} }
@@ -207,7 +208,7 @@ public class Input_PayManaCostUtil {
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
public static String getLongColorString(final String color) { public static String getLongColorString(final String color) {
Map<String, String> m = new HashMap<String, String>(); final Map<String, String> m = new HashMap<String, String>();
m.put("G", Constant.Color.GREEN); m.put("G", Constant.Color.GREEN);
m.put("R", Constant.Color.RED); m.put("R", Constant.Color.RED);
m.put("U", Constant.Color.BLUE); m.put("U", Constant.Color.BLUE);
@@ -234,7 +235,7 @@ public class Input_PayManaCostUtil {
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
public static String getShortColorString(final String color) { public static String getShortColorString(final String color) {
Map<String, String> m = new HashMap<String, String>(); final Map<String, String> m = new HashMap<String, String>();
m.put(Constant.Color.GREEN, "G"); m.put(Constant.Color.GREEN, "G");
m.put(Constant.Color.RED, "R"); m.put(Constant.Color.RED, "R");
m.put(Constant.Color.BLUE, "U"); m.put(Constant.Color.BLUE, "U");
@@ -243,7 +244,7 @@ public class Input_PayManaCostUtil {
m.put(Constant.Color.COLORLESS, "1"); m.put(Constant.Color.COLORLESS, "1");
m.put(Constant.Color.SNOW, "S"); m.put(Constant.Color.SNOW, "S");
Object o = m.get(color); final Object o = m.get(color);
return o.toString(); return o.toString();
} }

View File

@@ -54,16 +54,15 @@ public class Input_PayManaCost_Ability extends Input {
* Constructor for Input_PayManaCost_Ability. * Constructor for Input_PayManaCost_Ability.
* </p> * </p>
* *
* @param manaCost_2 * @param manaCost2
* a {@link java.lang.String} object. * a {@link java.lang.String} object.
* @param paidCommand_2 * @param paidCommand2
* a {@link forge.Command} object. * a {@link forge.Command} object.
* @param unpaidCommand_2 * @param unpaidCommand2
* a {@link forge.Command} object. * a {@link forge.Command} object.
*/ */
public Input_PayManaCost_Ability(final String manaCost_2, public Input_PayManaCost_Ability(final String manaCost2, final Command paidCommand2, final Command unpaidCommand2) {
final Command paidCommand_2, final Command unpaidCommand_2) { this("", manaCost2, paidCommand2, unpaidCommand2);
this("", manaCost_2, paidCommand_2, unpaidCommand_2);
} }
/** /**
@@ -73,16 +72,16 @@ public class Input_PayManaCost_Ability extends Input {
* *
* @param m * @param m
* a {@link java.lang.String} object. * a {@link java.lang.String} object.
* @param manaCost_2 * @param manaCost2
* a {@link java.lang.String} object. * a {@link java.lang.String} object.
* @param paidCommand_2 * @param paidCommand2
* a {@link forge.Command} object. * a {@link forge.Command} object.
* @param unpaidCommand_2 * @param unpaidCommand2
* a {@link forge.Command} object. * a {@link forge.Command} object.
*/ */
public Input_PayManaCost_Ability(final String m, final String manaCost_2, public Input_PayManaCost_Ability(final String m, final String manaCost2, final Command paidCommand2,
final Command paidCommand_2, final Command unpaidCommand_2) { final Command unpaidCommand2) {
this(m, manaCost_2, paidCommand_2, unpaidCommand_2, false); this(m, manaCost2, paidCommand2, unpaidCommand2, false);
} }
/** /**
@@ -92,19 +91,18 @@ public class Input_PayManaCost_Ability extends Input {
* *
* @param m * @param m
* a {@link java.lang.String} object. * a {@link java.lang.String} object.
* @param manaCost_2 * @param manaCost2
* a {@link java.lang.String} object. * a {@link java.lang.String} object.
* @param paidCommand_2 * @param paidCommand2
* a {@link forge.Command} object. * a {@link forge.Command} object.
* @param unpaidCommand_2 * @param unpaidCommand2
* a {@link forge.Command} object. * a {@link forge.Command} object.
* @param showOKButton * @param showOKButton
* a boolean. * a boolean.
*/ */
public Input_PayManaCost_Ability(final String m, final String manaCost_2, public Input_PayManaCost_Ability(final String m, final String manaCost2, final Command paidCommand2,
final Command paidCommand_2, final Command unpaidCommand_2, final Command unpaidCommand2, final boolean showOKButton) {
final boolean showOKButton) { this.fakeAbility = new SpellAbility(SpellAbility.getAbility(), null) {
fakeAbility = new SpellAbility(SpellAbility.getAbility(), null) {
@Override @Override
public void resolve() { public void resolve() {
} }
@@ -114,13 +112,13 @@ public class Input_PayManaCost_Ability extends Input {
return false; return false;
} }
}; };
originalManaCost = manaCost_2; this.originalManaCost = manaCost2;
message = m; this.message = m;
manaCost = new ManaCost(originalManaCost); this.manaCost = new ManaCost(this.originalManaCost);
paidCommand = paidCommand_2; this.paidCommand = paidCommand2;
unpaidCommand = unpaidCommand_2; this.unpaidCommand = unpaidCommand2;
showOnlyOKButton = showOKButton; this.showOnlyOKButton = showOKButton;
} }
/** /**
@@ -129,40 +127,40 @@ public class Input_PayManaCost_Ability extends Input {
* </p> * </p>
*/ */
public final void resetManaCost() { public final void resetManaCost() {
manaCost = new ManaCost(originalManaCost); this.manaCost = new ManaCost(this.originalManaCost);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final void selectCard(final Card card, final PlayerZone zone) { public final void selectCard(final Card card, final PlayerZone zone) {
// only tap card if the mana is needed // only tap card if the mana is needed
manaCost = Input_PayManaCostUtil.activateManaAbility(fakeAbility, card, manaCost); this.manaCost = Input_PayManaCostUtil.activateManaAbility(this.fakeAbility, card, this.manaCost);
if (manaCost.isPaid()) { if (this.manaCost.isPaid()) {
resetManaCost(); this.resetManaCost();
AllZone.getHumanPlayer().getManaPool().clearPay(fakeAbility, false); AllZone.getHumanPlayer().getManaPool().clearPay(this.fakeAbility, false);
stop(); this.stop();
paidCommand.execute(); this.paidCommand.execute();
} else { } else {
showMessage(); this.showMessage();
} }
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final void selectButtonCancel() { public final void selectButtonCancel() {
resetManaCost(); this.resetManaCost();
AllZone.getHumanPlayer().getManaPool().unpaid(fakeAbility, true); AllZone.getHumanPlayer().getManaPool().unpaid(this.fakeAbility, true);
stop(); this.stop();
unpaidCommand.execute(); this.unpaidCommand.execute();
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final void selectButtonOK() { public final void selectButtonOK() {
if (showOnlyOKButton) { if (this.showOnlyOKButton) {
stop(); this.stop();
unpaidCommand.execute(); this.unpaidCommand.execute();
} }
} }
@@ -170,10 +168,10 @@ public class Input_PayManaCost_Ability extends Input {
@Override @Override
public final void showMessage() { public final void showMessage() {
ButtonUtil.enableOnlyCancel(); ButtonUtil.enableOnlyCancel();
if (showOnlyOKButton) { if (this.showOnlyOKButton) {
ButtonUtil.enableOnlyOK(); ButtonUtil.enableOnlyOK();
} }
AllZone.getDisplay().showMessage(message + "Pay Mana Cost: \r\n" + manaCost.toString()); AllZone.getDisplay().showMessage(this.message + "Pay Mana Cost: \r\n" + this.manaCost.toString());
} }
} }

View File

@@ -1,2 +1,3 @@
/** Forge Card Game. */ /** Forge Card Game. */
package forge.gui.input; package forge.gui.input;