diff --git a/projects/mtg/include/MTGDeck.h b/projects/mtg/include/MTGDeck.h index c896d7812..5b06687cd 100644 --- a/projects/mtg/include/MTGDeck.h +++ b/projects/mtg/include/MTGDeck.h @@ -160,7 +160,7 @@ public: int totalCards(); int totalPrice(); MTGDeck(MTGAllCards * _allcards); - MTGDeck(const char * config_file, MTGAllCards * _allcards, int meta_only = 0); + MTGDeck(const char * config_file, MTGAllCards * _allcards, int meta_only = 0,int difficultySetting = 0); int addRandomCards(int howmany, int * setIds = NULL, int nbSets = 0, int rarity = -1, const char * subtype = NULL, int * colors = NULL, int nbcolors = 0); int add(int cardid); diff --git a/projects/mtg/src/AIPlayer.cpp b/projects/mtg/src/AIPlayer.cpp index c4d59943e..f0e317a5e 100644 --- a/projects/mtg/src/AIPlayer.cpp +++ b/projects/mtg/src/AIPlayer.cpp @@ -1178,8 +1178,18 @@ AIPlayer * AIPlayerFactory::createAIPlayer(MTGAllCards * collection, Player * op sprintf(avatarFile, "avatar%i.jpg", deckid); sprintf(deckFileSmall, "ai_baka_deck%i", deckid); } - - MTGDeck * tempDeck = NEW MTGDeck(deckFile, collection); +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); AIPlayerBaka * baka = NEW AIPlayerBaka(tempDeck, deckFile, deckFileSmall, avatarFile); baka->deckId = deckid; SAFE_DELETE(tempDeck); diff --git a/projects/mtg/src/MTGDeck.cpp b/projects/mtg/src/MTGDeck.cpp index ff64cd002..1c9e86fb4 100644 --- a/projects/mtg/src/MTGDeck.cpp +++ b/projects/mtg/src/MTGDeck.cpp @@ -742,7 +742,7 @@ int MTGDeck::totalPrice() return total; } -MTGDeck::MTGDeck(const char * config_file, MTGAllCards * _allcards, int meta_only) +MTGDeck::MTGDeck(const char * config_file, MTGAllCards * _allcards, int meta_only,int difficultyRating) { total_cards = 0; database = _allcards; @@ -753,7 +753,7 @@ MTGDeck::MTGDeck(const char * config_file, MTGAllCards * _allcards, int meta_onl meta_id = atoi(meta_name.substr(4).c_str()); wagic::ifstream file(config_file); std::string s; - + if (file) { while (std::getline(file, s)) @@ -778,6 +778,29 @@ MTGDeck::MTGDeck(const char * config_file, MTGAllCards * _allcards, int meta_onl continue; } if (meta_only) break; + int nb = 1; + size_t found = s.find(" *"); + if (found != string::npos) + { + nb = atoi(s.substr(found + 2).c_str()); + s = s.substr(0, found); + } + size_t diff = s.find("toggledifficulty:"); + if(diff != string::npos) + { + string cards = s.substr(diff + 17); + size_t separator = cards.find("|"); + string cardeasy = cards.substr(0,separator); + string cardhard = cards.substr(separator + 1); + if(difficultyRating == HARD) + { + s = cardhard; + } + else + { + s = cardeasy; + } + } int cardnb = atoi(s.c_str()); if (cardnb) { @@ -785,7 +808,6 @@ MTGDeck::MTGDeck(const char * config_file, MTGAllCards * _allcards, int meta_onl } else { - int nb = 1; size_t found = s.find(" *"); if (found != string::npos) { @@ -800,6 +822,7 @@ MTGDeck::MTGDeck(const char * config_file, MTGAllCards * _allcards, int meta_onl add(card); } } + else { DebugTrace("could not find Card matching name: " << s);