mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
Housecleaning on QuestBattle.java.
Updated Deck.java to indicate error if meta property not found.
This commit is contained in:
@@ -362,7 +362,9 @@ public class Deck implements Comparable<Deck>, Serializable {
|
|||||||
public String getMetadata(String key) {
|
public String getMetadata(String key) {
|
||||||
if (metadata.containsKey(key))
|
if (metadata.containsKey(key))
|
||||||
return metadata.get(key);
|
return metadata.get(key);
|
||||||
|
|
||||||
|
System.err.println("In forge.deck/Deck.java, getMetadata() failed "+
|
||||||
|
"for property '"+key+"' in deck '"+getName()+"'.");
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,56 +20,72 @@ public class QuestBattle extends QuestSelectablePanel {
|
|||||||
/** Constant <code>serialVersionUID=3112668476017792084L</code> */
|
/** Constant <code>serialVersionUID=3112668476017792084L</code> */
|
||||||
private static final long serialVersionUID = 3112668476017792084L;
|
private static final long serialVersionUID = 3112668476017792084L;
|
||||||
|
|
||||||
String deckName;
|
private String deckName;
|
||||||
|
|
||||||
|
private static String oppName;
|
||||||
|
private static String oppDiff;
|
||||||
|
private static String oppDesc;
|
||||||
|
private static String oppIconAddress;
|
||||||
|
private static ImageIcon icon;
|
||||||
|
private static Deck oppDeck;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Constructor for QuestBattle.</p>
|
||||||
|
*
|
||||||
|
* @param name a {@link java.lang.String}, stores display name of opponent.
|
||||||
|
* @param diff a {@link java.lang.String} stores difficulty of opponent.
|
||||||
|
* @param description a {@link java.lang.String} stores description of opponent's deck.
|
||||||
|
* @param icon a {@link javax.swing.ImageIcon} stores opponent's icon.
|
||||||
|
*/
|
||||||
|
private QuestBattle(String name, String deck, String diff, String desc, ImageIcon icon) {
|
||||||
|
super(name, diff, desc, icon);
|
||||||
|
this.deckName = deck;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>getBattles.</p>
|
* <p>getBattles.</p>
|
||||||
|
*
|
||||||
|
* Returns list of QuestBattle objects storing data
|
||||||
|
* of the battles currently available.
|
||||||
*
|
*
|
||||||
* @return a {@link java.util.List} object.
|
* @return a {@link java.util.List} object.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// There's got to be a better place for this method.
|
||||||
public static List<QuestSelectablePanel> getBattles() {
|
public static List<QuestSelectablePanel> getBattles() {
|
||||||
List<QuestSelectablePanel> opponentList = new ArrayList<QuestSelectablePanel>();
|
List<QuestSelectablePanel> opponentList = new ArrayList<QuestSelectablePanel>();
|
||||||
|
|
||||||
String[] oppDecks = QuestBattleManager.getOpponents();
|
String[] oppDecks = QuestBattleManager.getOpponents();
|
||||||
for (String oppDeckName : oppDecks) {
|
for (String oppDeckName : oppDecks) {
|
||||||
// Get deck object, its properties, and icon for this opponent.
|
// Get deck object and properties for this opponent.
|
||||||
Deck oppDeck = QuestBattleManager.getAIDeckNewFormat(oppDeckName);
|
oppDeck = QuestBattleManager.getAIDeckNewFormat(oppDeckName);
|
||||||
|
|
||||||
String oppName = oppDeckName.substring(0, oppDeckName.length() - 1).trim();
|
oppName = oppDeck.getMetadata("DisplayName");
|
||||||
String oppDiff = oppDeck.getMetadata("Difficulty");
|
oppDiff = oppDeck.getMetadata("Difficulty");
|
||||||
String oppDesc = oppDeck.getMetadata("Description");
|
oppDesc = oppDeck.getMetadata("Description");
|
||||||
ImageIcon icon = GuiUtils.getIconFromFile(oppName + ".jpg");
|
oppIconAddress = oppDeck.getMetadata("Icon");
|
||||||
|
|
||||||
// SHOULD BE HANDLED IN getMetadata(), will be soon enough.
|
icon = GuiUtils.getIconFromFile(oppName + ".jpg");
|
||||||
if(oppDiff.equals("")) { System.out.println(oppDeckName+" missing deck difficulty."); oppName = "<<Unknown>>"; }
|
|
||||||
if(oppDesc.equals("")) { System.out.println(oppDeckName+" missing deck description."); oppName = "<<Unknown>>"; }
|
// If non-default icon defined, use it
|
||||||
|
if(!oppIconAddress.equals("")) {
|
||||||
|
icon = GuiUtils.getIconFromFile(oppIconAddress + ".jpg");
|
||||||
|
}
|
||||||
|
|
||||||
// Add to list of current quest opponents.
|
// Add to list of current quest opponents.
|
||||||
opponentList.add(
|
opponentList.add(
|
||||||
new QuestBattle(oppDeckName, oppDiff, oppDesc, icon)
|
new QuestBattle(oppName, oppDeckName, oppDiff, oppDesc, icon)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return opponentList;
|
return opponentList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** {@inheritDoc} */
|
||||||
* <p>Constructor for QuestBattle.</p>
|
|
||||||
*
|
|
||||||
* @param name a {@link java.lang.String} object.
|
|
||||||
* @param difficulty a {@link java.lang.String} object.
|
|
||||||
* @param description a {@link java.lang.String} object.
|
|
||||||
* @param icon a {@link javax.swing.ImageIcon} object.
|
|
||||||
*/
|
|
||||||
private QuestBattle(String name, String difficulty, String description, ImageIcon icon) {
|
|
||||||
super(name.substring(0, name.length() - 2), difficulty, description, icon);
|
|
||||||
|
|
||||||
this.deckName = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
// Called by ???? to get deck name for image icon generation.
|
||||||
|
// Exception should be thrown somewhere if image can't be found.
|
||||||
return deckName;
|
return deckName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user