checkstyle

This commit is contained in:
jendave
2011-10-26 08:29:38 +00:00
parent e033d9045e
commit b65aa3705c
17 changed files with 942 additions and 606 deletions

1
.gitattributes vendored
View File

@@ -10474,6 +10474,7 @@ src/main/java/forge/gui/skin/FButton.java -text
src/main/java/forge/gui/skin/FPanel.java -text src/main/java/forge/gui/skin/FPanel.java -text
src/main/java/forge/gui/skin/FRoundedPanel.java -text src/main/java/forge/gui/skin/FRoundedPanel.java -text
src/main/java/forge/gui/skin/FSkin.java -text src/main/java/forge/gui/skin/FSkin.java -text
src/main/java/forge/gui/skin/package-info.java svneol=native#text/plain
src/main/java/forge/item/BoosterPack.java -text src/main/java/forge/item/BoosterPack.java -text
src/main/java/forge/item/CardDb.java -text src/main/java/forge/item/CardDb.java -text
src/main/java/forge/item/CardPrinted.java -text src/main/java/forge/item/CardPrinted.java -text

View File

@@ -5,61 +5,78 @@ import forge.Card;
import forge.Player; import forge.Player;
import forge.PlayerZone; import forge.PlayerZone;
/** /**
* <p>Abstract Input class.</p> * <p>
* Abstract Input class.
* </p>
* *
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
*/ */
public abstract class Input implements java.io.Serializable { public abstract class Input implements java.io.Serializable {
/** Constant <code>serialVersionUID=-6539552513871194081L</code> */ /** Constant <code>serialVersionUID=-6539552513871194081L</code>. */
private static final long serialVersionUID = -6539552513871194081L; private static final long serialVersionUID = -6539552513871194081L;
private boolean isFree = false; private boolean isFree = false;
// showMessage() is always the first method called // showMessage() is always the first method called
/** /**
* <p>showMessage.</p> * <p>
* showMessage.
* </p>
*/ */
public void showMessage() { public void showMessage() {
AllZone.getDisplay().showMessage("Blank Input"); AllZone.getDisplay().showMessage("Blank Input");
} }
/** /**
* <p>selectCard.</p> * <p>
* selectCard.
* </p>
* *
* @param c a {@link forge.Card} object. * @param c
* @param zone a {@link forge.PlayerZone} object. * a {@link forge.Card} object.
* @param zone
* a {@link forge.PlayerZone} object.
*/ */
public void selectCard(Card c, PlayerZone zone) { public void selectCard(final Card c, final PlayerZone zone) {
} }
/** /**
* <p>selectPlayer.</p> * <p>
* selectPlayer.
* </p>
* *
* @param player a {@link forge.Player} object. * @param player
* a {@link forge.Player} object.
*/ */
public void selectPlayer(final Player player) { public void selectPlayer(final Player player) {
} }
/** /**
* <p>selectButtonOK.</p> * <p>
* selectButtonOK.
* </p>
*/ */
public void selectButtonOK() { public void selectButtonOK() {
} }
/** /**
* <p>selectButtonCancel.</p> * <p>
* selectButtonCancel.
* </p>
*/ */
public void selectButtonCancel() { public void selectButtonCancel() {
} }
// helper methods, since they are used alot // helper methods, since they are used alot
// to be used by anything in CardFactory like SetTargetInput // to be used by anything in CardFactory like SetTargetInput
//NOT TO BE USED by Input_Main or any of the "regular" Inputs objects that are not set using AllZone.getInputControl().setInput(Input) // NOT TO BE USED by Input_Main or any of the "regular" Inputs objects that
// are not set using AllZone.getInputControl().setInput(Input)
/** /**
* <p>stop.</p> * <p>
* stop.
* </p>
*/ */
final public void stop() { final public void stop() {
// clears a "temp" Input like Input_PayManaCost if there is one // clears a "temp" Input like Input_PayManaCost if there is one
@@ -74,9 +91,12 @@ public abstract class Input implements java.io.Serializable {
// exits the "current" Input and sets the next Input // exits the "current" Input and sets the next Input
/** /**
* <p>stopSetNext.</p> * <p>
* stopSetNext.
* </p>
* *
* @param in a {@link forge.gui.input.Input} object. * @param in
* a {@link forge.gui.input.Input} object.
*/ */
final public void stopSetNext(Input in) { final public void stopSetNext(Input in) {
stop(); stop();
@@ -90,16 +110,21 @@ public abstract class Input implements java.io.Serializable {
}// returns the Input name like "EmptyStack" }// returns the Input name like "EmptyStack"
/** /**
* <p>setFree.</p> * <p>
* setFree.
* </p>
* *
* @param isFree a boolean. * @param isFree
* a boolean.
*/ */
public void setFree(boolean isFree) { public void setFree(boolean isFree) {
this.isFree = isFree; this.isFree = isFree;
} }
/** /**
* <p>isFree.</p> * <p>
* isFree.
* </p>
* *
* @return a boolean. * @return a boolean.
*/ */

View File

@@ -1,6 +1,5 @@
package forge.gui.input; package forge.gui.input;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Stack; import java.util.Stack;
@@ -12,53 +11,67 @@ import forge.Player;
import forge.model.FModel; import forge.model.FModel;
/** /**
* <p>InputControl class.</p> * <p>
* InputControl class.
* </p>
* *
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
*/ */
public class InputControl extends MyObservable implements java.io.Serializable { public class InputControl extends MyObservable implements java.io.Serializable {
/** Constant <code>serialVersionUID=3955194449319994301L</code> */ /** Constant <code>serialVersionUID=3955194449319994301L</code>. */
private static final long serialVersionUID = 3955194449319994301L; private static final long serialVersionUID = 3955194449319994301L;
private Input input; private Input input;
/** Constant <code>n=0</code> */
/** Constant <code>n=0</code>. */
static int n = 0; static int n = 0;
private Stack<Input> inputStack = new Stack<Input>(); private Stack<Input> inputStack = new Stack<Input>();
private Stack<Input> resolvingStack = new Stack<Input>(); private Stack<Input> resolvingStack = new Stack<Input>();
private LinkedList<Input> resolvingQueue = new LinkedList<Input>(); private 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 object created private ComputerAI_Input aiInput; // initialized at runtime to be the latest
// object created
/** /**
* TODO: Write javadoc for Constructor. * TODO Write javadoc for Constructor.
* @param model *
* @param fModel
* the f model
*/ */
public InputControl(FModel fModel) { public InputControl(final FModel fModel) {
model = fModel; model = fModel;
} }
/** /**
* <p>Setter for the field <code>input</code>.</p> * <p>
* Setter for the field <code>input</code>.
* </p>
* *
* @param in a {@link forge.gui.input.Input} object. * @param in
* a {@link forge.gui.input.Input} object.
*/ */
public void setInput(final Input in) { public final void setInput(final Input in) {
if (model.getGameState().getStack().getResolving() || !(input == null || input instanceof Input_PassPriority)) if (model.getGameState().getStack().getResolving() || !(input == null || input instanceof Input_PassPriority)) {
inputStack.add(in); inputStack.add(in);
else } else {
input = in; input = in;
}
updateObservers(); updateObservers();
} }
/** /**
* <p>Setter for the field <code>input</code>.</p> * <p>
* Setter for the field <code>input</code>.
* </p>
* *
* @param in a {@link forge.gui.input.Input} object. * @param in
* @param bAddToResolving a boolean. * a {@link forge.gui.input.Input} object.
* @param bAddToResolving
* a boolean.
*/ */
public void setInput(final Input in, boolean bAddToResolving) { public final void setInput(final Input in, final boolean bAddToResolving) {
// Make this // Make this
if (!bAddToResolving) { if (!bAddToResolving) {
setInput(in); setInput(in);
@@ -71,9 +84,12 @@ public class InputControl extends MyObservable implements java.io.Serializable {
} }
/** /**
* <p>changeInput.</p> * <p>
* changeInput.
* </p>
* *
* @param in a {@link forge.gui.input.Input} object. * @param in
* a {@link forge.gui.input.Input} object.
*/ */
private void changeInput(final Input in) { private void changeInput(final Input in) {
input = in; input = in;
@@ -81,71 +97,84 @@ public class InputControl extends MyObservable implements java.io.Serializable {
} }
/** /**
* <p>Getter for the field <code>input</code>.</p> * <p>
* Getter for the field <code>input</code>.
* </p>
* *
* @return a {@link forge.gui.input.Input} object. * @return a {@link forge.gui.input.Input} object.
*/ */
public Input getInput() { public final Input getInput() {
return input; return input;
} }
/** /**
* <p>clearInput.</p> * <p>
* clearInput.
* </p>
*/ */
public void clearInput() { public final void clearInput() {
input = null; input = null;
resolvingQueue.clear(); resolvingQueue.clear();
inputStack.clear(); inputStack.clear();
} }
/** /**
* <p>resetInput.</p> * <p>
* resetInput.
* </p>
*/ */
public void resetInput() { public final void resetInput() {
input = null; input = null;
updateObservers(); updateObservers();
} }
/** /**
* <p>resetInput.</p> * <p>
* resetInput.
* </p>
* *
* @param update a boolean. * @param update
* a boolean.
*/ */
public void resetInput(boolean update) { public final void resetInput(final boolean update) {
input = null; input = null;
if (update) if (update) {
updateObservers(); updateObservers();
} }
}
/** /**
* <p>updateInput.</p> * <p>
* updateInput.
* </p>
* *
* @return a {@link forge.gui.input.Input} object. * @return a {@link forge.gui.input.Input} object.
*/ */
public Input updateInput() { public final Input updateInput() {
final String phase = model.getGameState().getPhase().getPhase(); final String phase = model.getGameState().getPhase().getPhase();
final Player playerTurn = model.getGameState().getPhase().getPlayerTurn(); final Player playerTurn = model.getGameState().getPhase().getPlayerTurn();
final Player priority = model.getGameState().getPhase().getPriorityPlayer(); final Player priority = model.getGameState().getPhase().getPriorityPlayer();
// TODO: this resolving portion needs more work, but fixes Death Cloud issues // TODO this resolving portion needs more work, but fixes Death Cloud
// issues
if (resolvingStack.size() > 0) { if (resolvingStack.size() > 0) {
if (input != null) { if (input != null) {
return input; return input;
} }
// if an SA is resolving, only change input for something that is part of the resolving SA // if an SA is resolving, only change input for something that is
// part of the resolving SA
changeInput(resolvingStack.pop()); changeInput(resolvingStack.pop());
return input; return input;
} }
if (model.getGameState().getStack().getResolving()) if (model.getGameState().getStack().getResolving()) {
return null; return null;
}
if (input != null) {
if (input != null)
return input; return input;
} else if (inputStack.size() > 0) { // incoming input to Control
else if (inputStack.size() > 0) { // incoming input to Control
changeInput(inputStack.pop()); changeInput(inputStack.pop());
return input; return input;
} }
@@ -156,16 +185,19 @@ public class InputControl extends MyObservable implements java.io.Serializable {
return updateInput(); return updateInput();
} }
// If the Phase we're in doesn't allow for Priority, return null to move to next phase // If the Phase we're in doesn't allow for Priority, return null to move
if (model.getGameState().getPhase().isNeedToNextPhase()) // to next phase
if (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(); 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(); model.getGameState().getStack().freezeStack();
if (playerTurn.isHuman()) { if (playerTurn.isHuman()) {
@@ -176,33 +208,48 @@ public class InputControl extends MyObservable implements java.io.Serializable {
// no active attackers, skip the Blocking phase // no active attackers, skip the Blocking phase
model.getGameState().getPhase().setNeedToNextPhase(true); model.getGameState().getPhase().setNeedToNextPhase(true);
return null; return null;
} else } else {
return new Input_Block(); return new Input_Block();
} }
} else if (phase.equals(Constant.Phase.Cleanup)) // Player needs to discard }
if (model.getGameState().getStack().size() == 0) // fall through to resolve things like Madness } else if (phase.equals(Constant.Phase.Cleanup)) {
// discard
if (model.getGameState().getStack().size() == 0) {
// resolve things
// like Madness
return new Input_Cleanup(); return new Input_Cleanup();
}
}
// ********************* // *********************
// Special phases handled above, everything else is handled simply by priority // Special phases handled above, everything else is handled simply by
// priority
if (priority.isHuman()) { if (priority.isHuman()) {
boolean skip = model.getGameState().getPhase().doSkipPhase(); boolean skip = model.getGameState().getPhase().doSkipPhase();
model.getGameState().getPhase().setSkipPhase(false); model.getGameState().getPhase().setSkipPhase(false);
if (model.getGameState().getStack().size() == 0 && !forge.AllZone.getDisplay().stopAtPhase(playerTurn, phase) && skip) { if (model.getGameState().getStack().size() == 0
&& !forge.AllZone.getDisplay().stopAtPhase(playerTurn, phase) && skip) {
model.getGameState().getPhase().passPriority(); 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 aiInput;
else { } else {
aiInput.getComputer().stack_not_empty(); aiInput.getComputer().stack_not_empty();
return null; return null;
} }
}// getInput() }// getInput()
public void setComputer(ComputerAI_Input computerAI_Input) { /**
* Sets the computer.
*
* @param computerAI_Input
* the new computer
*/
public final void setComputer(final ComputerAI_Input computerAI_Input) {
aiInput = computerAI_Input; aiInput = computerAI_Input;
} }
}// InputControl }// InputControl

View File

@@ -11,11 +11,10 @@ import forge.Constant.Zone;
import forge.GameActionUtil; import forge.GameActionUtil;
import forge.PlayerZone; import forge.PlayerZone;
/** /**
* <p>Input_Attack class.</p> * <p>
* Input_Attack class.
* </p>
* *
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
@@ -48,8 +47,7 @@ public class Input_Attack extends Input {
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); Card c = possibleAttackers.get(i);
if (c.hasKeyword("CARDNAME attacks each turn if able.") if (c.hasKeyword("CARDNAME attacks each turn if able.") && CombatUtil.canAttack(c, AllZone.getCombat())
&& CombatUtil.canAttack(c, AllZone.getCombat())
&& !c.isAttacking()) && !c.isAttacking())
{ {
AllZone.getCombat().addAttacker(c); AllZone.getCombat().addAttacker(c);
@@ -84,12 +82,21 @@ public class Input_Attack extends Input {
&& CombatUtil.canAttack(card, AllZone.getCombat())) && CombatUtil.canAttack(card, AllZone.getCombat()))
{ {
// TODO add the propaganda code here and remove it in Phase.nextPhase() // TODO add the propaganda code here and remove it in
// Phase.nextPhase()
// if (!CombatUtil.checkPropagandaEffects(card)) // if (!CombatUtil.checkPropagandaEffects(card))
// return; // return;
AllZone.getCombat().addAttacker(card); AllZone.getCombat().addAttacker(card);
AllZone.getHumanPlayer().getZone(Zone.Battlefield).updateObservers(); // just to make sure the attack symbol is marked AllZone.getHumanPlayer().getZone(Zone.Battlefield).updateObservers(); // just
// to
// make
// sure
// the
// attack
// symbol
// is
// 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 (String effect : AllZone.getStaticEffects().getStateBasedMap().keySet()) {
@@ -102,10 +109,14 @@ public class Input_Attack extends Input {
} // selectCard() } // selectCard()
/** /**
* <p>unselectCard.</p> * <p>
* unselectCard.
* </p>
* *
* @param card a {@link forge.Card} object. * @param card
* @param zone a {@link forge.PlayerZone} object. * a {@link forge.Card} object.
* @param zone
* a {@link forge.PlayerZone} object.
*/ */
public void unselectCard(final Card card, final PlayerZone zone) { public void unselectCard(final Card card, final PlayerZone zone) {

View File

@@ -12,9 +12,10 @@ import forge.Constant;
import forge.GameActionUtil; import forge.GameActionUtil;
import forge.PlayerZone; import forge.PlayerZone;
/** /**
* <p>Input_Block class.</p> * <p>
* Input_Block class.
* </p>
* *
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
@@ -27,9 +28,12 @@ public class Input_Block extends Input {
private ArrayList<Card> allBlocking = new ArrayList<Card>(); private ArrayList<Card> allBlocking = new ArrayList<Card>();
/** /**
* <p>removeFromAllBlocking.</p> * <p>
* removeFromAllBlocking.
* </p>
* *
* @param c a {@link forge.Card} object. * @param c
* a {@link forge.Card} object.
*/ */
public final void removeFromAllBlocking(final Card c) { public final void removeFromAllBlocking(final Card c) {
allBlocking.remove(c); allBlocking.remove(c);
@@ -47,28 +51,24 @@ public class Input_Block extends Input {
// could add "Reset Blockers" button // could add "Reset Blockers" button
ButtonUtil.enableOnlyOK(); ButtonUtil.enableOnlyOK();
if (currentAttacker == null) { if (currentAttacker == null) {
/* /*
//Lure * //Lure CardList attackers = new
CardList attackers = new CardList(AllZone.getCombat().getAttackers()); * CardList(AllZone.getCombat().getAttackers()); for(Card
for(Card attacker:attackers) { * attacker:attackers) {
if(attacker.hasKeyword("All creatures able to block CARDNAME do so.")) { * if(attacker.hasKeyword("All creatures able to block CARDNAME do so."
CardList bls = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); * )) { CardList bls =
for(Card bl:bls) { * AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer());
if(CombatUtil.canBlock(attacker, bl, AllZone.getCombat())) { * for(Card bl:bls) { if(CombatUtil.canBlock(attacker, bl,
allBlocking.add(bl); * AllZone.getCombat())) { allBlocking.add(bl);
AllZone.getCombat().addBlocker(attacker, bl); * AllZone.getCombat().addBlocker(attacker, bl); } } } }
} */
}
}
}*/
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(); String attackerName = currentAttacker.isFaceDown() ? "Morph" : currentAttacker.getName();
AllZone.getDisplay().showMessage("Select a creature to block " + attackerName + " (" AllZone.getDisplay().showMessage(
+ currentAttacker.getUniqueNumber() + ") "); "Select a creature to block " + attackerName + " (" + currentAttacker.getUniqueNumber() + ") ");
} }
CombatUtil.showCombat(); CombatUtil.showCombat();
@@ -92,8 +92,7 @@ public class Input_Block extends Input {
if (CardUtil.toList(AllZone.getCombat().getAttackers()).contains(card)) { if (CardUtil.toList(AllZone.getCombat().getAttackers()).contains(card)) {
currentAttacker = card; 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(currentAttacker, card, AllZone.getCombat())) {
{
if (currentAttacker != null && (!allBlocking.contains(card))) { if (currentAttacker != null && (!allBlocking.contains(card))) {
allBlocking.add(card); allBlocking.add(card);
AllZone.getCombat().addBlocker(currentAttacker, card); AllZone.getCombat().addBlocker(currentAttacker, card);

View File

@@ -8,10 +8,10 @@ import forge.Constant;
import forge.Constant.Zone; import forge.Constant.Zone;
import forge.PlayerZone; import forge.PlayerZone;
/** /**
* <p>Input_Cleanup class.</p> * <p>
* Input_Cleanup class.
* </p>
* *
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
@@ -31,7 +31,8 @@ public class Input_Cleanup extends Input {
ButtonUtil.disableAll(); ButtonUtil.disableAll();
int n = AllZone.getHumanPlayer().getCardsIn(Zone.Hand).size(); int n = AllZone.getHumanPlayer().getCardsIn(Zone.Hand).size();
//MUST showMessage() before stop() or it will overwrite the next Input's message // MUST showMessage() before stop() or it will overwrite the next
// Input's message
StringBuffer sb = new StringBuffer(); 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");
@@ -42,7 +43,8 @@ public class Input_Cleanup extends Input {
CombatUtil.removeAllDamage(); CombatUtil.removeAllDamage();
AllZone.getPhase().setNeedToNextPhase(true); AllZone.getPhase().setNeedToNextPhase(true);
AllZone.getPhase().nextPhase(); // TODO keep an eye on this code, see if we can get rid of it. AllZone.getPhase().nextPhase(); // TODO keep an eye on this code,
// see if we can get rid of it.
} }
} }
@@ -57,9 +59,10 @@ public class Input_Cleanup extends Input {
} }
} // selectCard() } // selectCard()
/** /**
* <p>AI_CleanupDiscard.</p> * <p>
* AI_CleanupDiscard.
* </p>
*/ */
public void AI_CleanupDiscard() { public void AI_CleanupDiscard() {
int size = AllZone.getComputerPlayer().getCardsIn(Zone.Hand).size(); int size = AllZone.getComputerPlayer().getCardsIn(Zone.Hand).size();

View File

@@ -19,7 +19,9 @@ import forge.game.GamePlayerRating;
import forge.quest.data.QuestData; import forge.quest.data.QuestData;
/** /**
* <p>Input_Mulligan class.</p> * <p>
* Input_Mulligan class.
* </p>
* *
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
@@ -49,16 +51,25 @@ public class Input_Mulligan extends Input {
/** /**
* *
* TODO Write javadoc for this method. * TODO Write javadoc for this method.
* @param player a Player object *
* @param playerRating a GamePlayerRating object * @param player
* a Player object
* @param playerRating
* a GamePlayerRating object
* @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); CardList hand = player.getCardsIn(Zone.Hand);
for (Card c : hand) { AllZone.getGameAction().moveToLibrary(c); } for (Card c : hand) {
for (int i = 0; i < MAGIC_NUMBER_OF_SHUFFLES; i++) { player.shuffle(); } AllZone.getGameAction().moveToLibrary(c);
}
for (int i = 0; i < MAGIC_NUMBER_OF_SHUFFLES; i++) {
player.shuffle();
}
int newHand = hand.size() - 1; int newHand = hand.size() - 1;
for (int i = 0; i < newHand; i++) { player.drawCard(); } for (int i = 0; i < newHand; i++) {
player.drawCard();
}
playerRating.notifyHasMulliganed(); playerRating.notifyHasMulliganed();
playerRating.notifyOpeningHandSize(newHand); playerRating.notifyOpeningHandSize(newHand);
return newHand; return newHand;
@@ -84,7 +95,9 @@ public class Input_Mulligan extends Input {
} // selectButtonOK() } // selectButtonOK()
/** /**
* <p>end.</p> * <p>
* end.
* </p>
*/ */
final void end() { final void end() {
// Computer mulligan // Computer mulligan
@@ -92,7 +105,8 @@ public class Input_Mulligan extends Input {
GamePlayerRating aiRating = AllZone.getGameInfo().getPlayerRating(aiPlayer.getName()); 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 0 in its hand // Computer mulligans if there are no cards with converted mana cost of
// 0 in its hand
while (aiTakesMulligan) { while (aiTakesMulligan) {
CardList handList = aiPlayer.getCardsIn(Zone.Hand); CardList handList = aiPlayer.getCardsIn(Zone.Hand);
@@ -119,7 +133,8 @@ public class Input_Mulligan extends Input {
SpellAbility effect = af.getAbility(c.getSVar(effName), c); 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 hand, this would be a place to do so. // If we ever let the AI memorize cards in the players
// hand, this would be a place to do so.
AllZone.getGameAction().playSpellAbility_NoStack(effect, false); AllZone.getGameAction().playSpellAbility_NoStack(effect, false);
} }
} }
@@ -146,26 +161,25 @@ public class Input_Mulligan extends Input {
// 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)) {
GameActionUtil.showInfoDialg("Computer reveals " GameActionUtil.showInfoDialg("Computer reveals " + c.getName() + "(" + c.getUniqueNumber()
+ c.getName() + "(" + c.getUniqueNumber() + ")."); + ").");
ComputerUtil.playNoStack(effect); ComputerUtil.playNoStack(effect);
} }
} }
} }
} }
if (c.getName().startsWith("Leyline") && !(c.getName().startsWith("Leyline of Singularity") if (c.getName().startsWith("Leyline")
&& AllZoneUtil.getCardsIn(Zone.Battlefield, "Leyline of Singularity").size() > 0)) && !(c.getName().startsWith("Leyline of Singularity") && AllZoneUtil.getCardsIn(Zone.Battlefield,
{ "Leyline of Singularity").size() > 0)) {
AllZone.getGameAction().moveToPlay(c); AllZone.getGameAction().moveToPlay(c);
AllZone.getGameAction().checkStateEffects(); AllZone.getGameAction().checkStateEffects();
} }
} }
AllZone.getGameAction().checkStateEffects(); AllZone.getGameAction().checkStateEffects();
if (AllZone.getGameAction().isStartCut()
if (AllZone.getGameAction().isStartCut() && !(humanOpeningHand.contains(AllZone.getGameAction().getHumanCut()) && !(humanOpeningHand.contains(AllZone.getGameAction().getHumanCut()) || aiOpeningHand.contains(AllZone
|| aiOpeningHand.contains(AllZone.getGameAction().getComputerCut()))) .getGameAction().getComputerCut()))) {
{
AllZone.getGameAction().moveTo(AllZone.getHumanPlayer().getZone(Constant.Zone.Library), AllZone.getGameAction().moveTo(AllZone.getHumanPlayer().getZone(Constant.Zone.Library),
AllZone.getGameAction().getHumanCut()); AllZone.getGameAction().getHumanCut());
AllZone.getGameAction().moveTo(AllZone.getComputerPlayer().getZone(Constant.Zone.Library), AllZone.getGameAction().moveTo(AllZone.getComputerPlayer().getZone(Constant.Zone.Library),

View File

@@ -1,20 +1,27 @@
package forge.gui.input; package forge.gui.input;
import forge.*; import forge.AllZone;
import forge.ButtonUtil;
import forge.Card;
import forge.GuiDisplayUtil;
import forge.Player;
import forge.PlayerZone;
/** /**
* <p>Input_PassPriority class.</p> * <p>
* Input_PassPriority class.
* </p>
* *
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
*/ */
public class Input_PassPriority extends Input implements java.io.Serializable { public class Input_PassPriority extends Input implements java.io.Serializable {
/** Constant <code>serialVersionUID=-581477682214137181L</code> */ /** Constant <code>serialVersionUID=-581477682214137181L</code>. */
private static final long serialVersionUID = -581477682214137181L; private static final long serialVersionUID = -581477682214137181L;
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void showMessage() { public final void showMessage() {
GuiDisplayUtil.updateGUI(); GuiDisplayUtil.updateGUI();
ButtonUtil.enableOnlyOK(); ButtonUtil.enableOnlyOK();
@@ -30,10 +37,11 @@ public class Input_PassPriority extends Input implements java.io.Serializable {
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");
sb.append("Stack: "); sb.append("Stack: ");
if (AllZone.getStack().size() != 0) if (AllZone.getStack().size() != 0) {
sb.append(AllZone.getStack().size()).append(" to Resolve."); sb.append(AllZone.getStack().size()).append(" to Resolve.");
else } else {
sb.append("Empty"); sb.append("Empty");
}
sb.append("\n"); sb.append("\n");
sb.append("Priority: ").append(player); sb.append("Priority: ").append(player);
@@ -42,19 +50,21 @@ public class Input_PassPriority extends Input implements java.io.Serializable {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void selectButtonOK() { public final void selectButtonOK() {
AllZone.getPhase().passPriority(); AllZone.getPhase().passPriority();
GuiDisplayUtil.updateGUI(); GuiDisplayUtil.updateGUI();
Input in = AllZone.getInputControl().getInput(); 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
} }
}
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void selectCard(Card card, PlayerZone zone) { public final void selectCard(final Card card, final PlayerZone zone) {
if (AllZone.getGameAction().playCard(card)) if (AllZone.getGameAction().playCard(card)) {
AllZone.getPhase().setPriority(AllZone.getHumanPlayer()); AllZone.getPhase().setPriority(AllZone.getHumanPlayer());
}
} // selectCard() } // selectCard()
} }

View File

@@ -1,7 +1,12 @@
package forge.gui.input; package forge.gui.input;
import forge.*; import forge.AllZone;
import forge.ButtonUtil;
import forge.Card;
import forge.Constant.Zone; import forge.Constant.Zone;
import forge.Phase;
import forge.Player;
import forge.PlayerZone;
import forge.card.mana.ManaCost; import forge.card.mana.ManaCost;
import forge.card.spellability.SpellAbility; import forge.card.spellability.SpellAbility;
@@ -9,19 +14,23 @@ import forge.card.spellability.SpellAbility;
//the card is removed from the players hand if the cost is paid //the card is removed from the players hand if the cost is paid
//CANNOT be used for ABILITIES //CANNOT be used for ABILITIES
/** /**
* <p>Input_PayManaCost class.</p> * <p>
* Input_PayManaCost class.
* </p>
* *
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
*/ */
public class Input_PayManaCost extends Input { public class Input_PayManaCost extends Input {
// anything that uses this should be converted to Ability_Cost // anything that uses this should be converted to Ability_Cost
/** Constant <code>serialVersionUID=3467312982164195091L</code> */ /** Constant <code>serialVersionUID=3467312982164195091L</code>. */
private static final long serialVersionUID = 3467312982164195091L; private static final long serialVersionUID = 3467312982164195091L;
private final String originalManaCost; private final String originalManaCost;
private final Card originalCard; private final Card originalCard;
/** The mana cost. */
public ManaCost manaCost; public ManaCost manaCost;
private final SpellAbility spell; private final SpellAbility spell;
@@ -31,12 +40,16 @@ public class Input_PayManaCost extends Input {
private int phyLifeToLose = 0; private int phyLifeToLose = 0;
/** /**
* <p>Constructor for Input_PayManaCost.</p> * <p>
* Constructor for Input_PayManaCost.
* </p>
* *
* @param sa a {@link forge.card.spellability.SpellAbility} object. * @param sa
* @param noStack a boolean. * a {@link forge.card.spellability.SpellAbility} object.
* @param noStack
* a boolean.
*/ */
public Input_PayManaCost(SpellAbility sa, boolean noStack) { public Input_PayManaCost(final SpellAbility sa, final boolean noStack) {
skipStack = noStack; skipStack = noStack;
originalManaCost = sa.getManaCost(); // Change originalManaCost = sa.getManaCost(); // Change
originalCard = sa.getSourceCard(); originalCard = sa.getSourceCard();
@@ -45,8 +58,9 @@ public class Input_PayManaCost extends Input {
if (Phase.getGameBegins() == 1) { if (Phase.getGameBegins() == 1) {
if (sa.getSourceCard().isCopiedSpell() && sa.isSpell()) { if (sa.getSourceCard().isCopiedSpell() && sa.isSpell()) {
if (spell.getAfterPayMana() != null) stopSetNext(spell.getAfterPayMana()); if (spell.getAfterPayMana() != null) {
else { stopSetNext(spell.getAfterPayMana());
} else {
manaCost = new ManaCost("0"); manaCost = new ManaCost("0");
AllZone.getStack().add(spell); AllZone.getStack().add(spell);
} }
@@ -59,11 +73,14 @@ public class Input_PayManaCost extends Input {
} }
/** /**
* <p>Constructor for Input_PayManaCost.</p> * <p>
* Constructor for Input_PayManaCost.
* </p>
* *
* @param sa a {@link forge.card.spellability.SpellAbility} object. * @param sa
* a {@link forge.card.spellability.SpellAbility} object.
*/ */
public Input_PayManaCost(SpellAbility sa) { public Input_PayManaCost(final SpellAbility sa) {
originalManaCost = sa.getManaCost(); // Change originalManaCost = sa.getManaCost(); // Change
originalCard = sa.getSourceCard(); originalCard = sa.getSourceCard();
@@ -71,8 +88,9 @@ public class Input_PayManaCost extends Input {
if (Phase.getGameBegins() == 1) { if (Phase.getGameBegins() == 1) {
if (sa.getSourceCard().isCopiedSpell() && sa.isSpell()) { if (sa.getSourceCard().isCopiedSpell() && sa.isSpell()) {
if (spell.getAfterPayMana() != null) stopSetNext(spell.getAfterPayMana()); if (spell.getAfterPayMana() != null) {
else { stopSetNext(spell.getAfterPayMana());
} else {
manaCost = new ManaCost("0"); manaCost = new ManaCost("0");
AllZone.getStack().add(spell); AllZone.getStack().add(spell);
} }
@@ -85,7 +103,9 @@ public class Input_PayManaCost extends Input {
} }
/** /**
* <p>resetManaCost.</p> * <p>
* resetManaCost.
* </p>
*/ */
private void resetManaCost() { private void resetManaCost() {
manaCost = new ManaCost(originalManaCost); manaCost = new ManaCost(originalManaCost);
@@ -94,20 +114,24 @@ public class Input_PayManaCost extends Input {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void selectCard(Card card, PlayerZone zone) { public final void selectCard(final Card card, final PlayerZone zone) {
//this is a hack, to prevent lands being able to use mana to pay their own abilities from cards like // this is a hack, to prevent lands being able to use mana to pay their
//Kher Keep, Pendelhaven, Blinkmoth Nexus, and Mikokoro, Center of the Sea, .... // own abilities from cards like
// Kher Keep, Pendelhaven, Blinkmoth Nexus, and Mikokoro, Center of the
// Sea, ....
if (originalCard.equals(card) && spell.isTapAbility()) { if (originalCard.equals(card) && spell.isTapAbility()) {
// I'm not sure if this actually prevents anything that wouldn't be handled by canPlay below // I'm not sure if this actually prevents anything that wouldn't be
// handled by canPlay below
return; return;
} }
manaCost = Input_PayManaCostUtil.activateManaAbility(spell, card, manaCost); manaCost = Input_PayManaCostUtil.activateManaAbility(spell, card, 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(); showMessage();
}
if (manaCost.isPaid()) { if (manaCost.isPaid()) {
originalCard.setSunburstValue(manaCost.getSunburst()); originalCard.setSunburstValue(manaCost.getSunburst());
@@ -117,7 +141,7 @@ public class Input_PayManaCost extends Input {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void selectPlayer(Player player) { public final void selectPlayer(final Player player) {
if (player.isHuman()) { if (player.isHuman()) {
if (manaCost.payPhyrexian()) { if (manaCost.payPhyrexian()) {
@@ -130,34 +154,41 @@ public class Input_PayManaCost extends Input {
} }
/** /**
* <p>done.</p> * <p>
* done.
* </p>
*/ */
private void done() { private void done() {
if (phyLifeToLose > 0) if (phyLifeToLose > 0) {
AllZone.getHumanPlayer().payLife(phyLifeToLose, originalCard); AllZone.getHumanPlayer().payLife(phyLifeToLose, originalCard);
}
if (spell.getSourceCard().isCopiedSpell()) { if (spell.getSourceCard().isCopiedSpell()) {
if (spell.getAfterPayMana() != null) { if (spell.getAfterPayMana() != null) {
stopSetNext(spell.getAfterPayMana()); stopSetNext(spell.getAfterPayMana());
} else } else {
AllZone.getInputControl().resetInput(); AllZone.getInputControl().resetInput();
}
} else { } else {
AllZone.getHumanPlayer().getManaPool().clearPay(spell, false); AllZone.getHumanPlayer().getManaPool().clearPay(spell, false);
resetManaCost(); resetManaCost();
// if tap ability, tap card // if tap ability, tap card
if (spell.isTapAbility()) if (spell.isTapAbility()) {
originalCard.tap(); originalCard.tap();
if (spell.isUntapAbility()) }
if (spell.isUntapAbility()) {
originalCard.untap(); 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()) // already checked for if its a copy if (spell.isSpell()) {
AllZone.getGameAction().moveToStack(originalCard); AllZone.getGameAction().moveToStack(originalCard);
}
if (spell.getAfterPayMana() != null) if (spell.getAfterPayMana() != null) {
stopSetNext(spell.getAfterPayMana()); stopSetNext(spell.getAfterPayMana());
else { } else {
if (skipStack) { if (skipStack) {
spell.resolve(); spell.resolve();
} else { } else {
@@ -170,17 +201,26 @@ public class Input_PayManaCost extends Input {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void selectButtonCancel() { public final void selectButtonCancel() {
resetManaCost(); resetManaCost();
AllZone.getHumanPlayer().getManaPool().unpaid(spell, true); AllZone.getHumanPlayer().getManaPool().unpaid(spell, true);
AllZone.getHumanPlayer().getZone(Zone.Battlefield).updateObservers();//DO NOT REMOVE THIS, otherwise the cards don't always tap AllZone.getHumanPlayer().getZone(Zone.Battlefield).updateObservers(); // DO
// NOT
// REMOVE
// THIS,
// otherwise
// the
// cards
// don't
// always
// tap
stop(); stop();
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void showMessage() { public final void showMessage() {
ButtonUtil.enableOnlyCancel(); ButtonUtil.enableOnlyCancel();
StringBuilder msg = new StringBuilder("Pay Mana Cost: " + manaCost.toString()); StringBuilder msg = new StringBuilder("Pay Mana Cost: " + manaCost.toString());
@@ -200,6 +240,5 @@ public class Input_PayManaCost extends Input {
done(); done();
} }
} }
} }

View File

@@ -1,5 +1,10 @@
package forge.gui.input; package forge.gui.input;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import forge.AllZone; import forge.AllZone;
import forge.Card; import forge.Card;
import forge.Constant; import forge.Constant;
@@ -11,13 +16,10 @@ import forge.card.spellability.Ability_Mana;
import forge.card.spellability.SpellAbility; import forge.card.spellability.SpellAbility;
import forge.gui.GuiUtils; import forge.gui.GuiUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/** /**
* <p>Input_PayManaCostUtil class.</p> * <p>
* Input_PayManaCostUtil class.
* </p>
* *
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
@@ -27,36 +29,52 @@ public class Input_PayManaCostUtil {
// mana abilities are Strings and are retrieved by calling card.getKeyword() // mana abilities are Strings and are retrieved by calling card.getKeyword()
// taps any card that has mana ability, not just land // taps any card that has mana ability, not just land
/** /**
* <p>activateManaAbility.</p> * <p>
* activateManaAbility.
* </p>
* *
* @param sa a {@link forge.card.spellability.SpellAbility} object. * @param sa
* @param card a {@link forge.Card} object. * a {@link forge.card.spellability.SpellAbility} object.
* @param manaCost a {@link forge.card.mana.ManaCost} object. * @param card
* a {@link forge.Card} object.
* @param manaCost
* a {@link forge.card.mana.ManaCost} object.
* @return a {@link forge.card.mana.ManaCost} object. * @return a {@link forge.card.mana.ManaCost} object.
*/ */
public static ManaCost activateManaAbility(SpellAbility sa, Card card, ManaCost manaCost) { public static ManaCost activateManaAbility(final SpellAbility sa, final Card card, ManaCost manaCost) {
// make sure computer's lands aren't selected // make sure computer's lands aren't selected
if (card.getController().isComputer()) if (card.getController().isComputer()) {
return manaCost; return manaCost;
}
if (card instanceof ManaPool) if (card instanceof ManaPool) {
return ((ManaPool) card).subtractMana(sa, manaCost); return ((ManaPool) card).subtractMana(sa, manaCost);
}
ArrayList<Ability_Mana> abilities = getManaAbilities(card); ArrayList<Ability_Mana> abilities = getManaAbilities(card);
StringBuilder cneeded = new StringBuilder(); StringBuilder cneeded = new StringBuilder();
boolean choice = true; boolean choice = true;
boolean skipExpress = false; boolean skipExpress = false;
for (String color : Constant.Color.ManaColors) for (String color : Constant.Color.ManaColors) {
if (manaCost.isNeeded(color)) if (manaCost.isNeeded(color)) {
cneeded.append(getShortColorString(color)); cneeded.append(getShortColorString(color));
}
}
Iterator<Ability_Mana> it = abilities.iterator();//you can't remove unneeded abilities inside a for(am:abilities) loop :( Iterator<Ability_Mana> it = abilities.iterator(); // you can't remove
// unneeded abilities
// inside a
// for(am:abilities)
// loop :(
while (it.hasNext()) { while (it.hasNext()) {
Ability_Mana ma = it.next(); Ability_Mana ma = it.next();
ma.setActivatingPlayer(AllZone.getHumanPlayer()); ma.setActivatingPlayer(AllZone.getHumanPlayer());
if (!ma.canPlay()) it.remove(); if (!ma.canPlay()) {
else if (!canMake(ma, cneeded.toString())) it.remove(); it.remove();
} else if (!canMake(ma, cneeded.toString())) {
it.remove();
}
if (!skipExpress) { if (!skipExpress) {
// skip express mana if the ability is not undoable // skip express mana if the ability is not undoable
@@ -66,11 +84,13 @@ public class Input_PayManaCostUtil {
} }
} }
} }
if (abilities.isEmpty()) if (abilities.isEmpty()) {
return manaCost; return manaCost;
}
// TODO when implementing sunburst // TODO when implementing sunburst
// If the card has sunburst or any other ability that tracks mana spent, skip express Mana choice // If the card has sunburst or any other ability that tracks mana spent,
// skip express Mana choice
// if (card.getTrackManaPaid()) skipExpress = true; // if (card.getTrackManaPaid()) skipExpress = true;
if (!skipExpress) { if (!skipExpress) {
@@ -79,24 +99,29 @@ public class Input_PayManaCostUtil {
for (Ability_Mana am : abilities) { for (Ability_Mana am : abilities) {
if (am.isReflectedMana()) { if (am.isReflectedMana()) {
ArrayList<String> reflectableColors = AbilityFactory_Mana.reflectableMana(am, am.getAbilityFactory(), new ArrayList<String>(), new ArrayList<Card>()); ArrayList<String> reflectableColors = AbilityFactory_Mana.reflectableMana(am,
am.getAbilityFactory(), new ArrayList<String>(), new ArrayList<Card>());
for (String color : reflectableColors) { for (String color : reflectableColors) {
if (manaCost.isColor(color)) // convert to long before checking if color if (manaCost.isColor(color)) {
// checking if color
colorMatches.add(am); colorMatches.add(am);
} }
} }
else{ } else {
String[] m = ManaPool.formatMana(am); String[] m = ManaPool.formatMana(am);
for (String color : m) for (String color : m) {
if (manaCost.isColor(color)) // convert to long before checking if color if (manaCost.isColor(color)) {
// checking if color
colorMatches.add(am); colorMatches.add(am);
} }
} }
}
}
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()) {
// leave behind only color matches // leave behind only color matches
abilities = colorMatches; abilities = colorMatches;
} }
@@ -105,8 +130,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>(); HashMap<String, Ability_Mana> ability = new HashMap<String, Ability_Mana>();
for (Ability_Mana am : abilities) for (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());
} }
@@ -114,30 +140,38 @@ public class Input_PayManaCostUtil {
manaCost = AllZone.getHumanPlayer().getManaPool().subtractMana(sa, manaCost, chosen); manaCost = AllZone.getHumanPlayer().getManaPool().subtractMana(sa, manaCost, chosen);
AllZone.getHumanPlayer().getZone(Zone.Battlefield).updateObservers();//DO NOT REMOVE THIS, otherwise the cards don't always tap (copied) AllZone.getHumanPlayer().getZone(Zone.Battlefield).updateObservers();
// DO NOT REMOVE THIS, otherwise the cards don't always tap (copied)
return manaCost; return manaCost;
} }
/** /**
* <p>getManaAbilities.</p> * <p>
* getManaAbilities.
* </p>
* *
* @param card a {@link forge.Card} object. * @param card
* a {@link forge.Card} object.
* @return a {@link java.util.ArrayList} object. * @return a {@link java.util.ArrayList} object.
*/ */
public static ArrayList<Ability_Mana> getManaAbilities(Card card) { public static ArrayList<Ability_Mana> getManaAbilities(final Card card) {
return card.getManaAbility(); return card.getManaAbility();
} }
// color is like "G", returns "Green" // color is like "G", returns "Green"
/** /**
* <p>canMake.</p> * <p>
* canMake.
* </p>
* *
* @param am a {@link forge.card.spellability.Ability_Mana} object. * @param am
* @param mana a {@link java.lang.String} object. * a {@link forge.card.spellability.Ability_Mana} object.
* @param mana
* a {@link java.lang.String} object.
* @return a boolean. * @return a boolean.
*/ */
public static boolean canMake(Ability_Mana am, String mana) { public static boolean canMake(final Ability_Mana am, final String mana) {
if (mana.contains("1")) { if (mana.contains("1")) {
return true; return true;
} }
@@ -146,14 +180,14 @@ public class Input_PayManaCostUtil {
} }
if (am.isReflectedMana()) { if (am.isReflectedMana()) {
ArrayList<String> reflectableColors = AbilityFactory_Mana.reflectableMana(am, am.getAbilityFactory(), new ArrayList<String>(), new ArrayList<Card>()); ArrayList<String> reflectableColors = AbilityFactory_Mana.reflectableMana(am, am.getAbilityFactory(),
new ArrayList<String>(), new ArrayList<Card>());
for (String color : reflectableColors) { for (String color : reflectableColors) {
if (mana.contains(getShortColorString(color))) { if (mana.contains(getShortColorString(color))) {
return true; return true;
} }
} }
} } else {
else{
for (String color : ManaPool.formatMana(am)) { for (String color : ManaPool.formatMana(am)) {
if (mana.contains(color)) { if (mana.contains(color)) {
return true; return true;
@@ -164,12 +198,15 @@ public class Input_PayManaCostUtil {
} }
/** /**
* <p>getLongColorString.</p> * <p>
* getLongColorString.
* </p>
* *
* @param color a {@link java.lang.String} object. * @param color
* a {@link java.lang.String} object.
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
public static String getLongColorString(String color) { public static String getLongColorString(final String color) {
Map<String, String> m = new HashMap<String, String>(); 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);
@@ -180,20 +217,23 @@ public class Input_PayManaCostUtil {
Object o = m.get(color); Object o = m.get(color);
if (o == null) if (o == null) {
o = Constant.Color.Colorless; o = Constant.Color.Colorless;
}
return o.toString(); return o.toString();
} }
/** /**
* <p>getShortColorString.</p> * <p>
* getShortColorString.
* </p>
* *
* @param color a {@link java.lang.String} object. * @param color
* a {@link java.lang.String} object.
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
public static String getShortColorString(String color) { public static String getShortColorString(final String color) {
Map<String, String> m = new HashMap<String, String>(); 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");

View File

@@ -1,20 +1,26 @@
package forge.gui.input; package forge.gui.input;
import forge.*; import forge.AllZone;
import forge.ButtonUtil;
import forge.Card;
import forge.Command;
import forge.PlayerZone;
import forge.card.mana.ManaCost; import forge.card.mana.ManaCost;
import forge.card.spellability.SpellAbility; import forge.card.spellability.SpellAbility;
//if cost is paid, Command.execute() is called //if cost is paid, Command.execute() is called
/** /**
* <p>Input_PayManaCost_Ability class.</p> * <p>
* Input_PayManaCost_Ability class.
* </p>
* *
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
*/ */
public class Input_PayManaCost_Ability extends Input { public class Input_PayManaCost_Ability extends Input {
/** /**
* Constant <code>serialVersionUID=3836655722696348713L</code> * Constant <code>serialVersionUID=3836655722696348713L</code>.
*/ */
private static final long serialVersionUID = 3836655722696348713L; private static final long serialVersionUID = 3836655722696348713L;
@@ -30,48 +36,74 @@ public class Input_PayManaCost_Ability extends Input {
private boolean showOnlyOKButton = false; private boolean showOnlyOKButton = false;
/** /**
* <p>Constructor for Input_PayManaCost_Ability.</p> * <p>
* Constructor for Input_PayManaCost_Ability.
* </p>
* *
* @param manaCost a {@link java.lang.String} object. * @param manaCost
* @param paid a {@link forge.Command} object. * a {@link java.lang.String} object.
* @param paid
* a {@link forge.Command} object.
*/ */
public Input_PayManaCost_Ability(String manaCost, Command paid) { public Input_PayManaCost_Ability(final String manaCost, final Command paid) {
this(manaCost, paid, Command.Blank); this(manaCost, paid, Command.Blank);
} }
/** /**
* <p>Constructor for Input_PayManaCost_Ability.</p> * <p>
* Constructor for Input_PayManaCost_Ability.
* </p>
* *
* @param manaCost_2 a {@link java.lang.String} object. * @param manaCost_2
* @param paidCommand_2 a {@link forge.Command} object. * a {@link java.lang.String} object.
* @param unpaidCommand_2 a {@link forge.Command} object. * @param paidCommand_2
* a {@link forge.Command} object.
* @param unpaidCommand_2
* a {@link forge.Command} object.
*/ */
public Input_PayManaCost_Ability(String manaCost_2, Command paidCommand_2, Command unpaidCommand_2) { public Input_PayManaCost_Ability(final String manaCost_2,
final Command paidCommand_2, final Command unpaidCommand_2) {
this("", manaCost_2, paidCommand_2, unpaidCommand_2); this("", manaCost_2, paidCommand_2, unpaidCommand_2);
} }
/** /**
* <p>Constructor for Input_PayManaCost_Ability.</p> * <p>
* Constructor for Input_PayManaCost_Ability.
* </p>
* *
* @param m a {@link java.lang.String} object. * @param m
* @param manaCost_2 a {@link java.lang.String} object. * a {@link java.lang.String} object.
* @param paidCommand_2 a {@link forge.Command} object. * @param manaCost_2
* @param unpaidCommand_2 a {@link forge.Command} object. * a {@link java.lang.String} object.
* @param paidCommand_2
* a {@link forge.Command} object.
* @param unpaidCommand_2
* a {@link forge.Command} object.
*/ */
public Input_PayManaCost_Ability(String m, String manaCost_2, Command paidCommand_2, Command unpaidCommand_2) { public Input_PayManaCost_Ability(final String m, final String manaCost_2,
final Command paidCommand_2, final Command unpaidCommand_2) {
this(m, manaCost_2, paidCommand_2, unpaidCommand_2, false); this(m, manaCost_2, paidCommand_2, unpaidCommand_2, false);
} }
/** /**
* <p>Constructor for Input_PayManaCost_Ability.</p> * <p>
* Constructor for Input_PayManaCost_Ability.
* </p>
* *
* @param m a {@link java.lang.String} object. * @param m
* @param manaCost_2 a {@link java.lang.String} object. * a {@link java.lang.String} object.
* @param paidCommand_2 a {@link forge.Command} object. * @param manaCost_2
* @param unpaidCommand_2 a {@link forge.Command} object. * a {@link java.lang.String} object.
* @param showOKButton a boolean. * @param paidCommand_2
* a {@link forge.Command} object.
* @param unpaidCommand_2
* a {@link forge.Command} object.
* @param showOKButton
* a boolean.
*/ */
public Input_PayManaCost_Ability(String m, String manaCost_2, Command paidCommand_2, Command unpaidCommand_2, boolean showOKButton) { public Input_PayManaCost_Ability(final String m, final String manaCost_2,
final Command paidCommand_2, final Command unpaidCommand_2,
final boolean showOKButton) {
fakeAbility = new SpellAbility(SpellAbility.Ability, null) { fakeAbility = new SpellAbility(SpellAbility.Ability, null) {
@Override @Override
public void resolve() { public void resolve() {
@@ -91,17 +123,18 @@ public class Input_PayManaCost_Ability extends Input {
showOnlyOKButton = showOKButton; showOnlyOKButton = showOKButton;
} }
/** /**
* <p>resetManaCost.</p> * <p>
* resetManaCost.
* </p>
*/ */
public void resetManaCost() { public final void resetManaCost() {
manaCost = new ManaCost(originalManaCost); manaCost = new ManaCost(originalManaCost);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void selectCard(Card card, 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); manaCost = Input_PayManaCostUtil.activateManaAbility(fakeAbility, card, manaCost);
@@ -110,15 +143,14 @@ public class Input_PayManaCost_Ability extends Input {
AllZone.getHumanPlayer().getManaPool().clearPay(fakeAbility, false); AllZone.getHumanPlayer().getManaPool().clearPay(fakeAbility, false);
stop(); stop();
paidCommand.execute(); paidCommand.execute();
} } else {
else{
showMessage(); showMessage();
} }
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void selectButtonCancel() { public final void selectButtonCancel() {
resetManaCost(); resetManaCost();
AllZone.getHumanPlayer().getManaPool().unpaid(fakeAbility, true); AllZone.getHumanPlayer().getManaPool().unpaid(fakeAbility, true);
stop(); stop();
@@ -127,7 +159,7 @@ public class Input_PayManaCost_Ability extends Input {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void selectButtonOK() { public final void selectButtonOK() {
if (showOnlyOKButton) { if (showOnlyOKButton) {
stop(); stop();
unpaidCommand.execute(); unpaidCommand.execute();
@@ -136,12 +168,12 @@ public class Input_PayManaCost_Ability extends Input {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void showMessage() { public final void showMessage() {
ButtonUtil.enableOnlyCancel(); ButtonUtil.enableOnlyCancel();
if (showOnlyOKButton) if (showOnlyOKButton) {
ButtonUtil.enableOnlyOK(); ButtonUtil.enableOnlyOK();
}
AllZone.getDisplay().showMessage(message + "Pay Mana Cost: \r\n" + manaCost.toString()); AllZone.getDisplay().showMessage(message + "Pay Mana Cost: \r\n" + manaCost.toString());
} }
} }

View File

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

View File

@@ -8,23 +8,32 @@ import java.awt.Graphics2D;
import java.awt.Image; import java.awt.Image;
import java.awt.Insets; import java.awt.Insets;
import java.awt.RenderingHints; import java.awt.RenderingHints;
import javax.swing.JButton; import javax.swing.JButton;
import forge.AllZone; import forge.AllZone;
/** /**
* The core JButton used throughout the Forge project. * The core JButton used throughout the Forge project. Follows skin font and
* Follows skin font and theme button styling. * theme button styling.
* *
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class FButton extends JButton { public class FButton extends JButton {
/** The img r. */
protected Image imgL, imgM, imgR; protected Image imgL, imgM, imgR;
private int w, h = 0; private int w, h = 0;
private boolean allImagesPresent = false; private boolean allImagesPresent = false;
private FSkin skin; private FSkin skin;
private AlphaComposite disabledComposite = private AlphaComposite disabledComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.25f);
AlphaComposite.getInstance(AlphaComposite.SRC_OVER,0.25f);
/**
* Instantiates a new f button.
*
* @param msg
* the msg
*/
public FButton(String msg) { public FButton(String msg) {
super(msg); super(msg);
this.skin = AllZone.getSkin(); this.skin = AllZone.getSkin();
@@ -50,6 +59,7 @@ public class FButton extends JButton {
imgR = skin.btnRover.getImage(); imgR = skin.btnRover.getImage();
} }
} }
public void mouseExited(java.awt.event.MouseEvent evt) { public void mouseExited(java.awt.event.MouseEvent evt) {
if (isEnabled()) { if (isEnabled()) {
imgL = skin.btnLup.getImage(); imgL = skin.btnLup.getImage();
@@ -57,6 +67,7 @@ public class FButton extends JButton {
imgR = skin.btnRup.getImage(); imgR = skin.btnRup.getImage();
} }
} }
public void mousePressed(java.awt.event.MouseEvent evt) { public void mousePressed(java.awt.event.MouseEvent evt) {
if (isEnabled()) { if (isEnabled()) {
imgL = skin.btnLdown.getImage(); imgL = skin.btnLdown.getImage();
@@ -67,20 +78,21 @@ public class FButton extends JButton {
}); });
} }
/*
* (non-Javadoc)
*
* @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
*/
protected void paintComponent(Graphics g) { protected void paintComponent(Graphics g) {
if (!allImagesPresent) { if (!allImagesPresent) {
return; return;
} }
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
RenderingHints.VALUE_TEXT_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
g2d.setRenderingHint(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
if (!isEnabled()) { if (!isEnabled()) {
g2d.setComposite(disabledComposite); g2d.setComposite(disabledComposite);

View File

@@ -2,12 +2,16 @@ package forge.gui.skin;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.LayoutManager; import java.awt.LayoutManager;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import javax.swing.JPanel; import javax.swing.JPanel;
/** <p>FPanel.</p> /**
* The core JPanel used throughout the Forge project. * <p>
* Allows tiled images and ... * FPanel.
* </p>
* The core JPanel used throughout the Forge project. Allows tiled images and
* ...
* *
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
@@ -15,15 +19,26 @@ public class FPanel extends JPanel {
private ImageIcon bgImg = null; private ImageIcon bgImg = null;
private int w, h, iw, ih, x, y = 0; private int w, h, iw, ih, x, y = 0;
/**
* Instantiates a new f panel.
*/
public FPanel() { public FPanel() {
super(); super();
} }
/**
* Instantiates a new f panel.
*
* @param lm the lm
*/
public FPanel(LayoutManager lm) { public FPanel(LayoutManager lm) {
this(); this();
this.setLayout(lm); this.setLayout(lm);
} }
/* (non-Javadoc)
* @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
*/
protected void paintComponent(Graphics g) { protected void paintComponent(Graphics g) {
// System.out.print("\nRepainting. "); // System.out.print("\nRepainting. ");
if (this.bgImg != null) { if (this.bgImg != null) {
@@ -46,6 +61,11 @@ public class FPanel extends JPanel {
super.paintComponent(g); super.paintComponent(g);
} }
/**
* Sets the bG img.
*
* @param icon the new bG img
*/
public void setBGImg(ImageIcon icon) { public void setBGImg(ImageIcon icon) {
this.bgImg = icon; this.bgImg = icon;
if (this.bgImg != null) { if (this.bgImg != null) {

View File

@@ -5,17 +5,23 @@ import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.LayoutManager; import java.awt.LayoutManager;
import java.awt.RenderingHints; import java.awt.RenderingHints;
import javax.swing.JPanel; import javax.swing.JPanel;
/** <p>FRoundedPanel.</p> /**
* A subclass of JPanel with any of four corners rounded, * <p>
* drop shadow, and 1px line border. * FRoundedPanel.
* </p>
* A subclass of JPanel with any of four corners rounded, drop shadow, and 1px
* line border.
* *
* Limitations: Cannot tile background image, cannot set border width. * Limitations: Cannot tile background image, cannot set border width.
* *
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class FRoundedPanel extends JPanel { public class FRoundedPanel extends JPanel {
/** The corners. */
public boolean[] corners = { true, true, true, true }; // NW, SW, SE, NE public boolean[] corners = { true, true, true, true }; // NW, SW, SE, NE
private Color shadowColor = new Color(150, 150, 150, 150); private Color shadowColor = new Color(150, 150, 150, 150);
@@ -25,7 +31,9 @@ public class FRoundedPanel extends JPanel {
private boolean showShadow = false; private boolean showShadow = false;
/** /**
* <p>FRoundedPanel.</p> * <p>
* FRoundedPanel.
* </p>
* *
* Constructor, null layout manager. * Constructor, null layout manager.
*/ */
@@ -35,10 +43,14 @@ public class FRoundedPanel extends JPanel {
} }
/** /**
* <p>FRoundedPanel.</p> * <p>
* FRoundedPanel.
* </p>
* *
* Constructor. * Constructor.
* @param {@link java.awt.LayoutManager} *
* @param lm
* the lm
*/ */
public FRoundedPanel(LayoutManager lm) { public FRoundedPanel(LayoutManager lm) {
this(); this();
@@ -46,10 +58,14 @@ public class FRoundedPanel extends JPanel {
} }
/** /**
* <p>FRoundedPanel.</p> * <p>
* FRoundedPanel.
* </p>
* *
* Constructor. * Constructor.
* @param {@link java.awt.Graphics} *
* @param g
* the g
*/ */
protected void paintComponent(Graphics g) { protected void paintComponent(Graphics g) {
super.paintComponent(g); super.paintComponent(g);
@@ -59,8 +75,7 @@ public class FRoundedPanel extends JPanel {
int r = cornerRadius; int r = cornerRadius;
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
RenderingHints.VALUE_ANTIALIAS_ON);
if (showShadow) { if (showShadow) {
// Mid, left, right rectangles: shadow // Mid, left, right rectangles: shadow
@@ -73,29 +88,25 @@ public class FRoundedPanel extends JPanel {
// NW // NW
if (corners[0]) { if (corners[0]) {
g2d.fillArc(so, so, 2 * r, 2 * r, 90, 90); g2d.fillArc(so, so, 2 * r, 2 * r, 90, 90);
} } else {
else {
g2d.fillRect(so, so, r, r); g2d.fillRect(so, so, r, r);
} }
// SW // SW
if (corners[1]) { if (corners[1]) {
g2d.fillArc(so, h - 2 * r, 2 * r, 2 * r, 180, 90); g2d.fillArc(so, h - 2 * r, 2 * r, 2 * r, 180, 90);
} } else {
else {
g2d.fillRect(so, h - r, r, r); g2d.fillRect(so, h - r, r, r);
} }
// SE // SE
if (corners[2]) { if (corners[2]) {
g2d.fillArc(w - 2 * r, h - 2 * r, 2 * r, 2 * r, 270, 90); g2d.fillArc(w - 2 * r, h - 2 * r, 2 * r, 2 * r, 270, 90);
} } else {
else {
g2d.fillRect(w - r, h - r, r, r); g2d.fillRect(w - r, h - r, r, r);
} }
// NE // NE
if (corners[3]) { if (corners[3]) {
g2d.fillArc(w - 2 * r, so, 2 * r, 2 * r, 0, 90); g2d.fillArc(w - 2 * r, so, 2 * r, 2 * r, 0, 90);
} } else {
else {
g2d.fillRect(w - r, so, r, r); g2d.fillRect(w - r, so, r, r);
} }
} // End if(showShadow) } // End if(showShadow)
@@ -114,29 +125,25 @@ public class FRoundedPanel extends JPanel {
// NW // NW
if (corners[0]) { if (corners[0]) {
g2d.fillArc(0, 0, 2 * r, 2 * r, 90, 90); g2d.fillArc(0, 0, 2 * r, 2 * r, 90, 90);
} } else {
else {
g2d.fillRect(0, 0, r, r); g2d.fillRect(0, 0, r, r);
} }
// SW // SW
if (corners[1]) { if (corners[1]) {
g2d.fillArc(0, h - 2 * r - so, 2 * r, 2 * r, 180, 90); g2d.fillArc(0, h - 2 * r - so, 2 * r, 2 * r, 180, 90);
} } else {
else {
g2d.fillRect(0, h - r - so, r, r); g2d.fillRect(0, h - r - so, r, r);
} }
// SE // SE
if (corners[2]) { if (corners[2]) {
g2d.fillArc(w - 2 * r - so, h - 2 * r - so, 2 * r, 2 * r, 270, 90); g2d.fillArc(w - 2 * r - so, h - 2 * r - so, 2 * r, 2 * r, 270, 90);
} } else {
else {
g2d.fillRect(w - r - so, h - r - so, r, r); g2d.fillRect(w - r - so, h - r - so, r, r);
} }
// NE // NE
if (corners[3]) { if (corners[3]) {
g2d.fillArc(w - 2 * r - so, 0, 2 * r, 2 * r, 0, 90); g2d.fillArc(w - 2 * r - so, 0, 2 * r, 2 * r, 0, 90);
} } else {
else {
g2d.fillRect(w - r - so, 0, r, r); g2d.fillRect(w - r - so, 0, r, r);
} }
@@ -151,62 +158,67 @@ public class FRoundedPanel extends JPanel {
// NW // NW
if (corners[0]) { if (corners[0]) {
g2d.drawArc(0, 0, 2 * r, 2 * r, 90, 90); g2d.drawArc(0, 0, 2 * r, 2 * r, 90, 90);
} } else {
else {
g2d.drawLine(0, 0, r, 0); g2d.drawLine(0, 0, r, 0);
g2d.drawLine(0, 0, 0, r); g2d.drawLine(0, 0, 0, r);
} }
// SW // SW
if (corners[1]) { if (corners[1]) {
g2d.drawArc(0, h - 2 * r - so, 2 * r, 2 * r - 1, 180, 90); g2d.drawArc(0, h - 2 * r - so, 2 * r, 2 * r - 1, 180, 90);
} } else {
else {
g2d.drawLine(0, h - so - 1, 0, h - r - so - 1); g2d.drawLine(0, h - so - 1, 0, h - r - so - 1);
g2d.drawLine(0, h - so - 1, r, h - so - 1); g2d.drawLine(0, h - so - 1, r, h - so - 1);
} }
// SE // SE
if (corners[2]) { if (corners[2]) {
g2d.drawArc(w - 2 * r - so, h - 2 * r - so, 2 * r - 1, 2 * r - 1, 270, 90); g2d.drawArc(w - 2 * r - so, h - 2 * r - so, 2 * r - 1, 2 * r - 1, 270, 90);
} } else {
else {
g2d.drawLine(w - so - 1, h - so - 1, w - so - 1, h - r - so); g2d.drawLine(w - so - 1, h - so - 1, w - so - 1, h - r - so);
g2d.drawLine(w - so - 1, h - so - 1, w - r - so, h - so - 1); g2d.drawLine(w - so - 1, h - so - 1, w - r - so, h - so - 1);
} }
// NE // NE
if (corners[3]) { if (corners[3]) {
g2d.drawArc(w - 2 * r - so, 0, 2 * r - 1, 2 * r - 1, 0, 90); g2d.drawArc(w - 2 * r - so, 0, 2 * r - 1, 2 * r - 1, 0, 90);
} } else {
else {
g2d.drawLine(w - so - 1, 0, w - so - r, 0); g2d.drawLine(w - so - 1, 0, w - so - r, 0);
g2d.drawLine(w - so - 1, 0, w - so - 1, r); g2d.drawLine(w - so - 1, 0, w - so - 1, r);
} }
} }
/** /**
* <p>setShadowColor.</p> * <p>
* setShadowColor.
* </p>
* Sets color of shadow behind rounded panel. * Sets color of shadow behind rounded panel.
* *
* @param {@link java.awt.Color} * @param c
* the new shadow color
*/ */
public void setShadowColor(Color c) { public void setShadowColor(Color c) {
this.shadowColor = c; this.shadowColor = c;
} }
/** /**
* <p>setBorderColor.</p> * <p>
* setBorderColor.
* </p>
* Sets color of border around rounded panel. * Sets color of border around rounded panel.
* *
* @param {@link java.awt.Color} * @param c
* the new border color
*/ */
public void setBorderColor(Color c) { public void setBorderColor(Color c) {
this.borderColor = c; this.borderColor = c;
} }
/** /**
* <p>setShadowOffset.</p> * <p>
* setShadowOffset.
* </p>
* Sets offset of shadow from rounded panel. * Sets offset of shadow from rounded panel.
* *
* @param {@link java.lang.Integer} side * @param i
* the new shadow offset
*/ */
public void setShadowOffset(int i) { public void setShadowOffset(int i) {
if (i < 0) { if (i < 0) {
@@ -216,10 +228,13 @@ public class FRoundedPanel extends JPanel {
} }
/** /**
* <p>setCornerRadius.</p> * <p>
* setCornerRadius.
* </p>
* Sets radius of each corner on rounded panel. * Sets radius of each corner on rounded panel.
* *
* @param {@link java.lang.Integer} r * @param r
* the new corner radius
*/ */
public void setCornerRadius(int r) { public void setCornerRadius(int r) {
if (r < 0) { if (r < 0) {
@@ -230,10 +245,14 @@ public class FRoundedPanel extends JPanel {
} }
/** /**
* <p>setCorners.</p> * <p>
* Sets if corners should be rounded or not in the following order: * setCorners.
* NW, SW, SE, NE * </p>
* @param boolean vals[] must be length 4 * Sets if corners should be rounded or not in the following order: NW, SW,
* SE, NE
*
* @param vals
* the new corners
*/ */
public void setCorners(boolean vals[]) { public void setCorners(boolean vals[]) {
if (vals.length != 4) { if (vals.length != 4) {
@@ -243,6 +262,12 @@ public class FRoundedPanel extends JPanel {
corners = vals; corners = vals;
} }
/**
* Sets the show shadow.
*
* @param b
* the new show shadow
*/
public void setShowShadow(boolean b) { public void setShowShadow(boolean b) {
showShadow = b; showShadow = b;
} }

View File

@@ -12,43 +12,95 @@ import javax.swing.ImageIcon;
import forge.gui.GuiUtils; import forge.gui.GuiUtils;
/** /**
* Assembles settings from selected or default theme as appropriate. * Assembles settings from selected or default theme as appropriate. Saves in a
* Saves in a hashtable, access using .get(settingName) method. * hashtable, access using .get(settingName) method.
* *
*/ */
public class FSkin { public class FSkin {
// ===== Public fields // ===== Public fields
/** The font1. */
public Font font1 = null; public Font font1 = null;
/** The font2. */
public Font font2 = null; public Font font2 = null;
/** The texture1. */
public ImageIcon texture1 = null; public ImageIcon texture1 = null;
/** The texture2. */
public ImageIcon texture2 = null; public ImageIcon texture2 = null;
/** The texture3. */
public ImageIcon texture3 = null; public ImageIcon texture3 = null;
/** The btn lup. */
public ImageIcon btnLup = null; public ImageIcon btnLup = null;
/** The btn mup. */
public ImageIcon btnMup = null; public ImageIcon btnMup = null;
/** The btn rup. */
public ImageIcon btnRup = null; public ImageIcon btnRup = null;
/** The btn lover. */
public ImageIcon btnLover = null; public ImageIcon btnLover = null;
/** The btn mover. */
public ImageIcon btnMover = null; public ImageIcon btnMover = null;
/** The btn rover. */
public ImageIcon btnRover = null; public ImageIcon btnRover = null;
/** The btn ldown. */
public ImageIcon btnLdown = null; public ImageIcon btnLdown = null;
/** The btn mdown. */
public ImageIcon btnMdown = null; public ImageIcon btnMdown = null;
/** The btn rdown. */
public ImageIcon btnRdown = null; public ImageIcon btnRdown = null;
/** The splash. */
public ImageIcon splash = null; public ImageIcon splash = null;
/** The bg1a. */
public Color bg1a = Color.red; public Color bg1a = Color.red;
/** The bg1b. */
public Color bg1b = Color.red; public Color bg1b = Color.red;
/** The bg2a. */
public Color bg2a = Color.red; public Color bg2a = Color.red;
/** The bg2b. */
public Color bg2b = Color.red; public Color bg2b = Color.red;
/** The bg3a. */
public Color bg3a = Color.red; public Color bg3a = Color.red;
/** The bg3b. */
public Color bg3b = Color.red; public Color bg3b = Color.red;
/** The txt1a. */
public Color txt1a = Color.red; public Color txt1a = Color.red;
/** The txt1b. */
public Color txt1b = Color.red; public Color txt1b = Color.red;
/** The txt2a. */
public Color txt2a = Color.red; public Color txt2a = Color.red;
/** The txt2b. */
public Color txt2b = Color.red; public Color txt2b = Color.red;
/** The txt3a. */
public Color txt3a = Color.red; public Color txt3a = Color.red;
/** The txt3b. */
public Color txt3b = Color.red; public Color txt3b = Color.red;
/** The name. */
public String name = "default"; public String name = "default";
// ===== Private fields // ===== Private fields
@@ -72,14 +124,14 @@ public class FSkin {
private ImageIcon tempImg; private ImageIcon tempImg;
private Font tempFont; private Font tempFont;
private String skin; private String skin;
private String notfound = "FSkin.java: \""+skin+ private String notfound = "FSkin.java: \"" + skin + "\" skin can't find ";
"\" skin can't find ";
/** /**
* FSkin constructor. No arguments, will generate default skin settings, * FSkin constructor. No arguments, will generate default skin settings,
* fonts, and backgrounds. * fonts, and backgrounds.
* *
* @throws Exception * @throws Exception
* the exception
*/ */
public FSkin() throws Exception { public FSkin() throws Exception {
this("default"); this("default");
@@ -89,8 +141,10 @@ public class FSkin {
* FSkin constructor, using skin name. Generates custom skin settings, * FSkin constructor, using skin name. Generates custom skin settings,
* fonts, and backgrounds. * fonts, and backgrounds.
* *
* @param themeName * @param skinName
* the skin name
* @throws Exception * @throws Exception
* the exception
*/ */
public FSkin(String skinName) throws Exception { public FSkin(String skinName) throws Exception {
loadFontAndImages("default"); loadFontAndImages("default");
@@ -152,9 +206,11 @@ public class FSkin {
} }
/** /**
* <p>retrieveImage.</p> * <p>
* Tries to instantiate an image icon from a filename. * retrieveImage.
* Error reported if not found. * </p>
* Tries to instantiate an image icon from a filename. Error reported if not
* found.
* *
* @param {@link java.lang.String} address * @param {@link java.lang.String} address
* @return a ImageIcon * @return a ImageIcon
@@ -169,10 +225,12 @@ public class FSkin {
} }
/** /**
* <p>retrieveFont.</p> * <p>
* Uses GuiUtils to grab a font file at an address. * retrieveFont.
* Error will be reported by GuiUtils if not found. * </p>
* Error also reported by this method if not found. * Uses GuiUtils to grab a font file at an address. Error will be reported
* by GuiUtils if not found. Error also reported by this method if not
* found.
* *
* @param {@link java.lang.String} address * @param {@link java.lang.String} address
* @return a Font * @return a Font
@@ -184,15 +242,13 @@ public class FSkin {
} }
/** /**
* <p>getColorFromPixel.</p> * <p>
* getColorFromPixel.
* </p>
* *
* @param {@link java.lang.Integer} pixel information * @param {@link java.lang.Integer} pixel information
*/ */
private Color getColorFromPixel(int pixel) { private Color getColorFromPixel(int pixel) {
return new Color( return new Color((pixel & 0x00ff0000) >> 16, (pixel & 0x0000ff00) >> 8, (pixel & 0x000000ff));
(pixel & 0x00ff0000) >> 16,
(pixel & 0x0000ff00) >> 8,
(pixel & 0x000000ff)
);
} }
} }

View File

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