Sealed Deck mode is added as a menu item when the random deck mode is unlocked. It's basically just another random deck mode with all 5 colors and a rarity distribution that matches 4th edition starter decks. Eventually I think it would be nice to combine all of the random modes into one mode where the player can select different options like the number of colors, sets to use, etc from a filter-like interface.
More importantly, this mode uncovered a problem where workaround tokens and the like where being added to decks. This problem has been fixed, and I believe this also fixes a similar problem with these tokens being sold in the shop, because they both use the same random card function.
Code: Select all
Index: projects/mtg/bin/Res/rules/sealed.txt
===================================================================
--- projects/mtg/bin/Res/rules/sealed.txt (revision 0)
+++ projects/mtg/bin/Res/rules/sealed.txt (revision 0)
@@ -0,0 +1,3 @@
+include mtg.txt
+[INIT]
+mode=sealed
Index: projects/mtg/include/GameApp.h
===================================================================
--- projects/mtg/include/GameApp.h (revision 2281)
+++ projects/mtg/include/GameApp.h (working copy)
@@ -41,7 +41,8 @@
GAME_TYPE_MOMIR,
GAME_TYPE_RANDOM1,
GAME_TYPE_RANDOM2,
- GAME_TYPE_STORY
+ GAME_TYPE_STORY,
+ GAME_TYPE_SEALED
};
class MTGAllCards;
Index: projects/mtg/include/Rules.h
===================================================================
--- projects/mtg/include/Rules.h (revision 2281)
+++ projects/mtg/include/Rules.h (working copy)
@@ -52,6 +52,7 @@
protected:
Player * loadPlayerMomir(int isAI);
Player * loadPlayerRandom(int isAI, int mode);
+ Player * loadPlayerSealed(int isAI);
Player * initPlayer(int playerId);
MTGDeck * buildDeck( int playerId);
int strToGameMode(string s);
Index: projects/mtg/src/GameStateDuel.cpp
===================================================================
--- projects/mtg/src/GameStateDuel.cpp (revision 2281)
+++ projects/mtg/src/GameStateDuel.cpp (working copy)
@@ -245,9 +245,12 @@
} else if (mParent->gameType == GAME_TYPE_RANDOM1){
rules = NEW Rules ("random1.txt");
mGamePhase = DUEL_STATE_PLAY;
- }else if (mParent->gameType == GAME_TYPE_RANDOM2) {
+ } else if (mParent->gameType == GAME_TYPE_RANDOM2) {
rules = NEW Rules ("random2.txt");
mGamePhase = DUEL_STATE_PLAY;
+ } else if (mParent->gameType == GAME_TYPE_SEALED) {
+ rules = NEW Rules ("sealed.txt");
+ mGamePhase = DUEL_STATE_PLAY;
}
#ifdef TESTSUITE
else if (mParent->players[1] == PLAYER_TYPE_TESTSUITE){
@@ -325,7 +328,7 @@
musictrack = "ai_baka_music.mp3";
else if(mParent->gameType == GAME_TYPE_MOMIR)
musictrack = "ai_baka_music_momir.mp3";
- else if(mParent->gameType == GAME_TYPE_RANDOM1 || mParent->gameType == GAME_TYPE_RANDOM2)
+ else if(mParent->gameType == GAME_TYPE_RANDOM1 || mParent->gameType == GAME_TYPE_RANDOM2 || mParent->gameType == GAME_TYPE_SEALED)
musictrack = "ai_baka_music_random.mp3";
if(!MusicExist(musictrack))
Index: projects/mtg/src/GameStateMenu.cpp
===================================================================
--- projects/mtg/src/GameStateMenu.cpp (revision 2281)
+++ projects/mtg/src/GameStateMenu.cpp (working copy)
@@ -58,6 +58,7 @@
SUBMENUITEM_RANDOM1,
SUBMENUITEM_RANDOM2,
SUBMENUITEM_STORY,
+ SUBMENUITEM_SEALED
};
@@ -473,6 +474,7 @@
if (options[Options::RANDOMDECK_MODE_UNLOCKED].number){
subMenuController->Add(SUBMENUITEM_RANDOM1, "Random 1 Color");
subMenuController->Add(SUBMENUITEM_RANDOM2, "Random 2 Colors");
+ subMenuController->Add(SUBMENUITEM_SEALED, "Sealed Deck");
}
subMenuController->Add(SUBMENUITEM_STORY,"Story");
subMenuController->Add(SUBMENUITEM_CANCEL, "Cancel");
@@ -728,6 +730,13 @@
currentState = MENU_STATE_MAJOR_DUEL | MENU_STATE_MINOR_SUBMENU_CLOSING;
break;
+ case SUBMENUITEM_SEALED:
+ this->hasChosenGameType = 1;
+ mParent->gameType = GAME_TYPE_SEALED;
+ subMenuController->Close();
+ currentState = MENU_STATE_MAJOR_DUEL | MENU_STATE_MINOR_SUBMENU_CLOSING;
+ break;
+
case SUBMENUITEM_STORY:
this->hasChosenGameType = 1;
mParent->gameType = GAME_TYPE_STORY;
Index: projects/mtg/src/MTGDeck.cpp
===================================================================
--- projects/mtg/src/MTGDeck.cpp (revision 2281)
+++ projects/mtg/src/MTGDeck.cpp (working copy)
@@ -610,8 +610,8 @@
for (int i = 0; i < collectionTotal; i++){
MTGCard * card = database->_(i);
int r = card->getRarity();
- if (r != Constants::RARITY_T && (rarity == -1 || r==rarity) &&
- (!_subtype || card->data->hasSubtype(subtype))
+ // make sure rarity and subtype matches, make sure we never add items setID = -1 as these are just workaround tokens
+ if (r != Constants::RARITY_T && (rarity == -1 || r==rarity) && card->setId != -1 && (!_subtype || card->data->hasSubtype(subtype))
){
int ok = 0;
Index: projects/mtg/src/Rules.cpp
===================================================================
--- projects/mtg/src/Rules.cpp (revision 2281)
+++ projects/mtg/src/Rules.cpp (working copy)
@@ -215,7 +215,27 @@
return NEW AIPlayerBaka(deck,deckFile, deckFileSmall, "");
}
+Player * Rules::loadPlayerSealed(int isAI){
+ MTGDeck * tempDeck = NEW MTGDeck(GameApp::collection);
+ // Distribution based on 4th Edition starter decks: 22[L], 26[C], 9[U], 3[R]
+ tempDeck->addRandomCards(22,0,0,Constants::RARITY_L);
+ tempDeck->addRandomCards(26,0,0,Constants::RARITY_C);
+ tempDeck->addRandomCards(9,0,0,Constants::RARITY_U);
+ tempDeck->addRandomCards(3,0,0,Constants::RARITY_R);
+
+ string deckFile = "sealed";
+ string deckFileSmall = "sealed";
+
+ MTGPlayerCards * deck = NEW MTGPlayerCards(tempDeck);
+ delete tempDeck;
+
+ if (!isAI) // Human Player
+ return NEW HumanPlayer(deck, deckFile, deckFileSmall);
+ else
+ return NEW AIPlayerBaka(deck, deckFile, deckFileSmall, "");
+}
+
Player * Rules::initPlayer(int playerId){
GameObserver * g = GameObserver::GetInstance();
Player * p = g->players[playerId];
@@ -231,6 +251,8 @@
return loadPlayerRandom(isAI,GAME_TYPE_RANDOM1);
case GAME_TYPE_RANDOM2:
return loadPlayerRandom(isAI,GAME_TYPE_RANDOM2);
+ case GAME_TYPE_SEALED:
+ return loadPlayerSealed(isAI);
}
}
return p;
@@ -430,5 +452,6 @@
if (s.compare("momir")==0) return GAME_TYPE_MOMIR;
if (s.compare("random1")==0) return GAME_TYPE_RANDOM1;
if (s.compare("random2")==0) return GAME_TYPE_RANDOM2;
+ if (s.compare("sealed")==0) return GAME_TYPE_SEALED;
return GAME_TYPE_CLASSIC;
}
Also beware, the AI gets a random deck as well, and as we all know some cards just don't work well with the AI. This could be solved by using the grading system to prevent questionable cards from being added to the AI's deck. I don't think the grading system is used very much in practice though, so there would be some significant work needed to grade all the cards.