mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
Non-deck meta removed from quest dck files. Meta now reads
Name= Display Name= Icon= Deck Type= Comment= All quest-related information is fully stored in quests.txt, including AI and human extra cards at match start. ReadQuest_Assignment assembles all quest information from this file. Quest_Assignment has getters and setters to handle all information. QuestUtil updated, most importantly deprecating SetupQuest, which previously held a lot of hard-coded data.
This commit is contained in:
@@ -11,25 +11,25 @@ import forge.card.CardPrinted;
|
||||
* @version $Id$
|
||||
*/
|
||||
public class Quest_Assignment {
|
||||
private int id;
|
||||
private int requiredNumberWins;
|
||||
private int computerLife;
|
||||
|
||||
private long creditsReward;
|
||||
|
||||
private String name;
|
||||
private String desc;
|
||||
private String difficulty;
|
||||
private String cardReward;
|
||||
private String iconName;
|
||||
|
||||
private boolean repeatable;
|
||||
|
||||
private ArrayList<CardPrinted> cardRewardList = new ArrayList<CardPrinted>();
|
||||
|
||||
private CardList human = new CardList();
|
||||
private ArrayList<String> compy = new ArrayList<String>();
|
||||
// ID (default -1, should be explicitly set at later time.)
|
||||
private int id = -1;
|
||||
|
||||
// Default vals if none provided for this ID in quests.txt.
|
||||
private int requiredNumberWins = 20;
|
||||
private int computerLife = 25;
|
||||
private long creditsReward = 100;
|
||||
private String name = "Mystery Quest";
|
||||
private String desc = "";
|
||||
private String difficulty = "Medium";
|
||||
private String cardReward = "1 colorless rare";
|
||||
private String iconName = "Unknown.jpg";
|
||||
private boolean repeatable = false;
|
||||
|
||||
// Other cards used in assignment: starting, and reward.
|
||||
private CardList humanExtraCards = new CardList();
|
||||
private CardList aiExtraCards = new CardList();
|
||||
private ArrayList<CardPrinted> cardRewardList = new ArrayList<CardPrinted>();
|
||||
|
||||
/**
|
||||
* <p>Setter for the field <code>id</code>.</p>
|
||||
*
|
||||
@@ -211,58 +211,50 @@ public class Quest_Assignment {
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Setter for the field <code>human</code>.</p>
|
||||
* <p>Setter for the field <code>humanExtraCards</code>.</p>
|
||||
*
|
||||
* @param humanIn a {@link forge.CardList} object.
|
||||
* @param s a CardList object.
|
||||
*/
|
||||
public final void setHuman(final CardList humanIn) {
|
||||
this.human = humanIn;
|
||||
public final void setHumanExtraCards(final CardList cl) {
|
||||
this.humanExtraCards = cl;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>human</code>.</p>
|
||||
* <p>Getter for the field <code>humanExtraCards</code>.</p>
|
||||
*
|
||||
* @return a {@link forge.CardList} object.
|
||||
*/
|
||||
public final CardList getHuman() {
|
||||
return human;
|
||||
public final CardList getHumanExtraCards() {
|
||||
return humanExtraCards;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>addCompy.</p>
|
||||
* <p>Setter for the field <code>aiExtraCards</code>.</p>
|
||||
*
|
||||
* @param s a {@link java.lang.String} object.
|
||||
* @param s a CardList object.
|
||||
*/
|
||||
public final void addCompy(final String s) {
|
||||
this.compy.add(s);
|
||||
public final void setAIExtraCards(final CardList cl) {
|
||||
this.aiExtraCards = cl;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>clearCompy.</p>
|
||||
*/
|
||||
public final void clearCompy() {
|
||||
this.compy.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>compy</code>.</p>
|
||||
*
|
||||
* @return a {@link java.util.ArrayList} object.
|
||||
*/
|
||||
public final ArrayList<String> getCompy() {
|
||||
return compy;
|
||||
public final CardList getAIExtraCards() {
|
||||
return aiExtraCards;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Setter for the field <code>cardRewardList</code>.</p>
|
||||
*
|
||||
* @param cardRewardListIn a {@link java.util.ArrayList} object.
|
||||
* @return a {@link java.util.ArrayList} object.
|
||||
*/
|
||||
public final void setCardRewardList(final ArrayList<CardPrinted> cardRewardListIn) {
|
||||
this.cardRewardList = cardRewardListIn;
|
||||
public void setCardRewardList(final ArrayList<CardPrinted> cp) {
|
||||
this.cardRewardList = cp;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>cardRewardList</code>.</p>
|
||||
*
|
||||
@@ -271,4 +263,5 @@ public class Quest_Assignment {
|
||||
public final ArrayList<CardPrinted> getCardRewardList() {
|
||||
return cardRewardList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,14 +2,15 @@ package forge;
|
||||
|
||||
import forge.error.ErrorViewer;
|
||||
import forge.properties.NewConstants;
|
||||
import forge.quest.data.QuestUtil;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* <p>ReadQuest_Assignment class.</p>
|
||||
*
|
||||
@@ -17,60 +18,31 @@ import java.util.List;
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ReadQuest_Assignment implements Runnable, NewConstants {
|
||||
private BufferedReader in;
|
||||
ArrayList<Quest_Assignment> allQuests = new ArrayList<Quest_Assignment>();
|
||||
|
||||
ArrayList<Quest_Assignment> allQuests = new ArrayList<Quest_Assignment>();
|
||||
private ArrayList<Integer> ids = new ArrayList<Integer>();
|
||||
|
||||
private int totalWins;
|
||||
private List<Integer> completedQuests = new ArrayList<Integer>();
|
||||
|
||||
/**
|
||||
* <p>getQuests.</p>
|
||||
*
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
public List<Quest_Assignment> getQuests() {
|
||||
return new ArrayList<Quest_Assignment>(allQuests);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getQuestsByIds.</p>
|
||||
*
|
||||
* @param availableQuestIds a {@link java.util.List} object.
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
public List<Quest_Assignment> getQuestsByIds(List<Integer> availableQuestIds) {
|
||||
List<Quest_Assignment> quests = new ArrayList<Quest_Assignment>();
|
||||
|
||||
for (Quest_Assignment qa : allQuests) {
|
||||
if (availableQuestIds.contains(qa.getId()))
|
||||
quests.add(qa);
|
||||
}
|
||||
|
||||
return quests;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getQuestById.</p>
|
||||
*
|
||||
* @param i a int.
|
||||
* @return a {@link forge.Quest_Assignment} object.
|
||||
*/
|
||||
public Quest_Assignment getQuestById(int i) {
|
||||
for (Quest_Assignment qa : allQuests) {
|
||||
if (qa.getId() == i)
|
||||
return qa;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
public Quest_Assignment getQuestById(int id) {
|
||||
return allQuests.get(id);
|
||||
}
|
||||
*/
|
||||
private BufferedReader br;
|
||||
private int totalWins;
|
||||
private List<Integer> completedQuests = new ArrayList<Integer>();
|
||||
|
||||
// Constants, tied to properties in the quests.txt file.
|
||||
private static final String ID = "id";
|
||||
private static final String ICON = "Icon";
|
||||
private static final String TITLE = "Title";
|
||||
private static final String DESC = "Desc";
|
||||
private static final String DIFF = "Diff";
|
||||
private static final String AILIFE = "AILife";
|
||||
private static final String REPEAT = "Repeat";
|
||||
private static final String WINS = "Wins";
|
||||
private static final String CARDS = "Card Reward";
|
||||
private static final String CREDITS = "Credit Reward";
|
||||
private static final String HUMANEXTRAS = "HumanExtras";
|
||||
private static final String AIEXTRAS = "AIExtras";
|
||||
|
||||
/**
|
||||
* <p>Constructor for ReadQuest_Assignment.</p>
|
||||
* Sets parameters for available quests and prepares buffered reader for quests.txt.
|
||||
*
|
||||
* @param filename a {@link java.lang.String} object.
|
||||
* @param questData a {@link forge.quest.data.QuestData} object.
|
||||
@@ -81,128 +53,226 @@ public class ReadQuest_Assignment implements Runnable, NewConstants {
|
||||
|
||||
/**
|
||||
* <p>Constructor for ReadQuest_Assignment.</p>
|
||||
* Sets parameters for available quests and prepares buffered reader for quests.txt.
|
||||
*
|
||||
* @param file a {@link java.io.File} object.
|
||||
* @param questData a {@link forge.quest.data.QuestData} object.
|
||||
*/
|
||||
public ReadQuest_Assignment(File file, forge.quest.data.QuestData questData) {
|
||||
|
||||
if (questData != null) {
|
||||
totalWins = questData.getWin();
|
||||
if (questData.getCompletedQuests() != null)
|
||||
if (questData.getCompletedQuests() != null) {
|
||||
completedQuests = questData.getCompletedQuests();
|
||||
else
|
||||
}
|
||||
else {
|
||||
completedQuests = new ArrayList<Integer>();
|
||||
}
|
||||
}
|
||||
|
||||
if (!file.exists())
|
||||
throw new RuntimeException("ReadQuest_Assignment : constructor error -- file not found -- filename is "
|
||||
+ file.getAbsolutePath());
|
||||
|
||||
//makes the checked exception, into an unchecked runtime exception
|
||||
try {
|
||||
in = new BufferedReader(new FileReader(file));
|
||||
br = new BufferedReader(new FileReader(file));
|
||||
} catch (Exception ex) {
|
||||
ErrorViewer.showError(ex, "File \"%s\" not found", file.getAbsolutePath());
|
||||
throw new RuntimeException("ReadQuest_Assignment : constructor error -- file not found -- filename is "
|
||||
+ file.getPath());
|
||||
throw new RuntimeException("ReadQuest_Assignment > constructor error: "+
|
||||
"BufferedReader failed, '"+file.getAbsolutePath()+"' not found.");
|
||||
}
|
||||
}//ReadCard()
|
||||
} // ReadQuest_Assignment()
|
||||
|
||||
/**
|
||||
* <p>getQuests.</p>
|
||||
* Returns list of currently available quest objects.
|
||||
*
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
public List<Quest_Assignment> getQuests() {
|
||||
ArrayList<Quest_Assignment> availableQuests = new ArrayList<Quest_Assignment>();
|
||||
|
||||
for(Quest_Assignment qa : allQuests) {
|
||||
if (qa.getRequiredNumberWins() <= totalWins && !completedQuests.contains(qa.getId())) {
|
||||
availableQuests.add(qa);
|
||||
}
|
||||
}
|
||||
|
||||
return availableQuests;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getQuests.</p>
|
||||
* Returns complete list of all quest objects.
|
||||
*
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
public List<Quest_Assignment> getAllQuests() {
|
||||
return allQuests;
|
||||
}
|
||||
|
||||
/* id
|
||||
* name
|
||||
* desc
|
||||
* difficulty
|
||||
* repeatable
|
||||
* numberWinsRequired
|
||||
* cardReward
|
||||
* creditsReward
|
||||
*/
|
||||
/**
|
||||
* <p>getQuestsByIds.</p>
|
||||
*
|
||||
* @param availableQuestIds a {@link java.util.List} object.
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
public List<Quest_Assignment> getQuestsByIds(List<Integer> availableQuestIds) {
|
||||
List<Quest_Assignment> q = new ArrayList<Quest_Assignment>();
|
||||
|
||||
for (Quest_Assignment qa : allQuests) {
|
||||
if (availableQuestIds.contains(qa.getId())) {
|
||||
q.add(qa);
|
||||
}
|
||||
}
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getQuestById.</p>
|
||||
*
|
||||
* @param i a int.
|
||||
* @return a {@link forge.Quest_Assignment} object.
|
||||
*/
|
||||
public Quest_Assignment getQuestById(int id) {
|
||||
// Error handling for OOB ID?
|
||||
return allQuests.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>run.</p>
|
||||
* Assembles Quest_Assignment instances into allQuests.
|
||||
*/
|
||||
public void run() {
|
||||
Quest_Assignment qa;
|
||||
String s = readLine();
|
||||
ArrayList<Integer> ids = new ArrayList<Integer>();
|
||||
|
||||
while (!s.equals("End")) {
|
||||
qa = new Quest_Assignment();
|
||||
if (s.equals("")) throw new RuntimeException("ReadQuest_Assignment : run() reading error, id is blank");
|
||||
int id = Integer.parseInt(s);
|
||||
qa.setId(id);
|
||||
|
||||
s = readLine();
|
||||
qa.setName(s);
|
||||
|
||||
s = readLine();
|
||||
qa.setDesc(s);
|
||||
|
||||
|
||||
s = readLine();
|
||||
qa.setDifficulty(s);
|
||||
if (qa.getDifficulty().equals("Medium"))
|
||||
qa.setComputerLife(25);
|
||||
else if (qa.getDifficulty().equals("Hard"))
|
||||
qa.setComputerLife(30);
|
||||
else if (qa.getDifficulty().equals("Very Hard"))
|
||||
qa.setComputerLife(35);
|
||||
else if (qa.getDifficulty().equals("Expert"))
|
||||
qa.setComputerLife(50);
|
||||
else if (qa.getDifficulty().equals("Insane"))
|
||||
qa.setComputerLife(100);
|
||||
|
||||
s = readLine();
|
||||
qa.setRepeatable(s.equals("Repeatable"));
|
||||
|
||||
s = readLine();
|
||||
int wins = Integer.valueOf(s);
|
||||
qa.setRequiredNumberWins(wins);
|
||||
|
||||
s = readLine();
|
||||
qa.setCardReward(s);
|
||||
|
||||
s = readLine();
|
||||
long reward = Long.parseLong(s.trim());
|
||||
qa.setCreditsReward(reward);
|
||||
|
||||
s = readLine();
|
||||
qa.setIconName(s);
|
||||
|
||||
//s = readLine();
|
||||
s = readLine();
|
||||
|
||||
if (ids.contains(qa.getId())) {
|
||||
System.out.println("ReadQuest_Assignment:run() error - duplicate card name: " + qa.getId());
|
||||
throw new RuntimeException("ReadQuest_Assignment:run() error - duplicate card name: " + qa.getId());
|
||||
}
|
||||
|
||||
ids.add(qa.getId());
|
||||
if (qa.getRequiredNumberWins() <= totalWins && !completedQuests.contains(qa.getId())) {
|
||||
forge.quest.data.QuestUtil.setupQuest(qa);
|
||||
allQuests.add(qa);
|
||||
}
|
||||
|
||||
//id:
|
||||
s = readLine();
|
||||
}
|
||||
}//run()
|
||||
|
||||
/**
|
||||
* <p>readLine.</p>
|
||||
*
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
private String readLine() {
|
||||
//makes the checked exception, into an unchecked runtime exception
|
||||
Quest_Assignment qa = null;
|
||||
String line;
|
||||
int i;
|
||||
String[] linedata;
|
||||
|
||||
try {
|
||||
String s = in.readLine();
|
||||
if (s != null) s = s.trim();
|
||||
return s;
|
||||
} catch (Exception ex) {
|
||||
ErrorViewer.showError(ex);
|
||||
throw new RuntimeException("ReadQuest_Assignment: readLine(Quest_Assignment) error");
|
||||
while ((line = br.readLine()) != null) {
|
||||
if(line.equals("[quest]")) {
|
||||
qa = new Quest_Assignment();
|
||||
allQuests.add(qa);
|
||||
}
|
||||
else if(!line.equals("") && qa != null) {
|
||||
linedata = line.split("=", 2);
|
||||
linedata[1] = linedata[1].trim();
|
||||
|
||||
// If empty data, ignore the line (assignment will use default).
|
||||
if(linedata[1].equals("")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Data OK.
|
||||
if(linedata[0].equals(ID)) {
|
||||
i = Integer.parseInt(linedata[1]);
|
||||
|
||||
// Duplicate ID check
|
||||
if(ids.contains(i)) {
|
||||
throw new RuntimeException("ReadQuest_Assignment > run() error: duplicate quest ID ("+i+")");
|
||||
}
|
||||
// Non-sequential ID check
|
||||
else if(i != allQuests.size()) {
|
||||
throw new RuntimeException("ReadQuest_Assignment > run() error: non-sequential quest ID ("+i+")");
|
||||
}
|
||||
// ID OK.
|
||||
else {
|
||||
ids.add(i);
|
||||
qa.setId(i);
|
||||
}
|
||||
}
|
||||
else if(linedata[0].equals(ICON)) {
|
||||
qa.setIconName(linedata[1]);
|
||||
}
|
||||
else if(linedata[0].equals(TITLE)) {
|
||||
qa.setName(linedata[1]);
|
||||
}
|
||||
else if(linedata[0].equals(DESC)) {
|
||||
qa.setDesc(linedata[1]);
|
||||
}
|
||||
else if(linedata[0].equals(DIFF)) {
|
||||
qa.setDifficulty(linedata[1]);
|
||||
}
|
||||
else if(linedata[0].equals(REPEAT)) {
|
||||
qa.setRepeatable(Boolean.parseBoolean(linedata[1]));
|
||||
}
|
||||
else if(linedata[0].equals(AILIFE)) {
|
||||
qa.setComputerLife(Integer.parseInt(linedata[1]));
|
||||
}
|
||||
else if(linedata[0].equals(WINS)) {
|
||||
qa.setRequiredNumberWins(Integer.parseInt(linedata[1]));
|
||||
}
|
||||
else if(linedata[0].equals(CREDITS)) {
|
||||
qa.setCreditsReward(Integer.parseInt(linedata[1]));
|
||||
}
|
||||
// Card reward list assembled here.
|
||||
else if(linedata[0].equals(CARDS)) {
|
||||
qa.setCardReward(linedata[1]);
|
||||
qa.setCardRewardList(QuestUtil.generateCardRewardList(linedata[1]));
|
||||
}
|
||||
// Human extra card list assembled here.
|
||||
else if(linedata[0].equals(HUMANEXTRAS)) {
|
||||
String[] names = linedata[1].split("\\|");
|
||||
CardList templist = new CardList();
|
||||
Card tempcard;
|
||||
|
||||
for(String s : names) {
|
||||
// Token card creation
|
||||
if(s.substring(0,5).equals("TOKEN")) {
|
||||
tempcard = QuestUtil.createToken(s);
|
||||
tempcard.addController(AllZone.getHumanPlayer());
|
||||
tempcard.setOwner(AllZone.getHumanPlayer());
|
||||
templist.add(tempcard);
|
||||
}
|
||||
// Standard card creation
|
||||
else {
|
||||
tempcard = AllZone.getCardFactory().getCard(s, AllZone.getHumanPlayer());
|
||||
tempcard.setCurSetCode(tempcard.getMostRecentSet());
|
||||
tempcard.setImageFilename(CardUtil.buildFilename(tempcard));
|
||||
templist.add(tempcard);
|
||||
}
|
||||
}
|
||||
|
||||
qa.setHumanExtraCards(templist);
|
||||
}
|
||||
// AI extra card list assembled here.
|
||||
else if(linedata[0].equals(AIEXTRAS)) {
|
||||
String[] names = linedata[1].split("\\|");
|
||||
CardList templist = new CardList();
|
||||
Card tempcard;
|
||||
|
||||
for(String s : names) {
|
||||
// Token card creation
|
||||
if(s.substring(0,5).equals("TOKEN")) {
|
||||
tempcard = QuestUtil.createToken(s);
|
||||
tempcard.addController(AllZone.getComputerPlayer());
|
||||
tempcard.setOwner(AllZone.getComputerPlayer());
|
||||
templist.add(tempcard);
|
||||
}
|
||||
// Standard card creation
|
||||
else {
|
||||
tempcard = AllZone.getCardFactory().getCard(s, AllZone.getComputerPlayer());
|
||||
tempcard.setCurSetCode(tempcard.getMostRecentSet());
|
||||
tempcard.setImageFilename(CardUtil.buildFilename(tempcard));
|
||||
templist.add(tempcard);
|
||||
}
|
||||
}
|
||||
|
||||
qa.setAIExtraCards(templist);
|
||||
}
|
||||
} // else if()
|
||||
} // while()
|
||||
|
||||
br.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}//readLine(Quest_Assignment)
|
||||
|
||||
// Confirm that all quests have IDs.
|
||||
for(Quest_Assignment q : allQuests) {
|
||||
if(q.getId()==-1) {
|
||||
throw new RuntimeException("ReadQuest_Assignment > getQuests() error: "+
|
||||
"Quest ID missing for '"+q.getName()+"'.");
|
||||
}
|
||||
}
|
||||
|
||||
} // run()
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package forge.quest.data;
|
||||
|
||||
import forge.*;
|
||||
import forge.Card;
|
||||
import forge.CardList;
|
||||
import forge.Constant;
|
||||
import forge.Quest_Assignment;
|
||||
import forge.card.CardPrinted;
|
||||
import forge.card.CardRarity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -25,6 +29,7 @@ public class QuestUtil {
|
||||
|
||||
/**
|
||||
* <p>getComputerCreatures.</p>
|
||||
* Returns extra AI cards in play at start of quest.
|
||||
*
|
||||
* @param qd a {@link forge.quest.data.QuestData} object.
|
||||
* @param qa a {@link forge.Quest_Assignment} object.
|
||||
@@ -32,23 +37,16 @@ public class QuestUtil {
|
||||
*/
|
||||
public static CardList getComputerCreatures(final QuestData qd, Quest_Assignment qa) {
|
||||
CardList list = new CardList();
|
||||
|
||||
if (qa != null) {
|
||||
ArrayList<String> compCards = qa.getCompy();
|
||||
|
||||
for (String s : compCards) {
|
||||
Card c = AllZone.getCardFactory().getCard(s, AllZone.getComputerPlayer());
|
||||
|
||||
c.setCurSetCode(c.getMostRecentSet());
|
||||
c.setImageFilename(CardUtil.buildFilename(c));
|
||||
|
||||
list.add(c);
|
||||
}
|
||||
list.addAll(qa.getAIExtraCards());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getHumanPlantAndPet.</p>
|
||||
* Returns list of current plant/pet configuration.
|
||||
*
|
||||
* @param qd a {@link forge.quest.data.QuestData} object.
|
||||
* @return a {@link forge.CardList} object.
|
||||
@@ -69,6 +67,8 @@ public class QuestUtil {
|
||||
|
||||
/**
|
||||
* <p>getHumanPlantAndPet.</p>
|
||||
* Returns extra human cards, including current plant/pet configuration,
|
||||
* and cards in play at start of quest.
|
||||
*
|
||||
* @param qd a {@link forge.quest.data.QuestData} object.
|
||||
* @param qa a {@link forge.Quest_Assignment} object.
|
||||
@@ -76,420 +76,104 @@ public class QuestUtil {
|
||||
*/
|
||||
public static CardList getHumanPlantAndPet(final QuestData qd, Quest_Assignment qa) {
|
||||
CardList list = getHumanPlantAndPet(qd);
|
||||
|
||||
|
||||
if (qa != null) {
|
||||
list.addAll(qa.getHuman());
|
||||
list.addAll(qa.getHumanExtraCards());
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>createToken.</p>
|
||||
* Creates a card instance for token defined by property string.
|
||||
*
|
||||
* @param s Properties string of token (TOKEN;W;1;1;sheep;type;type;type...)
|
||||
* @return token Card
|
||||
*/
|
||||
public static Card createToken(String s) {
|
||||
String[] properties = s.split(";");;
|
||||
|
||||
Card c = new Card();
|
||||
c.setToken(true);
|
||||
|
||||
//c.setManaCost(properties[1]);
|
||||
c.addColor(properties[1]);
|
||||
c.setBaseAttack(Integer.parseInt(properties[2]));
|
||||
c.setBaseDefense(Integer.parseInt(properties[3]));
|
||||
c.setName(properties[4]);
|
||||
|
||||
c.setImageName(
|
||||
properties[1]+" "+
|
||||
properties[2]+" "+
|
||||
properties[3]+" "+
|
||||
properties[4]
|
||||
);
|
||||
|
||||
int x = 5;
|
||||
while(x != properties.length) {
|
||||
c.addType(properties[x++]);
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>generateCardRewardList.</p>
|
||||
* Takes a reward list string, parses, and returns list of cards rewarded.
|
||||
*
|
||||
* @param s Properties string of reward (97 multicolor rares)
|
||||
* @return CardList
|
||||
*/
|
||||
public static ArrayList<CardPrinted> generateCardRewardList(String s) {
|
||||
QuestBoosterPack pack = new QuestBoosterPack();
|
||||
String[] temp = s.split(" ");
|
||||
|
||||
int qty = Integer.parseInt(temp[0]);
|
||||
|
||||
// Determine rarity
|
||||
CardRarity rar = CardRarity.Uncommon;
|
||||
if(temp[1].equals("rare") || temp[1].equals("rares")) {
|
||||
rar = CardRarity.Rare;
|
||||
}
|
||||
|
||||
// Determine color ("random" defaults to null color)
|
||||
String col = null;
|
||||
if(temp[2].toLowerCase().equals("black")) {
|
||||
col = Constant.Color.Black;
|
||||
}
|
||||
else if(temp[2].toLowerCase().equals("blue")) {
|
||||
col = Constant.Color.Blue;
|
||||
}
|
||||
else if(temp[2].toLowerCase().equals("colorless")) {
|
||||
col = Constant.Color.Colorless;
|
||||
}
|
||||
else if(temp[2].toLowerCase().equals("green")) {
|
||||
col = Constant.Color.Green;
|
||||
}
|
||||
else if(temp[2].toLowerCase().equals("multicolor")) {
|
||||
col = "Multicolor"; // Note: No constant color for this??
|
||||
}
|
||||
else if(temp[2].toLowerCase().equals("red")) {
|
||||
col = Constant.Color.Red;
|
||||
}
|
||||
else if(temp[2].toLowerCase().equals("white")) {
|
||||
col = Constant.Color.White;
|
||||
}
|
||||
|
||||
return pack.generateCards(qty, rar, col);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>setupQuest.</p>
|
||||
*
|
||||
* @param qa a {@link forge.Quest_Assignment} object.
|
||||
* Assembled hard-coded quest options.
|
||||
* All non-deck-specific handling now takes place in quests.txt.
|
||||
*
|
||||
* @deprecated
|
||||
* @param qa
|
||||
*/
|
||||
public static void setupQuest(Quest_Assignment qa) {
|
||||
QuestBoosterPack pack = new QuestBoosterPack();
|
||||
qa.clearCompy();
|
||||
|
||||
int id = qa.getId();
|
||||
|
||||
if (id == 1) //White Dungeon
|
||||
{
|
||||
qa.addCompy("Divine Presence");
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(3, CardRarity.Rare, Constant.Color.White));
|
||||
} else if (id == 2) //Blue Dungeon
|
||||
{
|
||||
CardList humanList = new CardList();
|
||||
Card c = AllZone.getCardFactory().getCard("Quest for Ancient Secrets", AllZone.getHumanPlayer());
|
||||
|
||||
c.setCurSetCode(c.getMostRecentSet());
|
||||
c.setImageFilename(CardUtil.buildFilename(c));
|
||||
|
||||
humanList.add(c);
|
||||
|
||||
qa.setHuman(humanList);
|
||||
|
||||
qa.addCompy("Forced Fruition");
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(3, CardRarity.Rare, Constant.Color.Blue));
|
||||
} else if (id == 3) //Black Dungeon
|
||||
{
|
||||
qa.addCompy("Infernal Genesis");
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(3, CardRarity.Rare, Constant.Color.Black));
|
||||
} else if (id == 4) //Red Dungeon
|
||||
{
|
||||
qa.addCompy("Furnace of Rath");
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(3, CardRarity.Rare, Constant.Color.Red));
|
||||
} else if (id == 5) //Green Dungeon
|
||||
{
|
||||
CardList humanList = new CardList();
|
||||
Card c = AllZone.getCardFactory().getCard("Defense of the Heart", AllZone.getHumanPlayer());
|
||||
|
||||
c.setCurSetCode(c.getMostRecentSet());
|
||||
c.setImageFilename(CardUtil.buildFilename(c));
|
||||
|
||||
humanList.add(c);
|
||||
|
||||
qa.setHuman(humanList);
|
||||
|
||||
qa.addCompy("Eladamri's Vineyard");
|
||||
qa.addCompy("Upwelling");
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(3, CardRarity.Rare, Constant.Color.Green));
|
||||
} else if (id == 6) //Colorless Dungeon
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
qa.addCompy("Eon Hub");
|
||||
qa.setCardRewardList(pack.generateCards(3, CardRarity.Rare, Constant.Color.Colorless));
|
||||
} else if (id == 7) //Gold Dungeon
|
||||
{
|
||||
qa.addCompy("Darksteel Ingot");
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(3, CardRarity.Rare, "Multicolor"));
|
||||
} else if (id == 8) {
|
||||
CardList humanList = new CardList();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
//CANNOT use makeToken because of WheneverKeyword
|
||||
Card c = new Card();
|
||||
c.setName("Sheep");
|
||||
c.setImageName("G 0 1 Sheep");
|
||||
|
||||
c.addController(AllZone.getHumanPlayer());
|
||||
c.setOwner(AllZone.getHumanPlayer());
|
||||
|
||||
//c.setManaCost("G");
|
||||
c.addColor("G");
|
||||
c.setToken(true);
|
||||
|
||||
c.addType("Creature");
|
||||
c.addType("Sheep");
|
||||
|
||||
c.setBaseAttack(0);
|
||||
c.setBaseDefense(1);
|
||||
|
||||
humanList.add(c);
|
||||
}
|
||||
qa.setHuman(humanList);
|
||||
qa.setCardRewardList(pack.generateCards(3, CardRarity.Rare, null));
|
||||
} else if (id == 9) {
|
||||
CardList humanList = new CardList();
|
||||
Card c = AllZone.getCardFactory().getCard("Trusty Machete", AllZone.getHumanPlayer());
|
||||
|
||||
c.setCurSetCode(c.getMostRecentSet());
|
||||
c.setImageFilename(CardUtil.buildFilename(c));
|
||||
|
||||
humanList.add(c);
|
||||
|
||||
qa.setHuman(humanList);
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
qa.addCompy("Wall of Wood");
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(4, CardRarity.Rare, Constant.Color.Green));
|
||||
} else if (id == 10) {
|
||||
CardList humanList = new CardList();
|
||||
|
||||
Card crd = AllZone.getCardFactory().getCard("Wall of Spears", AllZone.getHumanPlayer());
|
||||
|
||||
crd.setCurSetCode(crd.getMostRecentSet());
|
||||
crd.setImageFilename(CardUtil.buildFilename(crd));
|
||||
|
||||
humanList.add(crd);
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Card c = new Card();
|
||||
c.setName("Citizen");
|
||||
c.setImageName("W 1 1 Citizen");
|
||||
|
||||
c.addController(AllZone.getHumanPlayer());
|
||||
c.setOwner(AllZone.getHumanPlayer());
|
||||
|
||||
c.setManaCost("W");
|
||||
c.addColor("W");
|
||||
c.setToken(true);
|
||||
|
||||
c.addType("Creature");
|
||||
c.addType("Citizen");
|
||||
|
||||
c.setBaseAttack(1);
|
||||
c.setBaseDefense(1);
|
||||
|
||||
humanList.add(c);
|
||||
}
|
||||
|
||||
qa.setHuman(humanList);
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
qa.addCompy("Scathe Zombies");
|
||||
qa.addCompy("Mass of Ghouls");
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(4, CardRarity.Rare, Constant.Color.Black));
|
||||
} else if (id == 11) // The King's Contest
|
||||
{
|
||||
CardList humanList = new CardList();
|
||||
Card c = AllZone.getCardFactory().getCard("Seal of Cleansing", AllZone.getHumanPlayer());
|
||||
|
||||
c.setCurSetCode(c.getMostRecentSet());
|
||||
c.setImageFilename(CardUtil.buildFilename(c));
|
||||
|
||||
humanList.add(c);
|
||||
|
||||
qa.setHuman(humanList);
|
||||
|
||||
qa.addCompy("Loyal Retainers");
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(3, CardRarity.Rare, null));
|
||||
} else if (id == 12) // Barroom Brawl
|
||||
{
|
||||
CardList humanList = new CardList();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Card c = new Card();
|
||||
c.setName("Soldier Ally");
|
||||
c.setImageName("W 1 1 Soldier Ally");
|
||||
|
||||
c.addController(AllZone.getHumanPlayer());
|
||||
c.setOwner(AllZone.getHumanPlayer());
|
||||
|
||||
c.setManaCost("W");
|
||||
c.addColor("W");
|
||||
c.setToken(true);
|
||||
|
||||
c.addType("Creature");
|
||||
c.addType("Soldier");
|
||||
c.addType("Ally");
|
||||
|
||||
c.setBaseAttack(1);
|
||||
c.setBaseDefense(1);
|
||||
|
||||
|
||||
humanList.add(c);
|
||||
}
|
||||
qa.setHuman(humanList);
|
||||
|
||||
|
||||
qa.addCompy("Lowland Giant");
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(4, CardRarity.Rare, null));
|
||||
} else if (id == 13) // The Court Jester
|
||||
{
|
||||
CardList humanList = new CardList();
|
||||
Card c = AllZone.getCardFactory().getCard("Sensei's Divining Top", AllZone.getHumanPlayer());
|
||||
|
||||
c.setCurSetCode(c.getMostRecentSet());
|
||||
c.setImageFilename(CardUtil.buildFilename(c));
|
||||
|
||||
humanList.add(c);
|
||||
|
||||
qa.setHuman(humanList);
|
||||
|
||||
qa.addCompy("Teferi's Puzzle Box");
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(4, CardRarity.Rare, "Multicolor"));
|
||||
} else if (id == 14) // Ancient Battlefield
|
||||
{
|
||||
CardList humanList = new CardList();
|
||||
String humanSetupCards[] = {"Glasses of Urza", "Blight Sickle"};
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
Card c = AllZone.getCardFactory().getCard(humanSetupCards[i], AllZone.getHumanPlayer());
|
||||
|
||||
c.setCurSetCode(c.getMostRecentSet());
|
||||
c.setImageFilename(CardUtil.buildFilename(c));
|
||||
|
||||
humanList.add(c);
|
||||
}
|
||||
qa.setHuman(humanList);
|
||||
|
||||
String compySetupCards[] = {"Bad Moon", "Wall of Brambles"};
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
qa.addCompy(compySetupCards[i]);
|
||||
}
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(4, CardRarity.Rare, null));
|
||||
} else if (id == 15) // Don't Play With Matches
|
||||
{
|
||||
CardList humanList = new CardList();
|
||||
String humanSetupCards[] = {"Mudbutton Torchrunner", "Scuzzback Scrapper"};
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
Card c = AllZone.getCardFactory().getCard(humanSetupCards[i], AllZone.getHumanPlayer());
|
||||
|
||||
c.setCurSetCode(c.getMostRecentSet());
|
||||
c.setImageFilename(CardUtil.buildFilename(c));
|
||||
|
||||
humanList.add(c);
|
||||
}
|
||||
qa.setHuman(humanList);
|
||||
|
||||
String compySetupCards[] = {"Heedless One", "Norwood Archers", "Wildslayer Elves"};
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
qa.addCompy(compySetupCards[i]);
|
||||
}
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(4, CardRarity.Rare, Constant.Color.Red));
|
||||
} else if (id == 16) // Mines of Kazum Durl
|
||||
{
|
||||
CardList humanList = new CardList();
|
||||
String[] humanSetupCards = {"Dwarven Demolition Team", "Dwarven Pony", "Dwarven Trader"};
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Card c = AllZone.getCardFactory().getCard(humanSetupCards[i], AllZone.getHumanPlayer());
|
||||
|
||||
c.setCurSetCode(c.getMostRecentSet());
|
||||
c.setImageFilename(CardUtil.buildFilename(c));
|
||||
|
||||
humanList.add(c);
|
||||
}
|
||||
qa.setHuman(humanList);
|
||||
|
||||
String[] compySetupCards =
|
||||
{"Wall of Earth", "Wall of Air", "Wall of Ice", "Wall of Light", "Carrion Wall", "Steel Wall"};
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
qa.addCompy(compySetupCards[i]);
|
||||
}
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(4, CardRarity.Rare, Constant.Color.Green));
|
||||
} else if (id == 17) // House Party
|
||||
{
|
||||
CardList humanList = new CardList();
|
||||
String[] humanSetupCards = {"Hopping Automaton", "Honden of Life's Web", "Forbidden Orchard"};
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Card c = AllZone.getCardFactory().getCard(humanSetupCards[i], AllZone.getHumanPlayer());
|
||||
|
||||
c.setCurSetCode(c.getMostRecentSet());
|
||||
c.setImageFilename(CardUtil.buildFilename(c));
|
||||
|
||||
humanList.add(c);
|
||||
}
|
||||
qa.setHuman(humanList);
|
||||
|
||||
String[] compySetupCards = {"Honden of Infinite Rage", "Mikokoro, Center of the Sea", "Tidehollow Strix"};
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
qa.addCompy(compySetupCards[i]);
|
||||
}
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(4, CardRarity.Rare, Constant.Color.Colorless));
|
||||
} else if (id == 18) // Crows in the Field
|
||||
{
|
||||
CardList humanList = new CardList();
|
||||
String[] humanSetupCards = {"Straw Soldiers", "Femeref Archers", "Moonglove Extract"};
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Card c = AllZone.getCardFactory().getCard(humanSetupCards[i], AllZone.getHumanPlayer());
|
||||
|
||||
c.setCurSetCode(c.getMostRecentSet());
|
||||
c.setImageFilename(CardUtil.buildFilename(c));
|
||||
|
||||
humanList.add(c);
|
||||
}
|
||||
qa.setHuman(humanList);
|
||||
|
||||
String[] compySetupCards = {"Defiant Falcon", "Soulcatcher", "Storm Crow", "Hypnotic Specter"};
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
qa.addCompy(compySetupCards[i]);
|
||||
}
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(5, CardRarity.Rare, null));
|
||||
} else if (id == 19) // The Desert Caravan
|
||||
{
|
||||
CardList humanList = new CardList();
|
||||
String[] humanSetupCards = {"Spidersilk Net", "Dromad Purebred"};
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
Card c = AllZone.getCardFactory().getCard(humanSetupCards[i], AllZone.getHumanPlayer());
|
||||
|
||||
c.setCurSetCode(c.getMostRecentSet());
|
||||
c.setImageFilename(CardUtil.buildFilename(c));
|
||||
|
||||
humanList.add(c);
|
||||
}
|
||||
qa.setHuman(humanList);
|
||||
|
||||
String[] compySetupCards = {"Ambush Party", "Ambush Party", "Gnat Alley Creeper", "Ambush Party", "Ambush Party"};
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
qa.addCompy(compySetupCards[i]);
|
||||
}
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(5, CardRarity.Rare, null));
|
||||
} else if (id == 20) // Blood Oath
|
||||
{
|
||||
CardList humanList = new CardList();
|
||||
String[] humanSetupCards = {"Counterbalance", "Hatching Plans", "Ley Druid"};
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Card c = AllZone.getCardFactory().getCard(humanSetupCards[i], AllZone.getHumanPlayer());
|
||||
|
||||
c.setCurSetCode(c.getMostRecentSet());
|
||||
c.setImageFilename(CardUtil.buildFilename(c));
|
||||
|
||||
humanList.add(c);
|
||||
}
|
||||
qa.setHuman(humanList);
|
||||
|
||||
String[] compySetupCards = {"Ior Ruin Expedition", "Oversold Cemetery", "Trapjaw Kelpie"};
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
qa.addCompy(compySetupCards[i]);
|
||||
}
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(5, CardRarity.Rare, Constant.Color.Colorless));
|
||||
} else if (id == 21) // Private Domain
|
||||
{
|
||||
CardList humanList = new CardList();
|
||||
|
||||
Card c = AllZone.getCardFactory().getCard("Strip Mine", AllZone.getHumanPlayer());
|
||||
|
||||
c.setCurSetCode(c.getMostRecentSet());
|
||||
c.setImageFilename(CardUtil.buildFilename(c));
|
||||
|
||||
humanList.add(c);
|
||||
|
||||
qa.setHuman(humanList);
|
||||
|
||||
String[] compySetupCards = {"Plains", "Island", "Swamp", "Mountain", "Forest"};
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
qa.addCompy(compySetupCards[i]);
|
||||
}
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(6, CardRarity.Rare, null));
|
||||
} else if (id == 22) // Pied Piper
|
||||
{
|
||||
CardList humanList = new CardList();
|
||||
String[] humanSetupCards = {"Volunteer Militia", "Land Tax", "Elvish Farmer", "An-Havva Township"};
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
Card c = AllZone.getCardFactory().getCard(humanSetupCards[i], AllZone.getHumanPlayer());
|
||||
|
||||
c.setCurSetCode(c.getMostRecentSet());
|
||||
c.setImageFilename(CardUtil.buildFilename(c));
|
||||
|
||||
humanList.add(c);
|
||||
}
|
||||
qa.setHuman(humanList);
|
||||
|
||||
String[] compySetupCards = {"Darksteel Citadel", "Relentless Rats"};
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
qa.addCompy(compySetupCards[i]);
|
||||
}
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(3, CardRarity.Rare, null));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
} //QuestUtil
|
||||
|
||||
Reference in New Issue
Block a user