MTG Forge 03/10 - with Quest Mode

I'm happy to announce that quest mode is working, but there may be a few bugs. Download
The basic idea is that you have to make your deck with the cards you are given and then you have to play in order to win more cards. In Easy mode you will get new cards after every game that you play, if you win or lose. In Medium you get new cards after you win or lose 2 games. Hard 3 games, Very Hard 4 games.
Your data is always saved in questData and if your current questData becomes corrupted you can use your previous questData which will be named something like questData-20. (The quest data is saved often so many backups will be created.)
Hm..what to say about quest mode. First it is awesome and you will get more addicted to Magic (if possible). The "Quest Length" is the number of games that you have to win. The only progression in the quest mode is that you get different titles, "Friday Night Champion", etc.. You can keep playing more games after you get to Level 10, which is World Champion. The user interface tells you this information but I'll tell it to you here, easy is 10 games, medium 20, hard 30, very hard 40. (This next info is not displayed.) In easy you get new cards after every game whether you win or lose. In medium you get new games if you win or lose 2 games (you don't have to win or lose 2 games in a row). Hard 3 games, Very Hard 4 games.
The idea is that even if you lose you are still progressing. And yes you can cheat by starting a game and then conceding.
(I changed from Easy being 50 games to Very Hard being only 40. I don't mind playing with random, crappy cards but I like to use new random, crappy cards also, lol.)
For now the deck editor will let you edit the AI decks, in the "public" version the user won't be able to do this. This will allow you guys to add some good decks for the AI to play. Right now there are only about 8 AI decks, I wanted to add more but I ran out of time and patience. The Deck Editor's rename just works like copy and needs to be fixed. And editing the AI's decks are a little slow since it has to load up all of the cards.
The decks I used for the AI are listed below and well as some suggested people to play against. I found playing against Morpheus more interesting than trying to beat a generic name like Sam. Feel free to add names, remove names, and suggest new ones.
There are a million little things to work on and improve such as custom quests. I made the number of cards that you win as 10 but some people might prefer the usual 15 (or 14 if you don't count the basic land). The more games the user wins, the AI could use better decks. More titles (ranks) could be included, right now there are 11, but there are only 10 "levels" since you start at level 0 Card Flopper.
This is based on the 03/08 version. I kept track of all of my changes which I attached below. A listing of the changes are in the source code in the file aa_change_log.java Most of the important data is in QuestData which adds new cards, keeps track of wins and loses, and decides when you get new cards, etc... Also the "AI Smooth Land" button in Gui_Quest.java doesn't work, I forgot to see how you did it in Gui_NewGame.java
To begin with I thought adding a quest mode wouldn't be too hard and QuestData is very simple by itself but incorporating it into the larger project was hard. I probably spent around 30 hours on this. I'm just glad it works
Sorry for the long post, skip over any info that is boring
AI Decks:
Genghis Khan - green-elvish-piper60
Albert Einstein - red-kiki-jiki
Superman - white-simple
Silver Surfer - blue-battle-wits
Wolverine - 4-Planeswalk-Chandra
Frodo - green-Baru
Luke Skywalker - red3
Morpheus - black-simple
Suggest AI Deck Names:
Abraham Lincoln
Napoleon
Newton
Jimi Hendrix
George Washington
Richard Garfield
Peter Pan
Neo
---------------------------------------
Source code changes
created class QuestData
created class QuestData_BoosterPack
created class Gui_Quest
created class Gui_QuestOptions
created class Gui_Quest_DeckEditor
Changes
1. added variable QuestData to AllZone
2. added "Quest Mode" JButton to gui and modified Gui_NewGame.addListeners()
3. I think you have to update Gui_Quest.playGameButton_actionPerformed(), because it calls AllZone.GameAction.newGame()
4. added line to Gui_NewGame constructor - AllZone.QuestData = null;
5. modified Qui_WinLose.quitButton_actionPerformed()
6. added method to CardList
Code
1. added variable QuestData to AllZone
//////////////////////////////////
class AllZone
{
public static QuestData QuestData = null;
2. added "Quest Mode" JButton to gui and modified Gui_NewGame.addListeners()
//////////////////////////////////
questButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(ActionEvent e)
{
//close this windows
//can't use this.dispose() because "this" object is an ActionListener
Gui_NewGame.this.dispose();
new Gui_QuestOptions();
}
});
4. added line to Gui_NewGame constructor - AllZone.QuestData = null;
/////////////////////////////////////
public Gui_NewGame()
{
AllZone.QuestData = null;
5. modified Qui_WinLose.quitButton_actionPerformed()
//////////////////////////////////////////
void quitButton_actionPerformed(ActionEvent e)
{
//are we on a quest?
if(AllZone.QuestData == null)
new Gui_NewGame();
else
{
WinLose winLose = Constant.Runtime.WinLose;
QuestData quest = AllZone.QuestData;
if(winLose.getWin() == 2)
{
quest.addWin();
if(quest.shouldAddCards())
{
quest.addCards();
JOptionPane.showMessageDialog(null, "You have won new cards");
}
}
else
quest.addLost();
winLose.reset();
QuestData.saveData(quest);
new Gui_Quest();
}//else - on quest
dispose();
//clear Image caches, so the program doesn't get slower and slower
ImageUtil.rotatedCache.clear();
ImageCache.cache.clear();
}
6. added method to CardList
///////////////////////////////
//removes one copy of that card
public void remove(final String cardName)
{
CardList find = this.filter(new CardListFilter()
{
public boolean addCard(Card c)
{
return c.getName().equals(cardName);
}
});
if(0 < find.size())
this.remove(find.get(0));
else
throw new RuntimeException("CardList : remove(String cardname), error - card name not found: " +cardName +" - contents of Arraylist:" +list);
}//remove(String cardName)
The basic idea is that you have to make your deck with the cards you are given and then you have to play in order to win more cards. In Easy mode you will get new cards after every game that you play, if you win or lose. In Medium you get new cards after you win or lose 2 games. Hard 3 games, Very Hard 4 games.
Your data is always saved in questData and if your current questData becomes corrupted you can use your previous questData which will be named something like questData-20. (The quest data is saved often so many backups will be created.)
Hm..what to say about quest mode. First it is awesome and you will get more addicted to Magic (if possible). The "Quest Length" is the number of games that you have to win. The only progression in the quest mode is that you get different titles, "Friday Night Champion", etc.. You can keep playing more games after you get to Level 10, which is World Champion. The user interface tells you this information but I'll tell it to you here, easy is 10 games, medium 20, hard 30, very hard 40. (This next info is not displayed.) In easy you get new cards after every game whether you win or lose. In medium you get new games if you win or lose 2 games (you don't have to win or lose 2 games in a row). Hard 3 games, Very Hard 4 games.
The idea is that even if you lose you are still progressing. And yes you can cheat by starting a game and then conceding.
(I changed from Easy being 50 games to Very Hard being only 40. I don't mind playing with random, crappy cards but I like to use new random, crappy cards also, lol.)
For now the deck editor will let you edit the AI decks, in the "public" version the user won't be able to do this. This will allow you guys to add some good decks for the AI to play. Right now there are only about 8 AI decks, I wanted to add more but I ran out of time and patience. The Deck Editor's rename just works like copy and needs to be fixed. And editing the AI's decks are a little slow since it has to load up all of the cards.
The decks I used for the AI are listed below and well as some suggested people to play against. I found playing against Morpheus more interesting than trying to beat a generic name like Sam. Feel free to add names, remove names, and suggest new ones.
There are a million little things to work on and improve such as custom quests. I made the number of cards that you win as 10 but some people might prefer the usual 15 (or 14 if you don't count the basic land). The more games the user wins, the AI could use better decks. More titles (ranks) could be included, right now there are 11, but there are only 10 "levels" since you start at level 0 Card Flopper.
This is based on the 03/08 version. I kept track of all of my changes which I attached below. A listing of the changes are in the source code in the file aa_change_log.java Most of the important data is in QuestData which adds new cards, keeps track of wins and loses, and decides when you get new cards, etc... Also the "AI Smooth Land" button in Gui_Quest.java doesn't work, I forgot to see how you did it in Gui_NewGame.java
To begin with I thought adding a quest mode wouldn't be too hard and QuestData is very simple by itself but incorporating it into the larger project was hard. I probably spent around 30 hours on this. I'm just glad it works

Sorry for the long post, skip over any info that is boring

AI Decks:
Genghis Khan - green-elvish-piper60
Albert Einstein - red-kiki-jiki
Superman - white-simple
Silver Surfer - blue-battle-wits
Wolverine - 4-Planeswalk-Chandra
Frodo - green-Baru
Luke Skywalker - red3
Morpheus - black-simple
Suggest AI Deck Names:
Abraham Lincoln
Napoleon
Newton
Jimi Hendrix
George Washington
Richard Garfield
Peter Pan
Neo
---------------------------------------
Source code changes
created class QuestData
created class QuestData_BoosterPack
created class Gui_Quest
created class Gui_QuestOptions
created class Gui_Quest_DeckEditor
Changes
1. added variable QuestData to AllZone
2. added "Quest Mode" JButton to gui and modified Gui_NewGame.addListeners()
3. I think you have to update Gui_Quest.playGameButton_actionPerformed(), because it calls AllZone.GameAction.newGame()
4. added line to Gui_NewGame constructor - AllZone.QuestData = null;
5. modified Qui_WinLose.quitButton_actionPerformed()
6. added method to CardList
Code
1. added variable QuestData to AllZone
//////////////////////////////////
class AllZone
{
public static QuestData QuestData = null;
2. added "Quest Mode" JButton to gui and modified Gui_NewGame.addListeners()
//////////////////////////////////
questButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(ActionEvent e)
{
//close this windows
//can't use this.dispose() because "this" object is an ActionListener
Gui_NewGame.this.dispose();
new Gui_QuestOptions();
}
});
4. added line to Gui_NewGame constructor - AllZone.QuestData = null;
/////////////////////////////////////
public Gui_NewGame()
{
AllZone.QuestData = null;
5. modified Qui_WinLose.quitButton_actionPerformed()
//////////////////////////////////////////
void quitButton_actionPerformed(ActionEvent e)
{
//are we on a quest?
if(AllZone.QuestData == null)
new Gui_NewGame();
else
{
WinLose winLose = Constant.Runtime.WinLose;
QuestData quest = AllZone.QuestData;
if(winLose.getWin() == 2)
{
quest.addWin();
if(quest.shouldAddCards())
{
quest.addCards();
JOptionPane.showMessageDialog(null, "You have won new cards");
}
}
else
quest.addLost();
winLose.reset();
QuestData.saveData(quest);
new Gui_Quest();
}//else - on quest
dispose();
//clear Image caches, so the program doesn't get slower and slower
ImageUtil.rotatedCache.clear();
ImageCache.cache.clear();
}
6. added method to CardList
///////////////////////////////
//removes one copy of that card
public void remove(final String cardName)
{
CardList find = this.filter(new CardListFilter()
{
public boolean addCard(Card c)
{
return c.getName().equals(cardName);
}
});
if(0 < find.size())
this.remove(find.get(0));
else
throw new RuntimeException("CardList : remove(String cardname), error - card name not found: " +cardName +" - contents of Arraylist:" +list);
}//remove(String cardName)