I have a profile with 100+ decks and it seems with the previous code,
the random deck seems not random.
This commit is contained in:
Anthony Calosa
2015-09-19 13:05:16 +08:00
parent e25b78953c
commit c9d9d3d4d3

View File

@@ -215,7 +215,10 @@ void DeckMenu::selectRandomDeck(bool isAi)
{
DeckManager *deckManager = DeckManager::GetInstance();
vector<DeckMetaData *> *deckList = isAi ? deckManager->getAIDeckOrderList() : deckManager->getPlayerDeckOrderList();
int random = (WRand() * 1000) % deckList->size();
//int random = (WRand() * 1000) % deckList->size();
int lowest=0, highest = deckList->size();
int range=(highest-lowest)+1;
int random = lowest+int(range*rand()/(RAND_MAX + 1.0));
selectDeck( random, isAi );
}