* optimized card loading. There was some redundant code that wasn't necessary.
* getCardByName seemed to have a initialization error if you tried to use it before the entire game loaded. The cache would throw an exception if you tried to use find and it was empty. I put a guard around it to avoid this issue. * refactored Zeth's "toggledifficuly" feature to be stored in meta data. http://code.google.com/p/wagic/source/detail?r=3106 -- This is slightly modified as it forces a 1 for 1 swap of cards that are specified. from the example given this is how it seemed to be used anyways. -- since all the information is stored in the meta data, there's no need to alter the deck's definition.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include "PrecompiledHeader.h"
|
||||
|
||||
#include "DeckManager.h"
|
||||
#include "DeckMetaData.h"
|
||||
#include "MTGGameZones.h"
|
||||
#include "Player.h"
|
||||
#include "GameOptions.h"
|
||||
@@ -43,10 +45,20 @@ MTGPlayerCards::MTGPlayerCards(MTGDeck * deck)
|
||||
void MTGPlayerCards::initDeck(MTGDeck * deck)
|
||||
{
|
||||
resetLibrary();
|
||||
bool isAI = deck->getFilename().find("baka") != string::npos;
|
||||
DeckMetaData *deckMeta = DeckManager::GetInstance()->getDeckMetaDataById( deck->meta_id, isAI);
|
||||
map<int,int> alternatesMap = deckMeta->getAlternateMappings();
|
||||
bool useAlternates = deckMeta->getVictoryPercentage() >= 65;
|
||||
map<int, int>::iterator it;
|
||||
for (it = deck->cards.begin(); it != deck->cards.end(); it++)
|
||||
{
|
||||
MTGCard * card = deck->getCardById(it->first);
|
||||
int cardId = it->first;
|
||||
if (useAlternates && isAI)
|
||||
{
|
||||
if ( alternatesMap.find( cardId ) != alternatesMap.end() )
|
||||
cardId = alternatesMap[ cardId ];
|
||||
}
|
||||
MTGCard * card = deck->getCardById(cardId);
|
||||
if (card)
|
||||
{
|
||||
for (int i = 0; i < it->second; i++)
|
||||
|
||||
Reference in New Issue
Block a user