From 2cd72cc4ca720c1e6fd6501394d831fb9ebca6e7 Mon Sep 17 00:00:00 2001 From: "techdragon.nguyen@gmail.com" Date: Mon, 14 Feb 2011 17:44:35 +0000 Subject: [PATCH] we should access the data required within a given context. Using DeckStats in this way works but only by chance that the previous step set the current deck file. Used victory percentage from the MetaData object rather than forcing what has already been computed. TODO: getVictoryPercentage() needs to represent Overall VictoryPercentage for all decks, not just player decks. AI Decks use getVictoryPercentage() to represent the VictoryPercentage against a specific deck. There should be an additional method that says getVictoryPercentageVsDeck( deckObject ) --- projects/mtg/src/AIPlayer.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/projects/mtg/src/AIPlayer.cpp b/projects/mtg/src/AIPlayer.cpp index 1e94adc13..c8d602354 100644 --- a/projects/mtg/src/AIPlayer.cpp +++ b/projects/mtg/src/AIPlayer.cpp @@ -1147,7 +1147,7 @@ AIPlayer * AIPlayerFactory::createAIPlayer(MTGAllCards * collection, Player * op if (deckid == GameStateDuel::MENUITEM_EVIL_TWIN) { //Evil twin sprintf(deckFile, "%s", opponent->deckFile.c_str()); - DebugTrace(opponent->deckFile); + DebugTrace("Evil Twin => " << opponent->deckFile); sprintf(avatarFile, "%s", "baka.jpg"); sprintf(deckFileSmall, "%s", "ai_baka_eviltwin"); } @@ -1179,18 +1179,16 @@ AIPlayer * AIPlayerFactory::createAIPlayer(MTGAllCards * collection, Player * op sprintf(avatarFile, "avatar%i.jpg", deckid); sprintf(deckFileSmall, "ai_baka_deck%i", deckid); } -DeckStats * stats = DeckStats::GetInstance(); -int deckSetting = NULL; -int diff = stats->percentVictories(); - if (diff >= 65) - { - deckSetting = HARD; - } - else if (diff < 65) - { - deckSetting = EASY; - } - MTGDeck * tempDeck = NEW MTGDeck(deckFile, collection,0,deckSetting); + + int deckSetting = EASY; + if ( opponent ) + { + bool isOpponentAI = opponent->isAI() == 1; + DeckMetaData *meta = DeckManager::GetInstance()->getDeckMetaDataByFilename( opponent->deckFile, isOpponentAI ); + if ( meta->getVictoryPercentage() >= 65) + deckSetting = HARD; + } + MTGDeck * tempDeck = NEW MTGDeck(deckFile, collection,0, deckSetting); AIPlayerBaka * baka = NEW AIPlayerBaka(tempDeck, deckFile, deckFileSmall, avatarFile); baka->deckId = deckid; SAFE_DELETE(tempDeck);