mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
checkstyle
This commit is contained in:
@@ -1,117 +1,156 @@
|
||||
package forge.quest.gui.main;
|
||||
|
||||
import forge.item.CardPrinted;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forge.item.CardPrinted;
|
||||
|
||||
/**
|
||||
* <p>QuestQuest class.</p>
|
||||
* <p>
|
||||
* QuestQuest class.
|
||||
* </p>
|
||||
*
|
||||
* MODEL - A single quest event data instance, including meta,
|
||||
* deck, and quest-specific properties.
|
||||
* MODEL - A single quest event data instance, including meta, deck, and
|
||||
* quest-specific properties.
|
||||
*
|
||||
*/
|
||||
public class QuestChallenge extends QuestEvent {
|
||||
// ID (default -1, should be explicitly set at later time.)
|
||||
/** The id. */
|
||||
public int id = -1;
|
||||
|
||||
|
||||
// Default vals if none provided for this ID
|
||||
public int aiLife = 25;
|
||||
public int creditsReward = 100;
|
||||
public String cardReward = "1 colorless rare";
|
||||
public boolean repeatable = false;
|
||||
public int winsReqd = 20;
|
||||
/** The ai life. */
|
||||
public int aiLife = 25;
|
||||
|
||||
/** The credits reward. */
|
||||
public int creditsReward = 100;
|
||||
|
||||
/** The card reward. */
|
||||
public String cardReward = "1 colorless rare";
|
||||
|
||||
/** The repeatable. */
|
||||
public boolean repeatable = false;
|
||||
|
||||
/** The wins reqd. */
|
||||
public int winsReqd = 20;
|
||||
|
||||
// Other cards used in assignment: starting, and reward.
|
||||
/** The human extra cards. */
|
||||
public List<String> humanExtraCards = new ArrayList<String>();
|
||||
public List<String> aiExtraCards = new ArrayList<String>();
|
||||
public List<CardPrinted> cardRewardList = new ArrayList<CardPrinted>();
|
||||
|
||||
/** The ai extra cards. */
|
||||
public List<String> aiExtraCards = new ArrayList<String>();
|
||||
|
||||
/** The card reward list. */
|
||||
public List<CardPrinted> cardRewardList = new ArrayList<CardPrinted>();
|
||||
|
||||
/**
|
||||
* Instantiates a new quest challenge.
|
||||
*/
|
||||
public QuestChallenge() {
|
||||
super();
|
||||
eventType = "challenge";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>getAILife.</p>
|
||||
*
|
||||
* <p>
|
||||
* getAILife.
|
||||
* </p>
|
||||
*
|
||||
* @return {@link java.lang.Integer}.
|
||||
*/
|
||||
public final int getAILife() {
|
||||
return aiLife;
|
||||
public final int getAILife() {
|
||||
return aiLife;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>getCardReward.</p>
|
||||
*
|
||||
* <p>
|
||||
* getCardReward.
|
||||
* </p>
|
||||
*
|
||||
* @return {@link java.lang.String}.
|
||||
*/
|
||||
public final String getCardReward() {
|
||||
return cardReward;
|
||||
public final String getCardReward() {
|
||||
return cardReward;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>getCreditsReward.</p>
|
||||
*
|
||||
* <p>
|
||||
* getCreditsReward.
|
||||
* </p>
|
||||
*
|
||||
* @return {@link java.lang.Integer}.
|
||||
*/
|
||||
public final int getCreditsReward() {
|
||||
return creditsReward;
|
||||
public final int getCreditsReward() {
|
||||
return creditsReward;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>getId.</p>
|
||||
*
|
||||
* <p>
|
||||
* getId.
|
||||
* </p>
|
||||
*
|
||||
* @return {@link java.lang.Integer}.
|
||||
*/
|
||||
public final int getId() {
|
||||
return id;
|
||||
public final int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>getRepeatable.</p>
|
||||
*
|
||||
* <p>
|
||||
* getRepeatable.
|
||||
* </p>
|
||||
*
|
||||
* @return {@link java.lang.Boolean}.
|
||||
*/
|
||||
public final boolean getRepeatable() {
|
||||
return repeatable;
|
||||
public final boolean getRepeatable() {
|
||||
return repeatable;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>getWinsReqd.</p>
|
||||
*
|
||||
* <p>
|
||||
* getWinsReqd.
|
||||
* </p>
|
||||
*
|
||||
* @return {@link java.lang.Integer}.
|
||||
*/
|
||||
public final int getWinsReqd() {
|
||||
return winsReqd;
|
||||
public final int getWinsReqd() {
|
||||
return winsReqd;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>getAIExtraCards.</p>
|
||||
* <p>
|
||||
* getAIExtraCards.
|
||||
* </p>
|
||||
* Retrieves list of cards AI has in play at the beginning of this quest.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @return the aI extra cards
|
||||
*/
|
||||
public final List<String> getAIExtraCards() {
|
||||
return aiExtraCards;
|
||||
public final List<String> getAIExtraCards() {
|
||||
return aiExtraCards;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>getHumanExtraCards.</p>
|
||||
* <p>
|
||||
* getHumanExtraCards.
|
||||
* </p>
|
||||
* Retrieves list of cards human has in play at the beginning of this quest.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @return the human extra cards
|
||||
*/
|
||||
public final List<String> getHumanExtraCards() {
|
||||
return humanExtraCards;
|
||||
public final List<String> getHumanExtraCards() {
|
||||
return humanExtraCards;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>getCardRewardList.</p>
|
||||
*
|
||||
* @return
|
||||
* <p>
|
||||
* getCardRewardList.
|
||||
* </p>
|
||||
*
|
||||
* @return the card reward list
|
||||
*/
|
||||
public final List<CardPrinted> getCardRewardList() {
|
||||
return cardRewardList;
|
||||
public final List<CardPrinted> getCardRewardList() {
|
||||
return cardRewardList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,33 +4,39 @@ import javax.swing.JLabel;
|
||||
|
||||
import forge.gui.GuiUtils;
|
||||
|
||||
/**
|
||||
* <p>QuestQuestPanel.</p>
|
||||
* VIEW - Creates a QuestSelectablePanel instance for a "quest" style event.
|
||||
/**
|
||||
* <p>
|
||||
* QuestQuestPanel.
|
||||
* </p>
|
||||
* VIEW - Creates a QuestSelectablePanel instance for a "quest" style event.
|
||||
*/
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class QuestChallengePanel extends QuestSelectablePanel {
|
||||
|
||||
|
||||
private JLabel repeatabilityLabel;
|
||||
|
||||
/** <p>QuestChallengePanel.</p>
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* QuestChallengePanel.
|
||||
* </p>
|
||||
* Constructor, using challenge data instance.
|
||||
*
|
||||
* @param {@link forge.quest.gui.main.QuestChallenge}
|
||||
* @param q
|
||||
* the q
|
||||
*/
|
||||
public QuestChallengePanel(QuestChallenge q) {
|
||||
public QuestChallengePanel(final QuestChallenge q) {
|
||||
super(q);
|
||||
|
||||
GuiUtils.addGap(super.rootPanel,7);
|
||||
|
||||
|
||||
GuiUtils.addGap(super.rootPanel, 7);
|
||||
|
||||
if (q.getRepeatable()) {
|
||||
repeatabilityLabel = new JLabel("This challenge is repeatable");
|
||||
} else {
|
||||
repeatabilityLabel = new JLabel("This challenge is not repeatable");
|
||||
}
|
||||
|
||||
|
||||
super.rootPanel.add(repeatabilityLabel);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
package forge.quest.gui.main;
|
||||
|
||||
/**
|
||||
* <p>QuestDuel class.</p>
|
||||
* <p>
|
||||
* QuestDuel class.
|
||||
* </p>
|
||||
* MODEL - A single duel event data instance, including meta and deck.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class QuestDuel extends QuestEvent {
|
||||
|
||||
public class QuestDuel extends QuestEvent {
|
||||
|
||||
/**
|
||||
* Instantiates a new quest duel.
|
||||
*/
|
||||
public QuestDuel() {
|
||||
super();
|
||||
eventType = "duel";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,19 +1,24 @@
|
||||
package forge.quest.gui.main;
|
||||
|
||||
|
||||
/**
|
||||
* <p>QuestDuelPanel.</p>
|
||||
* VIEW - Creates a QuestSelectablePanel instance for a "battle" style event.
|
||||
/**
|
||||
* <p>
|
||||
* QuestDuelPanel.
|
||||
* </p>
|
||||
* VIEW - Creates a QuestSelectablePanel instance for a "battle" style event.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class QuestDuelPanel extends QuestSelectablePanel {
|
||||
|
||||
/** <p>QuestDuelPanel.</p>
|
||||
/**
|
||||
* <p>
|
||||
* QuestDuelPanel.
|
||||
* </p>
|
||||
* Constructor, using duel data instance.
|
||||
*
|
||||
* @param {@link forge.quest.gui.main.QuestDuel}
|
||||
* @param d
|
||||
* the d
|
||||
*/
|
||||
public QuestDuelPanel(QuestDuel d) {
|
||||
public QuestDuelPanel(final QuestDuel d) {
|
||||
super(d);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,82 +2,111 @@ package forge.quest.gui.main;
|
||||
|
||||
import forge.deck.Deck;
|
||||
|
||||
/**
|
||||
* <p>QuestEvent.</p>
|
||||
*
|
||||
/**
|
||||
* <p>
|
||||
* QuestEvent.
|
||||
* </p>
|
||||
*
|
||||
* MODEL - A basic event instance in Quest mode. Can be extended for use in
|
||||
* unique event types: battles, quests, and others.
|
||||
*/
|
||||
public class QuestEvent {
|
||||
// Default vals if none provided in the event file.
|
||||
public Deck eventDeck = null;
|
||||
public String title = "Mystery Event";
|
||||
public String description = "";
|
||||
public String difficulty = "Medium";
|
||||
public String icon = "Unknown.jpg";
|
||||
public String name = "Noname";
|
||||
public String eventType = null;
|
||||
|
||||
/** The event deck. */
|
||||
public Deck eventDeck = null;
|
||||
|
||||
/** The title. */
|
||||
public String title = "Mystery Event";
|
||||
|
||||
/** The description. */
|
||||
public String description = "";
|
||||
|
||||
/** The difficulty. */
|
||||
public String difficulty = "Medium";
|
||||
|
||||
/** The icon. */
|
||||
public String icon = "Unknown.jpg";
|
||||
|
||||
/** The name. */
|
||||
public String name = "Noname";
|
||||
|
||||
/** The event type. */
|
||||
public String eventType = null;
|
||||
|
||||
/**
|
||||
* <p>getTitle.</p>
|
||||
*
|
||||
* <p>
|
||||
* getTitle.
|
||||
* </p>
|
||||
*
|
||||
* @return a {@link java.lang.String}.
|
||||
*/
|
||||
public final String getTitle() {
|
||||
return title;
|
||||
public final String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getDifficulty.</p>
|
||||
*
|
||||
* <p>
|
||||
* getDifficulty.
|
||||
* </p>
|
||||
*
|
||||
* @return a {@link java.lang.String}.
|
||||
*/
|
||||
public final String getDifficulty() {
|
||||
return difficulty;
|
||||
public final String getDifficulty() {
|
||||
return difficulty;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>getDescription.</p>
|
||||
*
|
||||
* <p>
|
||||
* getDescription.
|
||||
* </p>
|
||||
*
|
||||
* @return a {@link java.lang.String}.
|
||||
*/
|
||||
public final String getDescription() {
|
||||
return description;
|
||||
public final String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>getEventDeck.</p>
|
||||
* <p>
|
||||
* getEventDeck.
|
||||
* </p>
|
||||
*
|
||||
* @return {@link forge.deck.Deck}
|
||||
*/
|
||||
public final Deck getEventDeck() {
|
||||
return eventDeck;
|
||||
return eventDeck;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>getEventDeck.</p>
|
||||
* <p>
|
||||
* getEventDeck.
|
||||
* </p>
|
||||
*
|
||||
* @return {@link forge.deck.Deck}
|
||||
*/
|
||||
public final String getEventType() {
|
||||
return eventType;
|
||||
return eventType;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>getIcon.</p>
|
||||
*
|
||||
* @return a {@link java.lang.String}.
|
||||
*/
|
||||
public final String getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getName.</p>
|
||||
*
|
||||
* <p>
|
||||
* getIcon.
|
||||
* </p>
|
||||
*
|
||||
* @return a {@link java.lang.String}.
|
||||
*/
|
||||
public final String getName() {
|
||||
return name;
|
||||
public final String getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* getName.
|
||||
* </p>
|
||||
*
|
||||
* @return a {@link java.lang.String}.
|
||||
*/
|
||||
public final String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package forge.quest.gui.main;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.FileUtil;
|
||||
import forge.deck.DeckManager;
|
||||
@@ -8,295 +14,336 @@ import forge.properties.NewConstants;
|
||||
import forge.quest.data.QuestPreferences;
|
||||
import forge.quest.data.QuestUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>QuestEventManager.</p>
|
||||
* <p>
|
||||
* QuestEventManager.
|
||||
* </p>
|
||||
* MODEL - Manages collections of quest events (duelsquests, etc.)
|
||||
*
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class QuestEventManager {
|
||||
public List<QuestDuel> easyAIduels = null;
|
||||
public List<QuestDuel> mediumAIduels = null;
|
||||
public List<QuestDuel> hardAIduels = null;
|
||||
public List<QuestDuel> veryHardAIduels = null;
|
||||
|
||||
public List<QuestDuel> allDuels = null;
|
||||
public List<QuestChallenge> allChallenges = null;
|
||||
|
||||
/**<p>assembleAllEvents.</p> *
|
||||
* Reads all duel and challenge files and instantiates all events,
|
||||
* and difficulty lists accordingly. Should be used sparingly.
|
||||
|
||||
/** The easy a iduels. */
|
||||
public List<QuestDuel> easyAIduels = null;
|
||||
|
||||
/** The medium a iduels. */
|
||||
public List<QuestDuel> mediumAIduels = null;
|
||||
|
||||
/** The hard a iduels. */
|
||||
public List<QuestDuel> hardAIduels = null;
|
||||
|
||||
/** The very hard a iduels. */
|
||||
public List<QuestDuel> veryHardAIduels = null;
|
||||
|
||||
/** The all duels. */
|
||||
public List<QuestDuel> allDuels = null;
|
||||
|
||||
/** The all challenges. */
|
||||
public List<QuestChallenge> allChallenges = null;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* assembleAllEvents.
|
||||
* </p>
|
||||
* * Reads all duel and challenge files and instantiates all events, and
|
||||
* difficulty lists accordingly. Should be used sparingly.
|
||||
*/
|
||||
public void assembleAllEvents() {
|
||||
public final void assembleAllEvents() {
|
||||
this.allDuels = new ArrayList<QuestDuel>();
|
||||
this.allChallenges = new ArrayList<QuestChallenge>();
|
||||
|
||||
|
||||
List<String> contents;
|
||||
QuestEvent tempEvent;
|
||||
|
||||
|
||||
File file = ForgeProps.getFile(NewConstants.QUEST.DECKS);
|
||||
|
||||
DeckManager manager = new DeckManager(file);
|
||||
|
||||
|
||||
File[] allFiles = ForgeProps.getFile(NewConstants.QUEST.DECKS).listFiles(DeckManager.DCK_FILE_FILTER);
|
||||
|
||||
for(File f : allFiles) {
|
||||
|
||||
for (File f : allFiles) {
|
||||
contents = FileUtil.readFile(f);
|
||||
|
||||
if(contents.get(0).trim().equals("[quest]")) {
|
||||
if (contents.get(0).trim().equals("[quest]")) {
|
||||
tempEvent = new QuestChallenge();
|
||||
assembleChallengeUniquedata(contents,(QuestChallenge)tempEvent);
|
||||
allChallenges.add((QuestChallenge)tempEvent);
|
||||
assembleChallengeUniquedata(contents, (QuestChallenge) tempEvent);
|
||||
allChallenges.add((QuestChallenge) tempEvent);
|
||||
} // End if([quest])
|
||||
else {
|
||||
tempEvent = new QuestDuel();
|
||||
assembleDuelUniquedata(contents,(QuestDuel)tempEvent);
|
||||
allDuels.add((QuestDuel)tempEvent);
|
||||
assembleDuelUniquedata(contents, (QuestDuel) tempEvent);
|
||||
allDuels.add((QuestDuel) tempEvent);
|
||||
}
|
||||
|
||||
|
||||
// Assemble metadata (may not be necessary later) and deck object.
|
||||
assembleEventMetadata(contents,tempEvent);
|
||||
assembleEventMetadata(contents, tempEvent);
|
||||
tempEvent.eventDeck = manager.getDeck(tempEvent.getName());
|
||||
} // End for(allFiles)
|
||||
|
||||
assembleDuelDifficultyLists();
|
||||
|
||||
|
||||
assembleDuelDifficultyLists();
|
||||
|
||||
} // End assembleAllEvents()
|
||||
|
||||
|
||||
/**
|
||||
* <p>assembleDuelUniqueData.</p>
|
||||
* <p>
|
||||
* assembleDuelUniqueData.
|
||||
* </p>
|
||||
* Handler for any unique data contained in duel files.
|
||||
*
|
||||
* @param contents
|
||||
* @param qd
|
||||
*/
|
||||
private void assembleDuelUniquedata(List<String> contents, QuestDuel qd) {
|
||||
private void assembleDuelUniquedata(final List<String> contents, final QuestDuel qd) {
|
||||
int eqpos;
|
||||
String key, value;
|
||||
|
||||
for(String s : contents) {
|
||||
if (s.equals("[metadata]")) { break; }
|
||||
if (s.equals("[duel]")) { continue; }
|
||||
if (s.equals("")) { continue; }
|
||||
|
||||
|
||||
for (String s : contents) {
|
||||
if (s.equals("[metadata]")) {
|
||||
break;
|
||||
}
|
||||
if (s.equals("[duel]")) {
|
||||
continue;
|
||||
}
|
||||
if (s.equals("")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
eqpos = s.indexOf('=');
|
||||
if(eqpos < 0) { continue; }
|
||||
if (eqpos < 0) {
|
||||
continue;
|
||||
}
|
||||
key = s.substring(0, eqpos);
|
||||
value = s.substring(eqpos + 1);
|
||||
|
||||
if (key.equalsIgnoreCase("Name")) {
|
||||
qd.name = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>assembleChallengeUniquedata.</p>
|
||||
* <p>
|
||||
* assembleChallengeUniquedata.
|
||||
* </p>
|
||||
* Handler for any unique data contained in a challenge file.
|
||||
*
|
||||
* @param contents
|
||||
* @param qc
|
||||
*/
|
||||
private void assembleChallengeUniquedata(List<String> contents, QuestChallenge qc) {
|
||||
private void assembleChallengeUniquedata(final List<String> contents, final QuestChallenge qc) {
|
||||
int eqpos;
|
||||
String key, value;
|
||||
|
||||
|
||||
// Unique properties
|
||||
for(String s : contents) {
|
||||
if (s.equals("[metadata]")) { break; }
|
||||
if (s.equals("[quest]")) { continue; }
|
||||
if (s.equals("")) { continue; }
|
||||
|
||||
for (String s : contents) {
|
||||
if (s.equals("[metadata]")) {
|
||||
break;
|
||||
}
|
||||
if (s.equals("[quest]")) {
|
||||
continue;
|
||||
}
|
||||
if (s.equals("")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
eqpos = s.indexOf('=');
|
||||
key = s.substring(0, eqpos);
|
||||
value = s.substring(eqpos + 1).trim();
|
||||
|
||||
if (key.equalsIgnoreCase("ID")) {
|
||||
qc.id = Integer.parseInt(value);
|
||||
}
|
||||
else if (key.equalsIgnoreCase("Repeat")) {
|
||||
} else if (key.equalsIgnoreCase("Repeat")) {
|
||||
qc.repeatable = Boolean.parseBoolean(value);
|
||||
}
|
||||
else if (key.equalsIgnoreCase("AILife")) {
|
||||
} else if (key.equalsIgnoreCase("AILife")) {
|
||||
qc.aiLife = Integer.parseInt(value);
|
||||
}
|
||||
else if (key.equalsIgnoreCase("Wins")) {
|
||||
} else if (key.equalsIgnoreCase("Wins")) {
|
||||
qc.winsReqd = Integer.parseInt(value);
|
||||
}
|
||||
else if (key.equalsIgnoreCase("Credit Reward")) {
|
||||
} else if (key.equalsIgnoreCase("Credit Reward")) {
|
||||
qc.creditsReward = Integer.parseInt(value);
|
||||
}
|
||||
else if (key.equalsIgnoreCase("Card Reward")) {
|
||||
} else if (key.equalsIgnoreCase("Card Reward")) {
|
||||
qc.cardReward = value;
|
||||
qc.cardRewardList = QuestUtil.generateCardRewardList(value);
|
||||
}
|
||||
// Human extra card list assembled here.
|
||||
else if(key.equalsIgnoreCase("HumanExtras") && !value.equals("")) {
|
||||
else if (key.equalsIgnoreCase("HumanExtras") && !value.equals("")) {
|
||||
String[] names = value.split("\\|");
|
||||
List<String> templist = new ArrayList<String>();
|
||||
|
||||
for(String n : names) {
|
||||
|
||||
for (String n : names) {
|
||||
templist.add(n);
|
||||
}
|
||||
|
||||
qc.humanExtraCards = templist;
|
||||
}
|
||||
// AI extra card list assembled here.
|
||||
else if(key.equalsIgnoreCase("AIExtras") && !value.equals("")) {
|
||||
else if (key.equalsIgnoreCase("AIExtras") && !value.equals("")) {
|
||||
String[] names = value.split("\\|");
|
||||
List<String> templist = new ArrayList<String>();
|
||||
|
||||
for(String n : names) {
|
||||
|
||||
for (String n : names) {
|
||||
templist.add(n);
|
||||
}
|
||||
|
||||
qc.aiExtraCards = templist;
|
||||
}
|
||||
// Card reward list assembled here.
|
||||
else if(key.equalsIgnoreCase("Card Reward")) {
|
||||
else if (key.equalsIgnoreCase("Card Reward")) {
|
||||
qc.cardReward = value;
|
||||
qc.cardRewardList = QuestUtil.generateCardRewardList(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>assembleEventMetadata.</p>
|
||||
* <p>
|
||||
* assembleEventMetadata.
|
||||
* </p>
|
||||
* Handler for metadata contained in event files.
|
||||
*
|
||||
* @param contents
|
||||
* @param qe
|
||||
*/
|
||||
private void assembleEventMetadata(List<String> contents, QuestEvent qe) {
|
||||
private void assembleEventMetadata(final List<String> contents, final QuestEvent qe) {
|
||||
int eqpos;
|
||||
String key, value;
|
||||
|
||||
for(String s : contents) {
|
||||
|
||||
for (String s : contents) {
|
||||
s = s.trim();
|
||||
eqpos = s.indexOf('=');
|
||||
|
||||
if (s.equals("[main]")) { break; }
|
||||
if (s.equals("[metadata]")) { continue; }
|
||||
if (s.equals("")) { continue; }
|
||||
if (eqpos==-1) { continue; }
|
||||
|
||||
|
||||
if (s.equals("[main]")) {
|
||||
break;
|
||||
}
|
||||
if (s.equals("[metadata]")) {
|
||||
continue;
|
||||
}
|
||||
if (s.equals("")) {
|
||||
continue;
|
||||
}
|
||||
if (eqpos == -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
key = s.substring(0, eqpos);
|
||||
value = s.substring(eqpos + 1);
|
||||
|
||||
if (key.equalsIgnoreCase("Name")) {
|
||||
qe.name = value;
|
||||
}
|
||||
else if (key.equalsIgnoreCase("Title")) {
|
||||
} else if (key.equalsIgnoreCase("Title")) {
|
||||
qe.title = value;
|
||||
}
|
||||
else if (key.equalsIgnoreCase("Difficulty")) {
|
||||
} else if (key.equalsIgnoreCase("Difficulty")) {
|
||||
qe.difficulty = value;
|
||||
}
|
||||
else if (key.equalsIgnoreCase("Description")) {
|
||||
} else if (key.equalsIgnoreCase("Description")) {
|
||||
qe.description = value;
|
||||
}
|
||||
else if (key.equalsIgnoreCase("Icon")) {
|
||||
} else if (key.equalsIgnoreCase("Icon")) {
|
||||
qe.icon = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>getAllDuels.</p>
|
||||
* <p>
|
||||
* getAllDuels.
|
||||
* </p>
|
||||
* Returns complete list of all duel objects.
|
||||
*
|
||||
*
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
public List<QuestDuel> getAllDuels() {
|
||||
public final List<QuestDuel> getAllDuels() {
|
||||
return this.allDuels;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getAllChallenges.</p>
|
||||
* Returns complete list of all challenge objects.
|
||||
*
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
public List<QuestChallenge> getAllChallenges() {
|
||||
return this.allChallenges;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>assembleDuelDifficultyLists.</p>
|
||||
* Assemble duel deck difficulty lists
|
||||
*/
|
||||
private void assembleDuelDifficultyLists() {
|
||||
easyAIduels = new ArrayList<QuestDuel>();
|
||||
mediumAIduels = new ArrayList<QuestDuel>();
|
||||
hardAIduels = new ArrayList<QuestDuel>();
|
||||
veryHardAIduels = new ArrayList<QuestDuel>();
|
||||
String s;
|
||||
|
||||
for(QuestDuel qd : allDuels) {
|
||||
s = qd.getDifficulty();
|
||||
if(s.equalsIgnoreCase("easy")) {
|
||||
easyAIduels.add(qd);
|
||||
}
|
||||
else if(s.equalsIgnoreCase("medium")) {
|
||||
mediumAIduels.add(qd);
|
||||
}
|
||||
else if(s.equalsIgnoreCase("hard")) {
|
||||
hardAIduels.add(qd);
|
||||
}
|
||||
else if(s.equalsIgnoreCase("very hard")) {
|
||||
veryHardAIduels.add(qd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getDuelOpponent.</p>
|
||||
* Returns specific duel opponent from current shuffle of available duels.
|
||||
* This is to make sure that the opponents do not change
|
||||
* when the deck editor is launched.
|
||||
*
|
||||
* @param aiDeck a {@link java.util.List} object.
|
||||
* @param number a int.
|
||||
* <p>
|
||||
* getAllChallenges.
|
||||
* </p>
|
||||
* Returns complete list of all challenge objects.
|
||||
*
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
public final List<QuestChallenge> getAllChallenges() {
|
||||
return this.allChallenges;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* assembleDuelDifficultyLists.
|
||||
* </p>
|
||||
* Assemble duel deck difficulty lists
|
||||
*/
|
||||
private void assembleDuelDifficultyLists() {
|
||||
easyAIduels = new ArrayList<QuestDuel>();
|
||||
mediumAIduels = new ArrayList<QuestDuel>();
|
||||
hardAIduels = new ArrayList<QuestDuel>();
|
||||
veryHardAIduels = new ArrayList<QuestDuel>();
|
||||
String s;
|
||||
|
||||
for (QuestDuel qd : allDuels) {
|
||||
s = qd.getDifficulty();
|
||||
if (s.equalsIgnoreCase("easy")) {
|
||||
easyAIduels.add(qd);
|
||||
} else if (s.equalsIgnoreCase("medium")) {
|
||||
mediumAIduels.add(qd);
|
||||
} else if (s.equalsIgnoreCase("hard")) {
|
||||
hardAIduels.add(qd);
|
||||
} else if (s.equalsIgnoreCase("very hard")) {
|
||||
veryHardAIduels.add(qd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* getDuelOpponent.
|
||||
* </p>
|
||||
* Returns specific duel opponent from current shuffle of available duels.
|
||||
* This is to make sure that the opponents do not change when the deck
|
||||
* editor is launched.
|
||||
*
|
||||
* @param aiDeck
|
||||
* a {@link java.util.List} object.
|
||||
* @param number
|
||||
* a int.
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
private static QuestDuel getDuelOpponentByNumber(List<QuestDuel> aiDeck, int n) {
|
||||
private static QuestDuel getDuelOpponentByNumber(final List<QuestDuel> aiDeck, final int n) {
|
||||
List<QuestDuel> deckListCopy = new ArrayList<QuestDuel>(aiDeck);
|
||||
Collections.shuffle(deckListCopy, new Random(AllZone.getQuestData().getRandomSeed()));
|
||||
|
||||
return deckListCopy.get(n);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>getChallengeOpponentByNumber.</p>
|
||||
* Returns specific challenge event using its ID.
|
||||
* This is to make sure that the opponents do not change
|
||||
* when the deck editor is launched.
|
||||
* <p>
|
||||
* getChallengeOpponentByNumber.
|
||||
* </p>
|
||||
* Returns specific challenge event using its ID. This is to make sure that
|
||||
* the opponents do not change when the deck editor is launched.
|
||||
*
|
||||
* @param n
|
||||
* @return
|
||||
*/
|
||||
private QuestChallenge getChallengeEventByNumber(int n) {
|
||||
for(QuestChallenge qc : allChallenges) {
|
||||
if(qc.getId()==n) {
|
||||
private QuestChallenge getChallengeEventByNumber(final int n) {
|
||||
for (QuestChallenge qc : allChallenges) {
|
||||
if (qc.getId() == n) {
|
||||
return qc;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>generateDuels.</p>
|
||||
* <p>
|
||||
* generateDuels.
|
||||
* </p>
|
||||
* Generates an array of new duel opponents based on current win conditions.
|
||||
*
|
||||
*
|
||||
* @return an array of {@link java.lang.String} objects.
|
||||
*/
|
||||
public List<QuestDuel> generateDuels() {
|
||||
|
||||
public final List<QuestDuel> generateDuels() {
|
||||
|
||||
int index = AllZone.getQuestData().getDifficultyIndex();
|
||||
List<QuestDuel> duelOpponents = new ArrayList<QuestDuel>();
|
||||
|
||||
@@ -304,20 +351,18 @@ public class QuestEventManager {
|
||||
duelOpponents.add(getDuelOpponentByNumber(easyAIduels, 0));
|
||||
duelOpponents.add(getDuelOpponentByNumber(easyAIduels, 1));
|
||||
duelOpponents.add(getDuelOpponentByNumber(easyAIduels, 2));
|
||||
}
|
||||
else if (AllZone.getQuestData().getWin() == QuestPreferences.getWinsForMediumAI(index)) {
|
||||
} else if (AllZone.getQuestData().getWin() == QuestPreferences.getWinsForMediumAI(index)) {
|
||||
duelOpponents.add(getDuelOpponentByNumber(easyAIduels, 0));
|
||||
duelOpponents.add(getDuelOpponentByNumber(mediumAIduels, 0));
|
||||
duelOpponents.add(getDuelOpponentByNumber(mediumAIduels, 1));
|
||||
}
|
||||
else if (AllZone.getQuestData().getWin() < QuestPreferences.getWinsForHardAI(index)) {
|
||||
} else if (AllZone.getQuestData().getWin() < QuestPreferences.getWinsForHardAI(index)) {
|
||||
duelOpponents.add(getDuelOpponentByNumber(mediumAIduels, 0));
|
||||
duelOpponents.add(getDuelOpponentByNumber(mediumAIduels, 1));
|
||||
duelOpponents.add(getDuelOpponentByNumber(mediumAIduels, 2));
|
||||
}
|
||||
|
||||
else if (AllZone.getQuestData().getWin() == QuestPreferences.getWinsForHardAI(index)) {
|
||||
duelOpponents.add( getDuelOpponentByNumber(mediumAIduels, 0));
|
||||
duelOpponents.add(getDuelOpponentByNumber(mediumAIduels, 0));
|
||||
duelOpponents.add(getDuelOpponentByNumber(hardAIduels, 0));
|
||||
duelOpponents.add(getDuelOpponentByNumber(hardAIduels, 1));
|
||||
}
|
||||
@@ -326,63 +371,65 @@ public class QuestEventManager {
|
||||
duelOpponents.add(getDuelOpponentByNumber(hardAIduels, 0));
|
||||
duelOpponents.add(getDuelOpponentByNumber(hardAIduels, 1));
|
||||
duelOpponents.add(getDuelOpponentByNumber(hardAIduels, 2));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
duelOpponents.add(getDuelOpponentByNumber(hardAIduels, 0));
|
||||
duelOpponents.add(getDuelOpponentByNumber(hardAIduels, 1));
|
||||
duelOpponents.add(getDuelOpponentByNumber(veryHardAIduels, 2));
|
||||
}
|
||||
|
||||
|
||||
return duelOpponents;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>generateChallenges.</p>
|
||||
* Generates an array of new challenge opponents based on current win conditions.
|
||||
*
|
||||
* <p>
|
||||
* generateChallenges.
|
||||
* </p>
|
||||
* Generates an array of new challenge opponents based on current win
|
||||
* conditions.
|
||||
*
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
public List<QuestChallenge> generateChallenges() {
|
||||
public final List<QuestChallenge> generateChallenges() {
|
||||
forge.quest.data.QuestData questData = AllZone.getQuestData();
|
||||
|
||||
List<QuestChallenge> challengeOpponents = new ArrayList<QuestChallenge>();
|
||||
|
||||
|
||||
int maxChallenges = questData.getWin() / 10;
|
||||
if (maxChallenges > 5) {
|
||||
maxChallenges = 5;
|
||||
}
|
||||
|
||||
// Generate IDs as needed.
|
||||
if (questData.getAvailableChallenges() == null ||
|
||||
questData.getAvailableChallenges().size() < maxChallenges) {
|
||||
|
||||
|
||||
// Generate IDs as needed.
|
||||
if (questData.getAvailableChallenges() == null || questData.getAvailableChallenges().size() < maxChallenges) {
|
||||
|
||||
List<Integer> unlockedChallengeIds = new ArrayList<Integer>();
|
||||
List<Integer> availableChallengeIds = new ArrayList<Integer>();
|
||||
|
||||
for(QuestChallenge qc : allChallenges) {
|
||||
if (qc.getWinsReqd() <= questData.getWin() &&
|
||||
!questData.getCompletedChallenges().contains(qc.getId())) {
|
||||
|
||||
for (QuestChallenge qc : allChallenges) {
|
||||
if (qc.getWinsReqd() <= questData.getWin()
|
||||
&& !questData.getCompletedChallenges().contains(qc.getId()))
|
||||
{
|
||||
unlockedChallengeIds.add(qc.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Collections.shuffle(unlockedChallengeIds);
|
||||
|
||||
|
||||
maxChallenges = Math.min(maxChallenges, unlockedChallengeIds.size());
|
||||
|
||||
|
||||
for (int i = 0; i < maxChallenges; i++) {
|
||||
availableChallengeIds.add(unlockedChallengeIds.get(i));
|
||||
}
|
||||
|
||||
|
||||
questData.setAvailableChallenges(availableChallengeIds);
|
||||
questData.saveData();
|
||||
}
|
||||
|
||||
// Finally, pull challenge events from available IDs and return.
|
||||
for(int i : questData.getAvailableChallenges()) {
|
||||
challengeOpponents.add(getChallengeEventByNumber(i));
|
||||
}
|
||||
|
||||
|
||||
// Finally, pull challenge events from available IDs and return.
|
||||
for (int i : questData.getAvailableChallenges()) {
|
||||
challengeOpponents.add(getChallengeEventByNumber(i));
|
||||
}
|
||||
|
||||
return challengeOpponents;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,61 +1,72 @@
|
||||
package forge.quest.gui.main;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.io.File;
|
||||
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.CompoundBorder;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.border.LineBorder;
|
||||
|
||||
import forge.gui.GuiUtils;
|
||||
import forge.properties.ForgeProps;
|
||||
import forge.properties.NewConstants;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.CompoundBorder;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.border.LineBorder;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* <p>QuestSelectablePanel class.</p>
|
||||
* <p>
|
||||
* QuestSelectablePanel class.
|
||||
* </p>
|
||||
* VIEW - Creates a selectable panel, used for picking events.
|
||||
*
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class QuestSelectablePanel extends JPanel {
|
||||
/** Constant <code>serialVersionUID=-1502285997894190742L</code> */
|
||||
/** Constant <code>serialVersionUID=-1502285997894190742L</code>. */
|
||||
private static final long serialVersionUID = -1502285997894190742L;
|
||||
|
||||
/** The background color. */
|
||||
protected Color backgroundColor;
|
||||
private boolean selected;
|
||||
private QuestEvent event;
|
||||
private String iconfilename;
|
||||
|
||||
/** The root panel. */
|
||||
public JPanel rootPanel = new JPanel();
|
||||
|
||||
/**
|
||||
* <p>Constructor for QuestSelectablePanel.</p>
|
||||
* <p>
|
||||
* Constructor for QuestSelectablePanel.
|
||||
* </p>
|
||||
* VIEW - A JPanel for selecting quest events.
|
||||
*
|
||||
* @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.
|
||||
*
|
||||
* @param qe
|
||||
* the qe
|
||||
*/
|
||||
public QuestSelectablePanel(QuestEvent qe) {
|
||||
public QuestSelectablePanel(final QuestEvent qe) {
|
||||
this.event = qe;
|
||||
this.iconfilename = qe.icon;
|
||||
File base = ForgeProps.getFile(NewConstants.IMAGE_ICON);
|
||||
File file = new File(base, iconfilename);
|
||||
|
||||
if(!file.exists()) {
|
||||
file = new File(base,"Unknown.jpg");
|
||||
|
||||
if (!file.exists()) {
|
||||
file = new File(base, "Unknown.jpg");
|
||||
this.iconfilename = "Unknown.jpg";
|
||||
}
|
||||
|
||||
ImageIcon icon = new ImageIcon(file.toString());
|
||||
|
||||
|
||||
ImageIcon icon = new ImageIcon(file.toString());
|
||||
|
||||
this.backgroundColor = getBackground();
|
||||
this.setLayout(new BorderLayout(5, 5));
|
||||
|
||||
JLabel iconLabel;
|
||||
|
||||
if (icon.getIconHeight() == -1) {
|
||||
if (icon.getIconHeight() == -1) {
|
||||
iconLabel = new JLabel(GuiUtils.getEmptyIcon(40, 40));
|
||||
} else {
|
||||
iconLabel = new JLabel(GuiUtils.getResizedIcon(icon, 40, 40));
|
||||
@@ -101,20 +112,25 @@ public class QuestSelectablePanel extends JPanel {
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>isSelected.</p>
|
||||
*
|
||||
* <p>
|
||||
* isSelected.
|
||||
* </p>
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
public boolean isSelected() {
|
||||
public final boolean isSelected() {
|
||||
return selected;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Setter for the field <code>selected</code>.</p>
|
||||
*
|
||||
* @param selected a boolean.
|
||||
* <p>
|
||||
* Setter for the field <code>selected</code>.
|
||||
* </p>
|
||||
*
|
||||
* @param selected
|
||||
* a boolean.
|
||||
*/
|
||||
public void setSelected(boolean selected) {
|
||||
public final void setSelected(final boolean selected) {
|
||||
if (selected) {
|
||||
this.setBackground(backgroundColor.darker());
|
||||
} else {
|
||||
@@ -125,20 +141,24 @@ public class QuestSelectablePanel extends JPanel {
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getIconFilename.</p>
|
||||
* <p>
|
||||
* getIconFilename.
|
||||
* </p>
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getIconFilename() {
|
||||
public final String getIconFilename() {
|
||||
return this.iconfilename;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>getEvent.</p>
|
||||
* <p>
|
||||
* getEvent.
|
||||
* </p>
|
||||
*
|
||||
* @return QuestEvent
|
||||
*/
|
||||
public QuestEvent getEvent() {
|
||||
public final QuestEvent getEvent() {
|
||||
return this.event;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
/** Forge Card Game */
|
||||
/** Forge Card Game. */
|
||||
package forge.quest.gui.main;
|
||||
|
||||
Reference in New Issue
Block a user