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

View File

@@ -5,64 +5,81 @@ import forge.Card;
import forge.Player;
import forge.PlayerZone;
/**
* <p>Abstract Input class.</p>
*
* <p>
* Abstract Input class.
* </p>
*
* @author Forge
* @version $Id$
*/
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 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() {
AllZone.getDisplay().showMessage("Blank Input");
}
/**
* <p>selectCard.</p>
*
* @param c a {@link forge.Card} object.
* @param zone a {@link forge.PlayerZone} object.
* <p>
* selectCard.
* </p>
*
* @param c
* 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>
*
* @param player a {@link forge.Player} object.
* <p>
* selectPlayer.
* </p>
*
* @param player
* a {@link forge.Player} object.
*/
public void selectPlayer(final Player player) {
}
/**
* <p>selectButtonOK.</p>
* <p>
* selectButtonOK.
* </p>
*/
public void selectButtonOK() {
}
/**
* <p>selectButtonCancel.</p>
* <p>
* selectButtonCancel.
* </p>
*/
public void selectButtonCancel() {
}
//helper methods, since they are used alot
//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)
// helper methods, since they are used alot
// 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)
/**
* <p>stop.</p>
* <p>
* stop.
* </p>
*/
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
AllZone.getInputControl().resetInput();
if (AllZone.getPhase().isNeedToNextPhase()) {
@@ -72,11 +89,14 @@ 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>
*
* @param in a {@link forge.gui.input.Input} object.
* <p>
* stopSetNext.
* </p>
*
* @param in
* a {@link forge.gui.input.Input} object.
*/
final public void stopSetNext(Input in) {
stop();
@@ -87,20 +107,25 @@ public abstract class Input implements java.io.Serializable {
@Override
public String toString() {
return "blank";
}//returns the Input name like "EmptyStack"
}// returns the Input name like "EmptyStack"
/**
* <p>setFree.</p>
*
* @param isFree a boolean.
* <p>
* setFree.
* </p>
*
* @param isFree
* a boolean.
*/
public void setFree(boolean isFree) {
this.isFree = isFree;
}
/**
* <p>isFree.</p>
*
* <p>
* isFree.
* </p>
*
* @return a boolean.
*/
public boolean isFree() {

View File

@@ -1,6 +1,5 @@
package forge.gui.input;
import java.util.LinkedList;
import java.util.Stack;
@@ -12,53 +11,67 @@ import forge.Player;
import forge.model.FModel;
/**
* <p>InputControl class.</p>
*
* <p>
* InputControl class.
* </p>
*
* @author Forge
* @version $Id$
*/
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 Input input;
/** Constant <code>n=0</code> */
/** Constant <code>n=0</code>. */
static int n = 0;
private Stack<Input> inputStack = new Stack<Input>();
private Stack<Input> resolvingStack = new Stack<Input>();
private LinkedList<Input> resolvingQueue = new LinkedList<Input>();
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.
* @param model
* TODO Write javadoc for Constructor.
*
* @param fModel
* the f model
*/
public InputControl(FModel fModel) {
public InputControl(final FModel fModel) {
model = fModel;
}
/**
* <p>Setter for the field <code>input</code>.</p>
*
* @param in a {@link forge.gui.input.Input} object.
* <p>
* Setter for the field <code>input</code>.
* </p>
*
* @param in
* a {@link forge.gui.input.Input} object.
*/
public void setInput(final Input in) {
if (model.getGameState().getStack().getResolving() || !(input == null || input instanceof Input_PassPriority))
public final void setInput(final Input in) {
if (model.getGameState().getStack().getResolving() || !(input == null || input instanceof Input_PassPriority)) {
inputStack.add(in);
else
} else {
input = in;
}
updateObservers();
}
/**
* <p>Setter for the field <code>input</code>.</p>
*
* @param in a {@link forge.gui.input.Input} object.
* @param bAddToResolving a boolean.
* <p>
* Setter for the field <code>input</code>.
* </p>
*
* @param in
* 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
if (!bAddToResolving) {
setInput(in);
@@ -71,9 +84,12 @@ public class InputControl extends MyObservable implements java.io.Serializable {
}
/**
* <p>changeInput.</p>
*
* @param in a {@link forge.gui.input.Input} object.
* <p>
* changeInput.
* </p>
*
* @param in
* a {@link forge.gui.input.Input} object.
*/
private void changeInput(final 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.
*/
public Input getInput() {
public final Input getInput() {
return input;
}
/**
* <p>clearInput.</p>
* <p>
* clearInput.
* </p>
*/
public void clearInput() {
public final void clearInput() {
input = null;
resolvingQueue.clear();
inputStack.clear();
}
/**
* <p>resetInput.</p>
* <p>
* resetInput.
* </p>
*/
public void resetInput() {
public final void resetInput() {
input = null;
updateObservers();
}
/**
* <p>resetInput.</p>
*
* @param update a boolean.
* <p>
* resetInput.
* </p>
*
* @param update
* a boolean.
*/
public void resetInput(boolean update) {
public final void resetInput(final boolean update) {
input = null;
if (update)
if (update) {
updateObservers();
}
}
/**
* <p>updateInput.</p>
*
* <p>
* updateInput.
* </p>
*
* @return a {@link forge.gui.input.Input} object.
*/
public Input updateInput() {
public final Input updateInput() {
final String phase = model.getGameState().getPhase().getPhase();
final Player playerTurn = model.getGameState().getPhase().getPlayerTurn();
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 (input != null) {
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());
return input;
}
if (model.getGameState().getStack().getResolving())
if (model.getGameState().getStack().getResolving()) {
return null;
}
if (input != null)
if (input != null) {
return input;
else if (inputStack.size() > 0) { // incoming input to Control
} else if (inputStack.size() > 0) { // incoming input to Control
changeInput(inputStack.pop());
return input;
}
@@ -156,16 +185,19 @@ public class InputControl extends MyObservable implements java.io.Serializable {
return updateInput();
}
// If the Phase we're in doesn't allow for Priority, return null to move to next phase
if (model.getGameState().getPhase().isNeedToNextPhase())
// If the Phase we're in doesn't allow for Priority, return null to move
// to next phase
if (model.getGameState().getPhase().isNeedToNextPhase()) {
return null;
}
// Special Inputs needed for the following phases:
// Special Inputs needed for the following phases:
if (phase.equals(Constant.Phase.Combat_Declare_Attackers)) {
model.getGameState().getStack().freezeStack();
if (playerTurn.isHuman())
if (playerTurn.isHuman()) {
return new Input_Attack();
}
} else if (phase.equals(Constant.Phase.Combat_Declare_Blockers)) {
model.getGameState().getStack().freezeStack();
if (playerTurn.isHuman()) {
@@ -176,33 +208,48 @@ public class InputControl extends MyObservable implements java.io.Serializable {
// no active attackers, skip the Blocking phase
model.getGameState().getPhase().setNeedToNextPhase(true);
return null;
} else
} else {
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();
}
}
// *********************
// 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()) {
boolean skip = model.getGameState().getPhase().doSkipPhase();
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();
return null;
} else
} else {
return new Input_PassPriority();
} else if (playerTurn.isComputer())
}
} else if (playerTurn.isComputer()) {
return aiInput;
else {
} else {
aiInput.getComputer().stack_not_empty();
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;
}
}//InputControl
}// InputControl

View File

@@ -11,12 +11,11 @@ import forge.Constant.Zone;
import forge.GameActionUtil;
import forge.PlayerZone;
/**
* <p>Input_Attack class.</p>
*
* <p>
* Input_Attack class.
* </p>
*
* @author Forge
* @version $Id$
*/
@@ -48,8 +47,7 @@ public class Input_Attack extends Input {
possibleAttackers = possibleAttackers.getType("Creature");
for (int i = 0; i < possibleAttackers.size(); i++) {
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())
{
AllZone.getCombat().addAttacker(c);
@@ -84,14 +82,23 @@ public class Input_Attack extends Input {
&& 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))
// return;
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()) {
Command com = GameActionUtil.commands.get(effect);
com.execute();
@@ -99,13 +106,17 @@ public class Input_Attack extends Input {
CombatUtil.showCombat();
}
} //selectCard()
} // selectCard()
/**
* <p>unselectCard.</p>
*
* @param card a {@link forge.Card} object.
* @param zone a {@link forge.PlayerZone} object.
* <p>
* unselectCard.
* </p>
*
* @param card
* a {@link forge.Card} object.
* @param zone
* a {@link forge.PlayerZone} object.
*/
public void unselectCard(final Card card, final PlayerZone zone) {

View File

@@ -12,10 +12,11 @@ import forge.Constant;
import forge.GameActionUtil;
import forge.PlayerZone;
/**
* <p>Input_Block class.</p>
*
* <p>
* Input_Block class.
* </p>
*
* @author Forge
* @version $Id$
*/
@@ -27,9 +28,12 @@ public class Input_Block extends Input {
private ArrayList<Card> allBlocking = new ArrayList<Card>();
/**
* <p>removeFromAllBlocking.</p>
*
* @param c a {@link forge.Card} object.
* <p>
* removeFromAllBlocking.
* </p>
*
* @param c
* a {@link forge.Card} object.
*/
public final void removeFromAllBlocking(final Card c) {
allBlocking.remove(c);
@@ -38,37 +42,33 @@ public class Input_Block extends Input {
/** {@inheritDoc} */
@Override
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()) {
Command com = GameActionUtil.commands.get(effect);
com.execute();
}
//could add "Reset Blockers" button
// could add "Reset Blockers" button
ButtonUtil.enableOnlyOK();
if (currentAttacker == null) {
/*
//Lure
CardList attackers = new CardList(AllZone.getCombat().getAttackers());
for(Card attacker:attackers) {
if(attacker.hasKeyword("All creatures able to block CARDNAME do so.")) {
CardList bls = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer());
for(Card bl:bls) {
if(CombatUtil.canBlock(attacker, bl, AllZone.getCombat())) {
allBlocking.add(bl);
AllZone.getCombat().addBlocker(attacker, bl);
}
}
}
}*/
* //Lure CardList attackers = new
* CardList(AllZone.getCombat().getAttackers()); for(Card
* attacker:attackers) {
* if(attacker.hasKeyword("All creatures able to block CARDNAME do so."
* )) { CardList bls =
* AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer());
* for(Card bl:bls) { if(CombatUtil.canBlock(attacker, bl,
* AllZone.getCombat())) { allBlocking.add(bl);
* AllZone.getCombat().addBlocker(attacker, bl); } } } }
*/
AllZone.getDisplay().showMessage("To Block, click on your Opponents attacker first, then your blocker(s)");
} else {
String attackerName = currentAttacker.isFaceDown() ? "Morph" : currentAttacker.getName();
AllZone.getDisplay().showMessage("Select a creature to block " + attackerName + " ("
+ currentAttacker.getUniqueNumber() + ") ");
AllZone.getDisplay().showMessage(
"Select a creature to block " + attackerName + " (" + currentAttacker.getUniqueNumber() + ") ");
}
CombatUtil.showCombat();
@@ -88,17 +88,16 @@ public class Input_Block extends Input {
/** {@inheritDoc} */
@Override
public final void selectCard(final Card card, final PlayerZone zone) {
//is attacking?
// is attacking?
if (CardUtil.toList(AllZone.getCombat().getAttackers()).contains(card)) {
currentAttacker = card;
} 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))) {
allBlocking.add(card);
AllZone.getCombat().addBlocker(currentAttacker, card);
}
}
showMessage();
} //selectCard()
} // selectCard()
}

View File

@@ -8,11 +8,11 @@ import forge.Constant;
import forge.Constant.Zone;
import forge.PlayerZone;
/**
* <p>Input_Cleanup class.</p>
*
* <p>
* Input_Cleanup class.
* </p>
*
* @author Forge
* @version $Id$
*/
@@ -31,18 +31,20 @@ public class Input_Cleanup extends Input {
ButtonUtil.disableAll();
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();
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");
AllZone.getDisplay().showMessage(sb.toString());
//goes to the next phase
// goes to the next phase
if (n <= AllZone.getHumanPlayer().getMaxHandSize() || AllZone.getHumanPlayer().getMaxHandSize() == -1) {
CombatUtil.removeAllDamage();
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.
}
}
@@ -55,11 +57,12 @@ public class Input_Cleanup extends Input {
showMessage();
}
}
} //selectCard()
} // selectCard()
/**
* <p>AI_CleanupDiscard.</p>
* <p>
* AI_CleanupDiscard.
* </p>
*/
public void AI_CleanupDiscard() {
int size = AllZone.getComputerPlayer().getCardsIn(Zone.Hand).size();

View File

@@ -19,8 +19,10 @@ import forge.game.GamePlayerRating;
import forge.quest.data.QuestData;
/**
* <p>Input_Mulligan class.</p>
*
* <p>
* Input_Mulligan class.
* </p>
*
* @author Forge
* @version $Id$
*/
@@ -49,16 +51,25 @@ public class Input_Mulligan extends Input {
/**
*
* 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
*/
public final int doMulligan(final Player player, final GamePlayerRating playerRating) {
CardList hand = player.getCardsIn(Zone.Hand);
for (Card c : hand) { AllZone.getGameAction().moveToLibrary(c); }
for (int i = 0; i < MAGIC_NUMBER_OF_SHUFFLES; i++) { player.shuffle(); }
for (Card c : hand) {
AllZone.getGameAction().moveToLibrary(c);
}
for (int i = 0; i < MAGIC_NUMBER_OF_SHUFFLES; i++) {
player.shuffle();
}
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.notifyOpeningHandSize(newHand);
return newHand;
@@ -69,7 +80,7 @@ public class Input_Mulligan extends Input {
public final void selectButtonCancel() {
Player humanPlayer = AllZone.getHumanPlayer();
GamePlayerRating humanRating = AllZone.getGameInfo().getPlayerRating(humanPlayer.getName());
int newHand = doMulligan(humanPlayer, humanRating);
QuestData quest = AllZone.getQuestData();
@@ -81,18 +92,21 @@ public class Input_Mulligan extends Input {
if (newHand == 0) {
end();
}
} //selectButtonOK()
} // selectButtonOK()
/**
* <p>end.</p>
* <p>
* end.
* </p>
*/
final void end() {
//Computer mulligan
// Computer mulligan
Player aiPlayer = AllZone.getComputerPlayer();
GamePlayerRating aiRating = AllZone.getGameInfo().getPlayerRating(aiPlayer.getName());
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) {
CardList handList = aiPlayer.getCardsIn(Zone.Hand);
@@ -104,7 +118,7 @@ public class Input_Mulligan extends Input {
}
}
//Human Leylines & Chancellors
// Human Leylines & Chancellors
ButtonUtil.reset();
AbilityFactory af = new AbilityFactory();
CardList humanOpeningHand = AllZone.getHumanPlayer().getCardsIn(Zone.Hand);
@@ -119,7 +133,8 @@ public class Input_Mulligan extends Input {
SpellAbility effect = af.getAbility(c.getSVar(effName), c);
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);
}
}
@@ -131,7 +146,7 @@ public class Input_Mulligan extends Input {
}
}
//Computer Leylines & Chancellors
// Computer Leylines & Chancellors
CardList aiOpeningHand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand);
for (Card c : aiOpeningHand) {
if (!c.getName().startsWith("Leyline")) {
@@ -144,28 +159,27 @@ public class Input_Mulligan extends Input {
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)) {
GameActionUtil.showInfoDialg("Computer reveals "
+ c.getName() + "(" + c.getUniqueNumber() + ").");
GameActionUtil.showInfoDialg("Computer reveals " + c.getName() + "(" + c.getUniqueNumber()
+ ").");
ComputerUtil.playNoStack(effect);
}
}
}
}
if (c.getName().startsWith("Leyline") && !(c.getName().startsWith("Leyline of Singularity")
&& AllZoneUtil.getCardsIn(Zone.Battlefield, "Leyline of Singularity").size() > 0))
{
if (c.getName().startsWith("Leyline")
&& !(c.getName().startsWith("Leyline of Singularity") && AllZoneUtil.getCardsIn(Zone.Battlefield,
"Leyline of Singularity").size() > 0)) {
AllZone.getGameAction().moveToPlay(c);
AllZone.getGameAction().checkStateEffects();
}
}
AllZone.getGameAction().checkStateEffects();
if (AllZone.getGameAction().isStartCut() && !(humanOpeningHand.contains(AllZone.getGameAction().getHumanCut())
|| aiOpeningHand.contains(AllZone.getGameAction().getComputerCut())))
{
if (AllZone.getGameAction().isStartCut()
&& !(humanOpeningHand.contains(AllZone.getGameAction().getHumanCut()) || aiOpeningHand.contains(AllZone
.getGameAction().getComputerCut()))) {
AllZone.getGameAction().moveTo(AllZone.getHumanPlayer().getZone(Constant.Zone.Library),
AllZone.getGameAction().getHumanCut());
AllZone.getGameAction().moveTo(AllZone.getComputerPlayer().getZone(Constant.Zone.Library),

View File

@@ -1,20 +1,27 @@
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
* @version $Id$
*/
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;
/** {@inheritDoc} */
@Override
public void showMessage() {
public final void showMessage() {
GuiDisplayUtil.updateGUI();
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("Phase: ").append(phase).append("\n");
sb.append("Stack: ");
if (AllZone.getStack().size() != 0)
if (AllZone.getStack().size() != 0) {
sb.append(AllZone.getStack().size()).append(" to Resolve.");
else
} else {
sb.append("Empty");
}
sb.append("\n");
sb.append("Priority: ").append(player);
@@ -42,19 +50,21 @@ public class Input_PassPriority extends Input implements java.io.Serializable {
/** {@inheritDoc} */
@Override
public void selectButtonOK() {
public final void selectButtonOK() {
AllZone.getPhase().passPriority();
GuiDisplayUtil.updateGUI();
Input in = AllZone.getInputControl().getInput();
if (in == this || in == null)
if (in == this || in == null) {
AllZone.getInputControl().resetInput();
// Clear out PassPriority after clicking button
}
}
/** {@inheritDoc} */
@Override
public void selectCard(Card card, PlayerZone zone) {
if (AllZone.getGameAction().playCard(card))
public final void selectCard(final Card card, final PlayerZone zone) {
if (AllZone.getGameAction().playCard(card)) {
AllZone.getPhase().setPriority(AllZone.getHumanPlayer());
}//selectCard()
}
} // selectCard()
}

View File

@@ -1,7 +1,12 @@
package forge.gui.input;
import forge.*;
import forge.AllZone;
import forge.ButtonUtil;
import forge.Card;
import forge.Constant.Zone;
import forge.Phase;
import forge.Player;
import forge.PlayerZone;
import forge.card.mana.ManaCost;
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
//CANNOT be used for ABILITIES
/**
* <p>Input_PayManaCost class.</p>
*
* <p>
* Input_PayManaCost class.
* </p>
*
* @author Forge
* @version $Id$
*/
public class Input_PayManaCost extends Input {
// 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 final String originalManaCost;
private final Card originalCard;
/** The mana cost. */
public ManaCost manaCost;
private final SpellAbility spell;
@@ -31,12 +40,16 @@ public class Input_PayManaCost extends Input {
private int phyLifeToLose = 0;
/**
* <p>Constructor for Input_PayManaCost.</p>
*
* @param sa a {@link forge.card.spellability.SpellAbility} object.
* @param noStack a boolean.
* <p>
* Constructor for Input_PayManaCost.
* </p>
*
* @param sa
* 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;
originalManaCost = sa.getManaCost(); // Change
originalCard = sa.getSourceCard();
@@ -45,8 +58,9 @@ public class Input_PayManaCost extends Input {
if (Phase.getGameBegins() == 1) {
if (sa.getSourceCard().isCopiedSpell() && sa.isSpell()) {
if (spell.getAfterPayMana() != null) stopSetNext(spell.getAfterPayMana());
else {
if (spell.getAfterPayMana() != null) {
stopSetNext(spell.getAfterPayMana());
} else {
manaCost = new ManaCost("0");
AllZone.getStack().add(spell);
}
@@ -59,11 +73,14 @@ public class Input_PayManaCost extends Input {
}
/**
* <p>Constructor for Input_PayManaCost.</p>
*
* @param sa a {@link forge.card.spellability.SpellAbility} object.
* <p>
* Constructor for Input_PayManaCost.
* </p>
*
* @param sa
* a {@link forge.card.spellability.SpellAbility} object.
*/
public Input_PayManaCost(SpellAbility sa) {
public Input_PayManaCost(final SpellAbility sa) {
originalManaCost = sa.getManaCost(); // Change
originalCard = sa.getSourceCard();
@@ -71,8 +88,9 @@ public class Input_PayManaCost extends Input {
if (Phase.getGameBegins() == 1) {
if (sa.getSourceCard().isCopiedSpell() && sa.isSpell()) {
if (spell.getAfterPayMana() != null) stopSetNext(spell.getAfterPayMana());
else {
if (spell.getAfterPayMana() != null) {
stopSetNext(spell.getAfterPayMana());
} else {
manaCost = new ManaCost("0");
AllZone.getStack().add(spell);
}
@@ -85,7 +103,9 @@ public class Input_PayManaCost extends Input {
}
/**
* <p>resetManaCost.</p>
* <p>
* resetManaCost.
* </p>
*/
private void resetManaCost() {
manaCost = new ManaCost(originalManaCost);
@@ -94,20 +114,24 @@ public class Input_PayManaCost extends Input {
/** {@inheritDoc} */
@Override
public void selectCard(Card card, PlayerZone zone) {
//this is a hack, to prevent lands being able to use mana to pay their own abilities from cards like
//Kher Keep, Pendelhaven, Blinkmoth Nexus, and Mikokoro, Center of the Sea, ....
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
// Kher Keep, Pendelhaven, Blinkmoth Nexus, and Mikokoro, Center of the
// Sea, ....
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;
}
manaCost = Input_PayManaCostUtil.activateManaAbility(spell, card, manaCost);
// only show message if this is the active input
if (AllZone.getInputControl().getInput() == this)
if (AllZone.getInputControl().getInput() == this) {
showMessage();
}
if (manaCost.isPaid()) {
originalCard.setSunburstValue(manaCost.getSunburst());
@@ -117,7 +141,7 @@ public class Input_PayManaCost extends Input {
/** {@inheritDoc} */
@Override
public void selectPlayer(Player player) {
public final void selectPlayer(final Player player) {
if (player.isHuman()) {
if (manaCost.payPhyrexian()) {
@@ -130,36 +154,43 @@ public class Input_PayManaCost extends Input {
}
/**
* <p>done.</p>
* <p>
* done.
* </p>
*/
private void done() {
if (phyLifeToLose > 0)
if (phyLifeToLose > 0) {
AllZone.getHumanPlayer().payLife(phyLifeToLose, originalCard);
}
if (spell.getSourceCard().isCopiedSpell()) {
if (spell.getAfterPayMana() != null) {
stopSetNext(spell.getAfterPayMana());
} else
} else {
AllZone.getInputControl().resetInput();
}
} else {
AllZone.getHumanPlayer().getManaPool().clearPay(spell, false);
resetManaCost();
// if tap ability, tap card
if (spell.isTapAbility())
if (spell.isTapAbility()) {
originalCard.tap();
if (spell.isUntapAbility())
}
if (spell.isUntapAbility()) {
originalCard.untap();
}
// 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);
}
if (spell.getAfterPayMana() != null)
if (spell.getAfterPayMana() != null) {
stopSetNext(spell.getAfterPayMana());
else {
} else {
if (skipStack) {
spell.resolve();
spell.resolve();
} else {
AllZone.getStack().add(spell);
}
@@ -170,17 +201,26 @@ public class Input_PayManaCost extends Input {
/** {@inheritDoc} */
@Override
public void selectButtonCancel() {
public final void selectButtonCancel() {
resetManaCost();
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();
}
/** {@inheritDoc} */
@Override
public void showMessage() {
public final void showMessage() {
ButtonUtil.enableOnlyCancel();
StringBuilder msg = new StringBuilder("Pay Mana Cost: " + manaCost.toString());
@@ -200,6 +240,5 @@ public class Input_PayManaCost extends Input {
done();
}
}
}

View File

@@ -1,5 +1,10 @@
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.Card;
import forge.Constant;
@@ -11,52 +16,65 @@ import forge.card.spellability.Ability_Mana;
import forge.card.spellability.SpellAbility;
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
* @version $Id$
*/
public class Input_PayManaCostUtil {
//all mana abilities start with this and typical look like "tap: add G"
//mana abilities are Strings and are retrieved by calling card.getKeyword()
//taps any card that has mana ability, not just land
// all mana abilities start with this and typical look like "tap: add G"
// mana abilities are Strings and are retrieved by calling card.getKeyword()
// taps any card that has mana ability, not just land
/**
* <p>activateManaAbility.</p>
*
* @param sa a {@link forge.card.spellability.SpellAbility} object.
* @param card a {@link forge.Card} object.
* @param manaCost a {@link forge.card.mana.ManaCost} object.
* <p>
* activateManaAbility.
* </p>
*
* @param sa
* a {@link forge.card.spellability.SpellAbility} 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.
*/
public static ManaCost activateManaAbility(SpellAbility sa, Card card, ManaCost manaCost) {
//make sure computer's lands aren't selected
if (card.getController().isComputer())
public static ManaCost activateManaAbility(final SpellAbility sa, final Card card, ManaCost manaCost) {
// make sure computer's lands aren't selected
if (card.getController().isComputer()) {
return manaCost;
}
if (card instanceof ManaPool)
if (card instanceof ManaPool) {
return ((ManaPool) card).subtractMana(sa, manaCost);
}
ArrayList<Ability_Mana> abilities = getManaAbilities(card);
StringBuilder cneeded = new StringBuilder();
boolean choice = true;
boolean skipExpress = false;
for (String color : Constant.Color.ManaColors)
if (manaCost.isNeeded(color))
for (String color : Constant.Color.ManaColors) {
if (manaCost.isNeeded(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()) {
Ability_Mana ma = it.next();
ma.setActivatingPlayer(AllZone.getHumanPlayer());
if (!ma.canPlay()) it.remove();
else if (!canMake(ma, cneeded.toString())) it.remove();
if (!ma.canPlay()) {
it.remove();
} else if (!canMake(ma, cneeded.toString())) {
it.remove();
}
if (!skipExpress) {
// 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;
}
// 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 (!skipExpress) {
@@ -78,25 +98,30 @@ public class Input_PayManaCostUtil {
ArrayList<Ability_Mana> colorMatches = new ArrayList<Ability_Mana>();
for (Ability_Mana am : abilities) {
if (am.isReflectedMana()){
ArrayList<String> reflectableColors = AbilityFactory_Mana.reflectableMana(am, am.getAbilityFactory(), new ArrayList<String>(), new ArrayList<Card>());
for (String color : reflectableColors){
if (manaCost.isColor(color)) // convert to long before checking if color
if (am.isReflectedMana()) {
ArrayList<String> reflectableColors = AbilityFactory_Mana.reflectableMana(am,
am.getAbilityFactory(), new ArrayList<String>(), new ArrayList<Card>());
for (String color : reflectableColors) {
if (manaCost.isColor(color)) {
// checking if color
colorMatches.add(am);
}
}
}
else{
} else {
String[] m = ManaPool.formatMana(am);
for (String color : m)
if (manaCost.isColor(color)) // convert to long before checking if color
for (String color : m) {
if (manaCost.isColor(color)) {
// checking if color
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.
choice = false;
else if (colorMatches.size() < abilities.size()) {
} else if (colorMatches.size() < abilities.size()) {
// leave behind only color matches
abilities = colorMatches;
}
@@ -105,8 +130,9 @@ public class Input_PayManaCostUtil {
Ability_Mana chosen = abilities.get(0);
if (1 < abilities.size() && choice) {
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);
}
chosen = (Ability_Mana) GuiUtils.getChoice("Choose mana ability", abilities.toArray());
}
@@ -114,48 +140,56 @@ public class Input_PayManaCostUtil {
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;
}
/**
* <p>getManaAbilities.</p>
*
* @param card a {@link forge.Card} object.
* <p>
* getManaAbilities.
* </p>
*
* @param card
* a {@link forge.Card} 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();
}
//color is like "G", returns "Green"
// color is like "G", returns "Green"
/**
* <p>canMake.</p>
*
* @param am a {@link forge.card.spellability.Ability_Mana} object.
* @param mana a {@link java.lang.String} object.
* <p>
* canMake.
* </p>
*
* @param am
* a {@link forge.card.spellability.Ability_Mana} object.
* @param mana
* a {@link java.lang.String} object.
* @return a boolean.
*/
public static boolean canMake(Ability_Mana am, String mana) {
if (mana.contains("1")){
public static boolean canMake(final Ability_Mana am, final String mana) {
if (mana.contains("1")) {
return true;
}
if (mana.contains("S") && am.isSnow()){
if (mana.contains("S") && am.isSnow()) {
return true;
}
if (am.isReflectedMana()){
ArrayList<String> reflectableColors = AbilityFactory_Mana.reflectableMana(am, am.getAbilityFactory(), new ArrayList<String>(), new ArrayList<Card>());
for (String color : reflectableColors){
if (mana.contains(getShortColorString(color))){
if (am.isReflectedMana()) {
ArrayList<String> reflectableColors = AbilityFactory_Mana.reflectableMana(am, am.getAbilityFactory(),
new ArrayList<String>(), new ArrayList<Card>());
for (String color : reflectableColors) {
if (mana.contains(getShortColorString(color))) {
return true;
}
}
}
else{
for (String color : ManaPool.formatMana(am)){
if (mana.contains(color)){
} else {
for (String color : ManaPool.formatMana(am)) {
if (mana.contains(color)) {
return true;
}
}
@@ -164,12 +198,15 @@ public class Input_PayManaCostUtil {
}
/**
* <p>getLongColorString.</p>
*
* @param color a {@link java.lang.String} object.
* <p>
* getLongColorString.
* </p>
*
* @param color
* 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>();
m.put("G", Constant.Color.Green);
m.put("R", Constant.Color.Red);
@@ -180,20 +217,23 @@ public class Input_PayManaCostUtil {
Object o = m.get(color);
if (o == null)
if (o == null) {
o = Constant.Color.Colorless;
}
return o.toString();
}
/**
* <p>getShortColorString.</p>
*
* @param color a {@link java.lang.String} object.
* <p>
* getShortColorString.
* </p>
*
* @param color
* 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>();
m.put(Constant.Color.Green, "G");
m.put(Constant.Color.Red, "R");

View File

@@ -1,20 +1,26 @@
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.spellability.SpellAbility;
//if cost is paid, Command.execute() is called
/**
* <p>Input_PayManaCost_Ability class.</p>
*
* <p>
* Input_PayManaCost_Ability class.
* </p>
*
* @author Forge
* @version $Id$
*/
public class Input_PayManaCost_Ability extends Input {
/**
* Constant <code>serialVersionUID=3836655722696348713L</code>
* Constant <code>serialVersionUID=3836655722696348713L</code>.
*/
private static final long serialVersionUID = 3836655722696348713L;
@@ -26,52 +32,78 @@ public class Input_PayManaCost_Ability extends Input {
private Command paidCommand;
private Command unpaidCommand;
//only used for X costs:
// only used for X costs:
private boolean showOnlyOKButton = false;
/**
* <p>Constructor for Input_PayManaCost_Ability.</p>
*
* @param manaCost a {@link java.lang.String} object.
* @param paid a {@link forge.Command} object.
* <p>
* Constructor for Input_PayManaCost_Ability.
* </p>
*
* @param manaCost
* 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);
}
/**
* <p>Constructor for Input_PayManaCost_Ability.</p>
*
* @param manaCost_2 a {@link java.lang.String} object.
* @param paidCommand_2 a {@link forge.Command} object.
* @param unpaidCommand_2 a {@link forge.Command} object.
* <p>
* Constructor for Input_PayManaCost_Ability.
* </p>
*
* @param manaCost_2
* 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 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);
}
/**
* <p>Constructor for Input_PayManaCost_Ability.</p>
*
* @param m a {@link java.lang.String} object.
* @param manaCost_2 a {@link java.lang.String} object.
* @param paidCommand_2 a {@link forge.Command} object.
* @param unpaidCommand_2 a {@link forge.Command} object.
* <p>
* Constructor for Input_PayManaCost_Ability.
* </p>
*
* @param m
* a {@link java.lang.String} object.
* @param manaCost_2
* 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);
}
/**
* <p>Constructor for Input_PayManaCost_Ability.</p>
*
* @param m a {@link java.lang.String} object.
* @param manaCost_2 a {@link java.lang.String} object.
* @param paidCommand_2 a {@link forge.Command} object.
* @param unpaidCommand_2 a {@link forge.Command} object.
* @param showOKButton a boolean.
* <p>
* Constructor for Input_PayManaCost_Ability.
* </p>
*
* @param m
* a {@link java.lang.String} object.
* @param manaCost_2
* a {@link java.lang.String} object.
* @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) {
@Override
public void resolve() {
@@ -91,34 +123,34 @@ public class Input_PayManaCost_Ability extends Input {
showOnlyOKButton = showOKButton;
}
/**
* <p>resetManaCost.</p>
* <p>
* resetManaCost.
* </p>
*/
public void resetManaCost() {
public final void resetManaCost() {
manaCost = new ManaCost(originalManaCost);
}
/** {@inheritDoc} */
@Override
public void selectCard(Card card, PlayerZone zone) {
//only tap card if the mana is needed
public final void selectCard(final Card card, final PlayerZone zone) {
// only tap card if the mana is needed
manaCost = Input_PayManaCostUtil.activateManaAbility(fakeAbility, card, manaCost);
if (manaCost.isPaid()) {
resetManaCost();
AllZone.getHumanPlayer().getManaPool().clearPay(fakeAbility, false);
stop();
paidCommand.execute();
}
else{
} else {
showMessage();
}
}
/** {@inheritDoc} */
@Override
public void selectButtonCancel() {
public final void selectButtonCancel() {
resetManaCost();
AllZone.getHumanPlayer().getManaPool().unpaid(fakeAbility, true);
stop();
@@ -127,7 +159,7 @@ public class Input_PayManaCost_Ability extends Input {
/** {@inheritDoc} */
@Override
public void selectButtonOK() {
public final void selectButtonOK() {
if (showOnlyOKButton) {
stop();
unpaidCommand.execute();
@@ -136,12 +168,12 @@ public class Input_PayManaCost_Ability extends Input {
/** {@inheritDoc} */
@Override
public void showMessage() {
public final void showMessage() {
ButtonUtil.enableOnlyCancel();
if (showOnlyOKButton)
if (showOnlyOKButton) {
ButtonUtil.enableOnlyOK();
}
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;

View File

@@ -8,91 +8,103 @@ import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Insets;
import java.awt.RenderingHints;
import javax.swing.JButton;
import forge.AllZone;
/**
* The core JButton used throughout the Forge project.
* Follows skin font and theme button styling.
*
/**
* The core JButton used throughout the Forge project. Follows skin font and
* theme button styling.
*
*/
@SuppressWarnings("serial")
public class FButton extends JButton {
public class FButton extends JButton {
/** The img r. */
protected Image imgL, imgM, imgR;
private int w, h = 0;
private boolean allImagesPresent = false;
private FSkin skin;
private AlphaComposite disabledComposite =
AlphaComposite.getInstance(AlphaComposite.SRC_OVER,0.25f);
private AlphaComposite disabledComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.25f);
/**
* Instantiates a new f button.
*
* @param msg
* the msg
*/
public FButton(String msg) {
super(msg);
this.skin = AllZone.getSkin();
this.setOpaque(false);
this.setForeground(skin.txt1a);
this.setForeground(skin.txt1a);
this.setBackground(Color.red);
this.setContentAreaFilled(false);
this.setMargin(new Insets(0,25,0,25));
this.setFont(skin.font1.deriveFont(Font.BOLD,15));
this.setMargin(new Insets(0, 25, 0, 25));
this.setFont(skin.font1.deriveFont(Font.BOLD, 15));
this.imgL = skin.btnLup.getImage();
this.imgM = skin.btnMup.getImage();
this.imgR = skin.btnRup.getImage();
if(this.imgL != null && this.imgM != null && this.imgR != null) {
if (this.imgL != null && this.imgM != null && this.imgR != null) {
allImagesPresent = true;
}
this.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseEntered(java.awt.event.MouseEvent evt) {
if(isEnabled()) {
if (isEnabled()) {
imgL = skin.btnLover.getImage();
imgM = skin.btnMover.getImage();
imgR = skin.btnRover.getImage();
}
}
public void mouseExited(java.awt.event.MouseEvent evt) {
if(isEnabled()) {
if (isEnabled()) {
imgL = skin.btnLup.getImage();
imgM = skin.btnMup.getImage();
imgR = skin.btnRup.getImage();
}
}
public void mousePressed(java.awt.event.MouseEvent evt) {
if(isEnabled()) {
if (isEnabled()) {
imgL = skin.btnLdown.getImage();
imgM = skin.btnMdown.getImage();
imgR = skin.btnRdown.getImage();
}
}
});
});
}
/*
* (non-Javadoc)
*
* @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
*/
protected void paintComponent(Graphics g) {
if(!allImagesPresent) {
if (!allImagesPresent) {
return;
}
Graphics2D g2d = (Graphics2D)g;
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
if(!isEnabled()) {
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
if (!isEnabled()) {
g2d.setComposite(disabledComposite);
}
w = this.getWidth();
h = this.getHeight();
g2d.drawImage(imgL,0,0,h,h,null);
g2d.drawImage(imgM,h,0,w - 2*h,h,null);
g2d.drawImage(imgR,w-h,0,h,h,null);
h = this.getHeight();
g2d.drawImage(imgL, 0, 0, h, h, null);
g2d.drawImage(imgM, h, 0, w - 2 * h, h, null);
g2d.drawImage(imgR, w - h, 0, h, h, null);
super.paintComponent(g);
}
}
}

View File

@@ -2,39 +2,54 @@ package forge.gui.skin;
import java.awt.Graphics;
import java.awt.LayoutManager;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
/** <p>FPanel.</p>
* The core JPanel used throughout the Forge project.
* Allows tiled images and ...
*
/**
* <p>
* FPanel.
* </p>
* The core JPanel used throughout the Forge project. Allows tiled images and
* ...
*
*/
@SuppressWarnings("serial")
public class FPanel extends JPanel {
private ImageIcon bgImg = null;
private int w, h, iw, ih, x, y = 0;
private ImageIcon bgImg = null;
private int w, h, iw, ih, x, y = 0;
/**
* Instantiates a new f panel.
*/
public FPanel() {
super();
}
/**
* Instantiates a new f panel.
*
* @param lm the lm
*/
public FPanel(LayoutManager lm) {
this();
this.setLayout(lm);
}
/* (non-Javadoc)
* @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
*/
protected void paintComponent(Graphics g) {
//System.out.print("\nRepainting. ");
if(this.bgImg != null) {
// System.out.print("\nRepainting. ");
if (this.bgImg != null) {
w = getWidth();
h = getHeight();
iw = this.bgImg.getIconWidth();
ih = this.bgImg.getIconHeight();
while(x < w) {
while(y < h) {
g.drawImage(bgImg.getImage(),x,y,null);
while (x < w) {
while (y < h) {
g.drawImage(bgImg.getImage(), x, y, null);
y += ih;
}
x += iw;
@@ -42,13 +57,18 @@ public class FPanel extends JPanel {
}
x = 0;
}
super.paintComponent(g);
}
/**
* Sets the bG img.
*
* @param icon the new bG img
*/
public void setBGImg(ImageIcon icon) {
this.bgImg = icon;
if(this.bgImg != null) {
this.bgImg = icon;
if (this.bgImg != null) {
this.setOpaque(false);
}
}

View File

@@ -5,27 +5,35 @@ import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.LayoutManager;
import java.awt.RenderingHints;
import javax.swing.JPanel;
/** <p>FRoundedPanel.</p>
* A subclass of JPanel with any of four corners rounded,
* drop shadow, and 1px line border.
/**
* <p>
* 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.
*
*
*/
@SuppressWarnings("serial")
public class FRoundedPanel extends JPanel {
public boolean[] corners = {true,true,true,true}; //NW, SW, SE, NE
private Color shadowColor = new Color(150,150,150,150);
private Color borderColor = Color.black;
private int shadowOffset = 5;
private int cornerRadius = 10;
private boolean showShadow = false;
/** The corners. */
public boolean[] corners = { true, true, true, true }; // NW, SW, SE, NE
private Color shadowColor = new Color(150, 150, 150, 150);
private Color borderColor = Color.black;
private int shadowOffset = 5;
private int cornerRadius = 10;
private boolean showShadow = false;
/**
* <p>FRoundedPanel.</p>
* <p>
* FRoundedPanel.
* </p>
*
* Constructor, null layout manager.
*/
@@ -33,12 +41,16 @@ public class FRoundedPanel extends JPanel {
super();
this.setOpaque(false);
}
/**
* <p>FRoundedPanel.</p>
* <p>
* FRoundedPanel.
* </p>
*
* Constructor.
* @param {@link java.awt.LayoutManager}
*
* @param lm
* the lm
*/
public FRoundedPanel(LayoutManager lm) {
this();
@@ -46,10 +58,14 @@ public class FRoundedPanel extends JPanel {
}
/**
* <p>FRoundedPanel.</p>
* <p>
* FRoundedPanel.
* </p>
*
* Constructor.
* @param {@link java.awt.Graphics}
*
* @param g
* the g
*/
protected void paintComponent(Graphics g) {
super.paintComponent(g);
@@ -57,45 +73,40 @@ public class FRoundedPanel extends JPanel {
int h = getHeight();
int so = shadowOffset;
int r = cornerRadius;
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
if(showShadow) {
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
if (showShadow) {
// Mid, left, right rectangles: shadow
g2d.setColor(shadowColor);
g2d.fillRect(r + so, so, w - 2*r - so, h - so);
g2d.fillRect(so, r + so, r, h - 2*r - so);
g2d.fillRect(w - r, r + so, r, h - 2*r - so);
g2d.fillRect(r + so, so, w - 2 * r - so, h - so);
g2d.fillRect(so, r + so, r, h - 2 * r - so);
g2d.fillRect(w - r, r + so, r, h - 2 * r - so);
// Corners: shadow
// NW
if(corners[0]) {
g2d.fillArc(so, so, 2*r, 2*r, 90, 90);
}
else {
if (corners[0]) {
g2d.fillArc(so, so, 2 * r, 2 * r, 90, 90);
} else {
g2d.fillRect(so, so, r, r);
}
// SW
if(corners[1]) {
g2d.fillArc(so, h - 2*r, 2*r, 2*r, 180, 90);
}
else {
// SW
if (corners[1]) {
g2d.fillArc(so, h - 2 * r, 2 * r, 2 * r, 180, 90);
} else {
g2d.fillRect(so, h - r, r, r);
}
// SE
if(corners[2]) {
g2d.fillArc(w - 2*r, h - 2*r, 2*r, 2*r, 270, 90);
}
else {
if (corners[2]) {
g2d.fillArc(w - 2 * r, h - 2 * r, 2 * r, 2 * r, 270, 90);
} else {
g2d.fillRect(w - r, h - r, r, r);
}
// NE
if(corners[3]) {
g2d.fillArc(w - 2*r, so, 2*r, 2*r, 0, 90);
}
else {
if (corners[3]) {
g2d.fillArc(w - 2 * r, so, 2 * r, 2 * r, 0, 90);
} else {
g2d.fillRect(w - r, so, r, r);
}
} // End if(showShadow)
@@ -103,146 +114,160 @@ public class FRoundedPanel extends JPanel {
so = 0;
so = 0;
}
// Mid, left, right rectangles: content
g2d.setColor(getBackground());
g2d.fillRect(r, 0, w - 2*r - so, h - so);
g2d.fillRect(0, r, r, h - 2*r - so);
g2d.fillRect(w - r - so, r, r, h - 2*r - so);
g2d.fillRect(r, 0, w - 2 * r - so, h - so);
g2d.fillRect(0, r, r, h - 2 * r - so);
g2d.fillRect(w - r - so, r, r, h - 2 * r - so);
// Corners: content
// NW
if(corners[0]) {
g2d.fillArc(0, 0, 2*r, 2*r, 90, 90);
}
else {
if (corners[0]) {
g2d.fillArc(0, 0, 2 * r, 2 * r, 90, 90);
} else {
g2d.fillRect(0, 0, r, r);
}
// SW
if(corners[1]) {
g2d.fillArc(0, h - 2*r - so, 2*r, 2*r, 180, 90);
}
else {
// SW
if (corners[1]) {
g2d.fillArc(0, h - 2 * r - so, 2 * r, 2 * r, 180, 90);
} else {
g2d.fillRect(0, h - r - so, r, r);
}
// SE
if(corners[2]) {
g2d.fillArc(w - 2*r - so, h - 2*r - so, 2*r, 2*r, 270, 90);
}
else {
if (corners[2]) {
g2d.fillArc(w - 2 * r - so, h - 2 * r - so, 2 * r, 2 * r, 270, 90);
} else {
g2d.fillRect(w - r - so, h - r - so, r, r);
}
// NE
if(corners[3]) {
g2d.fillArc(w - 2*r - so, 0, 2*r, 2*r, 0, 90);
}
else {
if (corners[3]) {
g2d.fillArc(w - 2 * r - so, 0, 2 * r, 2 * r, 0, 90);
} else {
g2d.fillRect(w - r - so, 0, r, r);
}
// Mid, left, right rectangles: border
g2d.setColor(this.borderColor);
g2d.drawLine(r, 0, w - r - so, 0);
g2d.drawLine(r, h - so - 1, w - r - so, h - so - 1);
g2d.drawLine(0, r, 0, h - r - so);
g2d.drawLine(w - so - 1, r, w - so - 1, h - r - so);
// Corners: border
// NW
if(corners[0]) {
g2d.drawArc(0, 0, 2*r, 2*r, 90, 90);
}
else {
if (corners[0]) {
g2d.drawArc(0, 0, 2 * r, 2 * r, 90, 90);
} else {
g2d.drawLine(0, 0, r, 0);
g2d.drawLine(0, 0, 0, r);
}
// SW
if(corners[1]) {
g2d.drawArc(0, h - 2*r - so, 2*r, 2*r - 1, 180, 90);
}
else {
// SW
if (corners[1]) {
g2d.drawArc(0, h - 2 * r - so, 2 * r, 2 * r - 1, 180, 90);
} else {
g2d.drawLine(0, h - so - 1, 0, h - r - so - 1);
g2d.drawLine(0, h - so - 1, r, h - so - 1);
}
// SE
if(corners[2]) {
g2d.drawArc(w - 2*r - so, h - 2*r - so, 2*r - 1, 2*r - 1, 270, 90);
}
else {
if (corners[2]) {
g2d.drawArc(w - 2 * r - so, h - 2 * r - so, 2 * r - 1, 2 * r - 1, 270, 90);
} else {
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);
}
// NE
if(corners[3]) {
g2d.drawArc(w - 2*r - so, 0, 2*r - 1, 2*r - 1, 0, 90);
}
else {
if (corners[3]) {
g2d.drawArc(w - 2 * r - so, 0, 2 * r - 1, 2 * r - 1, 0, 90);
} else {
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>
* Sets color of shadow behind rounded panel.
*
* @param {@link java.awt.Color}
* <p>
* setShadowColor.
* </p>
* Sets color of shadow behind rounded panel.
*
* @param c
* the new shadow color
*/
public void setShadowColor(Color c) {
this.shadowColor = c;
}
/**
* <p>setBorderColor.</p>
* Sets color of border around rounded panel.
*
* @param {@link java.awt.Color}
* <p>
* setBorderColor.
* </p>
* Sets color of border around rounded panel.
*
* @param c
* the new border color
*/
public void setBorderColor(Color c) {
this.borderColor = c;
}
/**
* <p>setShadowOffset.</p>
* <p>
* setShadowOffset.
* </p>
* Sets offset of shadow from rounded panel.
*
* @param {@link java.lang.Integer} side
*
* @param i
* the new shadow offset
*/
public void setShadowOffset(int i) {
if(i < 0) {
if (i < 0) {
i = 0;
}
this.shadowOffset = i;
}
/**
* <p>setCornerRadius.</p>
* <p>
* setCornerRadius.
* </p>
* 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) {
if(r < 0) {
if (r < 0) {
r = 0;
}
this.cornerRadius = r;
}
}
/**
* <p>setCorners.</p>
* Sets if corners should be rounded or not in the following order:
* NW, SW, SE, NE
* @param boolean vals[] must be length 4
* <p>
* setCorners.
* </p>
* 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[] ) {
if(vals.length!=4) {
public void setCorners(boolean vals[]) {
if (vals.length != 4) {
throw new IllegalArgumentException("FRoundedPanel > setCorners requires an array of booleans of length 4.");
}
corners = vals;
}
/**
* Sets the show shadow.
*
* @param b
* the new show shadow
*/
public void setShowShadow(boolean b) {
showShadow = b;
}

View File

@@ -11,107 +11,161 @@ import javax.swing.ImageIcon;
import forge.gui.GuiUtils;
/**
* Assembles settings from selected or default theme as appropriate.
* Saves in a hashtable, access using .get(settingName) method.
*
/**
* Assembles settings from selected or default theme as appropriate. Saves in a
* hashtable, access using .get(settingName) method.
*
*/
public class FSkin {
//===== Public fields
public Font font1 = null;
public Font font2 = null;
public ImageIcon texture1 = null;
public ImageIcon texture2 = null;
public ImageIcon texture3 = null;
public ImageIcon btnLup = null;
public ImageIcon btnMup = null;
public ImageIcon btnRup = null;
public ImageIcon btnLover = null;
public ImageIcon btnMover = null;
public ImageIcon btnRover = null;
public ImageIcon btnLdown = null;
public ImageIcon btnMdown = null;
public ImageIcon btnRdown = null;
public ImageIcon splash = null;
public Color bg1a = Color.red;
public Color bg1b = Color.red;
public Color bg2a = Color.red;
public Color bg2b = Color.red;
public Color bg3a = Color.red;
public Color bg3b = Color.red;
public Color txt1a = Color.red;
public Color txt1b = Color.red;
public Color txt2a = Color.red;
public Color txt2b = Color.red;
public Color txt3a = Color.red;
public Color txt3b = Color.red;
public String name = "default";
//===== Private fields
private final String paletteFile = "palette.jpg";
private final String font1file = "font1.ttf";
private final String font2file = "font2.ttf";
private final String texture1file = "texture1.jpg";
private final String texture2file = "texture2.jpg";
private final String texture3file = "texture3.jpg";
private final String btnLupfile = "btnLup.png";
private final String btnMupfile = "btnMup.png";
private final String btnRupfile = "btnRup.png";
private final String btnLoverfile = "btnLover.png";
private final String btnMoverfile = "btnMover.png";
private final String btnRoverfile = "btnRover.png";
private final String btnLdownfile = "btnLdown.png";
private final String btnMdownfile = "btnMdown.png";
private final String btnRdownfile = "btnRdown.png";
private final String splashfile = "bg_splash.jpg";
// ===== Public fields
/** The font1. */
public Font font1 = null;
/** The font2. */
public Font font2 = null;
/** The texture1. */
public ImageIcon texture1 = null;
/** The texture2. */
public ImageIcon texture2 = null;
/** The texture3. */
public ImageIcon texture3 = null;
/** The btn lup. */
public ImageIcon btnLup = null;
/** The btn mup. */
public ImageIcon btnMup = null;
/** The btn rup. */
public ImageIcon btnRup = null;
/** The btn lover. */
public ImageIcon btnLover = null;
/** The btn mover. */
public ImageIcon btnMover = null;
/** The btn rover. */
public ImageIcon btnRover = null;
/** The btn ldown. */
public ImageIcon btnLdown = null;
/** The btn mdown. */
public ImageIcon btnMdown = null;
/** The btn rdown. */
public ImageIcon btnRdown = null;
/** The splash. */
public ImageIcon splash = null;
/** The bg1a. */
public Color bg1a = Color.red;
/** The bg1b. */
public Color bg1b = Color.red;
/** The bg2a. */
public Color bg2a = Color.red;
/** The bg2b. */
public Color bg2b = Color.red;
/** The bg3a. */
public Color bg3a = Color.red;
/** The bg3b. */
public Color bg3b = Color.red;
/** The txt1a. */
public Color txt1a = Color.red;
/** The txt1b. */
public Color txt1b = Color.red;
/** The txt2a. */
public Color txt2a = Color.red;
/** The txt2b. */
public Color txt2b = Color.red;
/** The txt3a. */
public Color txt3a = Color.red;
/** The txt3b. */
public Color txt3b = Color.red;
/** The name. */
public String name = "default";
// ===== Private fields
private final String paletteFile = "palette.jpg";
private final String font1file = "font1.ttf";
private final String font2file = "font2.ttf";
private final String texture1file = "texture1.jpg";
private final String texture2file = "texture2.jpg";
private final String texture3file = "texture3.jpg";
private final String btnLupfile = "btnLup.png";
private final String btnMupfile = "btnMup.png";
private final String btnRupfile = "btnRup.png";
private final String btnLoverfile = "btnLover.png";
private final String btnMoverfile = "btnMover.png";
private final String btnRoverfile = "btnRover.png";
private final String btnLdownfile = "btnLdown.png";
private final String btnMdownfile = "btnMdown.png";
private final String btnRdownfile = "btnRdown.png";
private final String splashfile = "bg_splash.jpg";
private ImageIcon tempImg;
private Font tempFont;
private String skin;
private String notfound = "FSkin.java: \""+skin+
"\" skin can't find ";
private String notfound = "FSkin.java: \"" + skin + "\" 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.
*
* @throws Exception
* the exception
*/
public FSkin() throws Exception {
this("default");
}
/**
* FSkin constructor, using skin name. Generates custom skin settings,
* fonts, and backgrounds.
*
* @param themeName
* @param skinName
* the skin name
* @throws Exception
* the exception
*/
public FSkin(String skinName) throws Exception {
loadFontAndImages("default");
if(!skinName.equals("default")) {
loadFontAndImages("default");
if (!skinName.equals("default")) {
loadFontAndImages(skinName);
}
}
/**
* Loads objects from skin folder, prints brief error if not found.
*
* @param skinName
*/
private void loadFontAndImages(String skinName) {
String dirName = "res/images/skins/"+skinName+"/";
String dirName = "res/images/skins/" + skinName + "/";
// Fonts
font1 = retrieveFont(dirName + font1file);
font2 = retrieveFont(dirName + font2file);
// Images
texture1 = retrieveImage(dirName + texture1file);
texture2 = retrieveImage(dirName + texture2file);
@@ -126,53 +180,57 @@ public class FSkin {
btnMdown = retrieveImage(dirName + btnMdownfile);
btnRdown = retrieveImage(dirName + btnRdownfile);
splash = retrieveImage(dirName + splashfile);
// Color palette
File file= new File(dirName + paletteFile);
File file = new File(dirName + paletteFile);
BufferedImage image;
try {
image = ImageIO.read(file);
bg1a = getColorFromPixel(image.getRGB(10,30));
bg1b = getColorFromPixel(image.getRGB(30,30));
bg2a = getColorFromPixel(image.getRGB(50,30));
bg2b = getColorFromPixel(image.getRGB(70,30));
bg3a = getColorFromPixel(image.getRGB(90,30));
bg3b = getColorFromPixel(image.getRGB(110,30));
txt1a = getColorFromPixel(image.getRGB(10,70));
txt1b = getColorFromPixel(image.getRGB(30,70));
txt2a = getColorFromPixel(image.getRGB(50,70));
txt2b = getColorFromPixel(image.getRGB(70,70));
txt3a = getColorFromPixel(image.getRGB(90,70));
txt3b = getColorFromPixel(image.getRGB(110,70));
bg1a = getColorFromPixel(image.getRGB(10, 30));
bg1b = getColorFromPixel(image.getRGB(30, 30));
bg2a = getColorFromPixel(image.getRGB(50, 30));
bg2b = getColorFromPixel(image.getRGB(70, 30));
bg3a = getColorFromPixel(image.getRGB(90, 30));
bg3b = getColorFromPixel(image.getRGB(110, 30));
txt1a = getColorFromPixel(image.getRGB(10, 70));
txt1b = getColorFromPixel(image.getRGB(30, 70));
txt2a = getColorFromPixel(image.getRGB(50, 70));
txt2b = getColorFromPixel(image.getRGB(70, 70));
txt3a = getColorFromPixel(image.getRGB(90, 70));
txt3b = getColorFromPixel(image.getRGB(110, 70));
} catch (IOException e) {
System.err.println(notfound + paletteFile);
}
}
/**
* <p>retrieveImage.</p>
* Tries to instantiate an image icon from a filename.
* Error reported if not found.
* <p>
* retrieveImage.
* </p>
* Tries to instantiate an image icon from a filename. Error reported if not
* found.
*
* @param {@link java.lang.String} address
* @return a ImageIcon
*/
private ImageIcon retrieveImage(String address) {
tempImg = new ImageIcon(address);
if(tempImg.getIconWidth()==-1) {
if (tempImg.getIconWidth() == -1) {
System.err.println(notfound + address);
}
return tempImg;
}
/**
* <p>retrieveFont.</p>
* 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.
* <p>
* retrieveFont.
* </p>
* 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
* @return a Font
@@ -182,17 +240,15 @@ public class FSkin {
return tempFont;
}
/**
* <p>getColorFromPixel.</p>
* <p>
* getColorFromPixel.
* </p>
*
* @param {@link java.lang.Integer} pixel information
*/
private Color getColorFromPixel(int pixel) {
return new Color(
(pixel & 0x00ff0000) >> 16,
(pixel & 0x0000ff00) >> 8,
(pixel & 0x000000ff)
);
return new Color((pixel & 0x00ff0000) >> 16, (pixel & 0x0000ff00) >> 8, (pixel & 0x000000ff));
}
}

View File

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