Quest Mode source code changes
by mtgrares
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
Quest Mode source code changes
by mtgrares » 30 Apr 2009, 18:57
This is just for DennisBergkamp. I guess I could just private message but it is long, so I decided just to do this. (I can't imagine anyone else really wanting to read this, but...who knows.)
This update also requires the files questDecks-easy.txt, questDecks-medium.txt, and questDecks-hard.txt and they must have at least 3 decks names in each file. Attached are the files from Chris' 04-26-09 release: questData, questDecks-easy.txt, questDecks-medium.txt, and questDecks-hard.txt
In case you have other questions you can also check out the complete source that is in
http://www.mediafire.com/file/g4bjwmtnmny/beta-forge.zip
As always post any questions that you have.
Gui_QuestOptions.java - added one line questData.readAIQuestDeckFiles();
I think I changed and then unchanged the constructor, so I think I didn't change it after all but I'm not 100% sure.
This update also requires the files questDecks-easy.txt, questDecks-medium.txt, and questDecks-hard.txt and they must have at least 3 decks names in each file. Attached are the files from Chris' 04-26-09 release: questData, questDecks-easy.txt, questDecks-medium.txt, and questDecks-hard.txt
In case you have other questions you can also check out the complete source that is in
http://www.mediafire.com/file/g4bjwmtnmny/beta-forge.zip
As always post any questions that you have.
Gui_QuestOptions.java - added one line questData.readAIQuestDeckFiles();
- Code: Select all
void newQuestButton_actionPerformed(ActionEvent e)
{
String difficulty = "";
if(easyRadio.isSelected())
difficulty = questData.EASY;
else if(mediumRadio.isSelected())
difficulty = questData.MEDIUM;
else if(hardRadio.isSelected())
difficulty = questData.HARD;
else if(veryHardRadio.isSelected())
difficulty = questData.VERY_HARD;
else //user didn't select a difficulty
return;
//give the user a few cards to build a deck
questData.newGame(difficulty);
copyAIDecks(questData, QuestData.loadData());
QuestData.saveData(questData);
questData.readAIQuestDeckFiles();
//set global variable
AllZone.QuestData = questData;
dispose();
new Gui_Quest();
}
I think I changed and then unchanged the constructor, so I think I didn't change it after all but I'm not 100% sure.
- Code: Select all
//when you create QuestData and AFTER you copy the AI decks over
//you have to call one of these two methods below
//see Gui_QuestOptions for more details
//
//static readAIQuestDeckFiles(QuestData data, ArrayList aiDeckNames)
//OR non-static readAIQuestDeckFiles()
//which reads the files "questDecks-easy.txt", "questDecks-medium.txt","questDecks-hard.txt",
public class QuestData
{
//CHANGED!!!!!!!!!!!!!!!!!
//also changed Gui_QuestOptions.newQuestButton_actionPerformed()
//copyAIDecks(questData, QuestData.loadData());
//QuestData.saveData(questData);
//questData.readAIQuestDeckFiles();
//easy, medium, hard, very hard
//easy gets a new booster pack after 1 wins
//medium gets a new booster pack after after 2 wins, etc...
//these numbers are just guesses
private int[] addCardsArray = {1, 2, 2, 2};
private ArrayList easyAIDecks;
private ArrayList mediumAIDecks;
private ArrayList hardAIDecks;
public String[] getOpponents()
{
int difficulty[][] =
{
//if getWin() is < 4 return use easyAIDecks
//if getWin() is < 7 return mediumAIDecks
//else use hardAIDecks
{4,7}, //easy difficulty
{6, 12}, //medium difficulty
{10, 20},//hard difficulty
{10, 20},//very hard difficulty
};
int index = convertDifficultyToIndex(getDifficulty());
if(getWin() < difficulty[index][0])
return getOpponents(easyAIDecks);
if(getWin() < difficulty[index][1])
return getOpponents(mediumAIDecks);
return getOpponents(hardAIDecks);
}//getOpponents()
public String[] getOpponents(ArrayList aiDeck)
{
Collections.shuffle(aiDeck);
return new String[]
{
aiDeck.get(0).toString(),
aiDeck.get(1).toString(),
aiDeck.get(2).toString()
};
}//getOpponents()
private static ArrayList readFile(String filename, ArrayList aiDecks)
{
ArrayList list = FileUtil.readFile(filename);
//remove any blank lines
ArrayList noBlankLines = new ArrayList();
String s;
for(int i = 0; i < list.size(); i++)
{
s = list.get(i).toString().trim();
if(! s.equals(""))
noBlankLines.add(s);
}
list = noBlankLines;
if(list.size() < 3)
showError("QuestData : readFile() error, file - " +filename +" - is too short, it must contain at least 3 ai decks names");
for(int i = 0; i < list.size(); i++)
if(! aiDecks.contains(list.get(i).toString()))
showError("QuestData : readFile() error, file - " +filename +" - contains the invalid ai deck name: " +list.get(i));
return list;
}//readFile()
public QuestData()
{
for(int i = 0; i < 40; i++)
{
cardPool.add("Forest");
cardPool.add("Mountain");
cardPool.add("Swamp");
cardPool.add("Island");
cardPool.add("Plains");
}//for
}//QuestData
public void readAIQuestDeckFiles()
{
readAIQuestDeckFiles(this, ai_getDeckNames());
}
static public void readAIQuestDeckFiles(QuestData data, ArrayList aiDeckNames)
{
data.easyAIDecks = readFile("questDecks-easy.txt", aiDeckNames);
data.mediumAIDecks = readFile("questDecks-medium.txt", aiDeckNames);
data.hardAIDecks = readFile("questDecks-hard.txt", aiDeckNames);
}
static public QuestData loadData()
{
try
{
//read file "questData"
ObjectInputStream in = new ObjectInputStream(new FileInputStream(saveFileName));
Object o = in.readObject();
in.close();
QuestData_State state = (QuestData_State) o;
QuestData data = new QuestData();
data.win = state.win;
data.lost = state.lost;
data.rankIndex = state.rankIndex;
data.difficulty = state.difficulty;
data.cardPool = state.cardPool;
data.myDecks = state.myDecks;
data.aiDecks = state.aiDecks;
readAIQuestDeckFiles(data, new ArrayList(data.aiDecks.keySet()));
return data;
}//try
catch(Exception ex)
{
ex.printStackTrace();
showError("Error loading Quest Data, " +ex);
}
return null;
}//loadData()
//CHANGED!!!!!!!!!!!!!!!!!
- Attachments
-
- questData_04-26-09.zip
- questData, questDecks-easy.txt, questDecks-medium.txt, questDecks-hard.txt
- (11.5 KiB) Downloaded 243 times
- mtgrares
- DEVELOPER
- Posts: 1352
- Joined: 08 Sep 2008, 22:10
- Has thanked: 3 times
- Been thanked: 12 times
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: Quest Mode source code changes
by Chris H. » 30 Apr 2009, 21:30
Yeah, very cool.DennisBergkamp wrote:Ok, cool, I'll merge them
With my beta testing, Forge was dividing the quest into stages and was displaying the names for decks in the appropriate questDecks file.
The number of decks in the easy and medium groups are slowly growing. I finished several more decks today. It will likely be several more weeks before I have enough to release another update to these files.
-
Chris H. - Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
Re: Quest Mode source code changes
by Huggybaby » 01 May 2009, 03:37
HA! I read it! and I wanted to too!mtgrares wrote:(I can't imagine anyone else really wanting to read this, but...who knows.)
-
Huggybaby - Administrator
- Posts: 3207
- Joined: 15 Jan 2006, 19:44
- Location: Finally out of Atlanta
- Has thanked: 701 times
- Been thanked: 594 times
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 159 guests