From 8ed84aa97deafeac30782a06dc923a76308fd6c7 Mon Sep 17 00:00:00 2001 From: "techdragon.nguyen@gmail.com" Date: Thu, 21 Apr 2011 08:32:32 +0000 Subject: [PATCH] Issue 634: Fixed. Had to clear the DeckManager whenever the player deck selection screen is displayed. TODO: Need to implement a caching mechanism that caches the deck information based on deck selection and not a global one. Currently DeckManager is effectively treating the DeckMetaData as global data. *some minor tweaks to how deck information is managed/created --- projects/mtg/src/DeckMenu.cpp | 2 -- projects/mtg/src/DeckMetaData.cpp | 5 +++-- projects/mtg/src/GameStateDuel.cpp | 1 + 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/mtg/src/DeckMenu.cpp b/projects/mtg/src/DeckMenu.cpp index c48928106..25098457f 100644 --- a/projects/mtg/src/DeckMenu.cpp +++ b/projects/mtg/src/DeckMenu.cpp @@ -271,14 +271,12 @@ void DeckMenu::Render() mainFont->DrawString(text.c_str(), descX, descY); mFont->SetColor(ARGB(255,255,255,255)); - // fill in the statistical portion if (currentMenuItem->meta) { ostringstream oss; oss << _("Deck: ") << currentMenuItem->meta->getName() << endl; oss << currentMenuItem->meta->getStatsSummary(); - mainFont->DrawString(oss.str(), statsX, statsY); } } diff --git a/projects/mtg/src/DeckMetaData.cpp b/projects/mtg/src/DeckMetaData.cpp index c2fa03030..465722859 100644 --- a/projects/mtg/src/DeckMetaData.cpp +++ b/projects/mtg/src/DeckMetaData.cpp @@ -56,7 +56,7 @@ void DeckMetaData::LoadStats() DeckStat * opponentDeckStats = stats->getDeckStat(mStatsFilename); if (opponentDeckStats) { - mPercentVictories = stats->percentVictories(mStatsFilename); + mPercentVictories = opponentDeckStats->percentVictories(); mVictories = opponentDeckStats->victories; mGamesPlayed = opponentDeckStats->nbgames; mColorIndex = opponentDeckStats->manaColorIndex; @@ -73,6 +73,7 @@ void DeckMetaData::LoadStats() { mDifficulty = EASY; } + mStatsLoaded = true; } } else @@ -83,10 +84,10 @@ void DeckMetaData::LoadStats() mGamesPlayed = stats->nbGames(); mPercentVictories = stats->percentVictories(); mVictories = static_cast(mGamesPlayed * (mPercentVictories / 100.0f)); + mStatsLoaded = true; } } - mStatsLoaded = true; } } diff --git a/projects/mtg/src/GameStateDuel.cpp b/projects/mtg/src/GameStateDuel.cpp index a1b3a86ab..db180061b 100644 --- a/projects/mtg/src/GameStateDuel.cpp +++ b/projects/mtg/src/GameStateDuel.cpp @@ -115,6 +115,7 @@ void GameStateDuel::Start() { if (mParent->players[i] == PLAYER_TYPE_HUMAN) { + DeckManager::EndInstance(); decksneeded = 1; deckmenu = NEW DeckMenu(DUEL_MENU_CHOOSE_DECK, this, Fonts::OPTION_FONT, "Choose a Deck",