- fixed card id collisions in Legends, Ravnica, Portal
- Changed Deck and Database structures with better design (a bit faster, hopefully a lot cleaner)
- updated Windows project file
This commit is contained in:
wagic.the.homebrew@gmail.com
2009-06-06 04:46:54 +00:00
parent 01bd44025d
commit ab42e5db06
13 changed files with 166 additions and 145 deletions
+4 -4
View File
@@ -73,7 +73,7 @@ toughness=2
[/card] [/card]
[card] [card]
text=Legendary text=Legendary
id=1516 id=1647
name=Barktooth Warbeard name=Barktooth Warbeard
color=Black,Red color=Black,Red
rarity=U rarity=U
@@ -138,7 +138,7 @@ toughness=1
[/card] [/card]
[card] [card]
text=Forestwalk text=Forestwalk
id=1516 id=1517
name=Cat Warriors name=Cat Warriors
color=Green color=Green
rarity=C rarity=C
@@ -559,7 +559,7 @@ type=Enchantment
[/card] [/card]
[card] [card]
text=Rampage 1 (Whenever this creature becomes blocked, it gets +1/+1 until end of turn for each creature blocking it beyond the first.) text=Rampage 1 (Whenever this creature becomes blocked, it gets +1/+1 until end of turn for each creature blocking it beyond the first.)
id=1653 id=1657
auto=rampage(1/1,1) auto=rampage(1/1,1)
name=Hunding Gjornersen name=Hunding Gjornersen
color=White,Blue color=White,Blue
@@ -778,7 +778,7 @@ toughness=2
[/card] [/card]
[card] [card]
text=Legendary {T}: Lady Caleria deals 3 damage to target attacking or blocking creature. text=Legendary {T}: Lady Caleria deals 3 damage to target attacking or blocking creature.
id=5771 id=1665
name=Lady Caleria name=Lady Caleria
color=White,Green color=White,Green
rarity=R rarity=R
+2 -2
View File
@@ -119,7 +119,7 @@ abilities=swampwalk
[/card] [/card]
[card] [card]
text={B}{T}, Discard a card: Add {B}{B}{B} to your mana pool. text={B}{T}, Discard a card: Add {B}{B}{B} to your mana pool.
id=21332 id=19578
name=Bog Witch name=Bog Witch
color=Black color=Black
rarity=C rarity=C
@@ -1171,7 +1171,7 @@ subtype=Swamp
[card] [card]
text={T}: Add {B} to your mana pool. text={T}: Add {B} to your mana pool.
auto={T}: Add {B} auto={T}: Add {B}
id=20888 id=20889
name=Swamp name=Swamp
rarity=L rarity=L
color=Land color=Land
+1 -37
View File
@@ -745,18 +745,6 @@ toughness=1
abilities=flying abilities=flying
[/card] [/card]
[card] [card]
text=Flying
id=4306
name=Moon Sprite
rarity=U
mana={1}{G}
type=Creature
subtype=Faerie
power=1
toughness=1
abilities=flying
[/card]
[card]
text={T}: Add {R} to your mana pool. text={T}: Add {R} to your mana pool.
auto={T}: Add {R} auto={T}: Add {R}
id=4420 id=4420
@@ -806,18 +794,6 @@ power=1
toughness=1 toughness=1
[/card] [/card]
[card] [card]
text=Mountainwalk
id=4352
name=Mountain Goat
rarity=U
mana={R}
type=Creature
subtype=Goat
power=1
toughness=1
abilities=mountainwalk
[/card]
[card]
text=Counter target creature or sorcery spell. text=Counter target creature or sorcery spell.
target=creature,sorcery|stack target=creature,sorcery|stack
auto=fizzle auto=fizzle
@@ -937,18 +913,6 @@ type=Basic Land
subtype=Plains subtype=Plains
[/card] [/card]
[card] [card]
text=Phantom Warrior is unblockable.
id=4272
name=Phantom Warrior
rarity=R
mana={1}{U}{U}
type=Creature
subtype=Illusion Warrior
power=2
toughness=2
abilities=unblockable
[/card]
[card]
text=Pyroclasm deals 2 damage to each creature. text=Pyroclasm deals 2 damage to each creature.
id=4354 id=4354
alias=2650 alias=2650
@@ -1045,7 +1009,7 @@ power=2
toughness=3 toughness=3
[/card] [/card]
[card] [card]
id=4315 id=4316
name=Rowan Treefolk name=Rowan Treefolk
rarity=C rarity=C
mana={3}{G} mana={3}{G}
+1 -1
View File
@@ -851,7 +851,7 @@ subtype=Swamp
[/card] [/card]
[card] [card]
text=Flying {B}: Regenerate Tattered Drake. text=Flying {B}: Regenerate Tattered Drake.
id=87986 id=87930
name=Tattered Drake name=Tattered Drake
color=Blue color=Blue
rarity=C rarity=C
+2 -2
View File
@@ -32,11 +32,11 @@ class DeckDataWrapper{
DeckDataWrapper(MTGDeck * deck); DeckDataWrapper(MTGDeck * deck);
~DeckDataWrapper(); ~DeckDataWrapper();
int Add(MTGCard * card); int Add(MTGCard * card, int quantity = 1);
int Remove(MTGCard * card); int Remove(MTGCard * card);
MTGCard * getNext(MTGCard * previous = NULL, int color = -1); MTGCard * getNext(MTGCard * previous = NULL, int color = -1);
MTGCard * getPrevious(MTGCard * next = NULL, int color = -1); MTGCard * getPrevious(MTGCard * next = NULL, int color = -1);
void updateCounts(MTGCard * card = NULL, int removed = 0); void updateCounts(MTGCard * card = NULL, int quantity = 1);
int getCount(int color = -1); int getCount(int color = -1);
int totalPrice(); int totalPrice();
void save(); void save();
+16 -5
View File
@@ -42,6 +42,8 @@ class MtgSets{
class MTGAllCards { class MTGAllCards {
private:
MTGCard * tempCard;
protected: protected:
int conf_read_mode; int conf_read_mode;
int colorsCount[Constants::MTG_NB_COLORS]; int colorsCount[Constants::MTG_NB_COLORS];
@@ -52,12 +54,12 @@ class MTGAllCards {
public: public:
TexturesCache * mCache; TexturesCache * mCache;
MTGCard * _(int i); vector<int> ids;
vector<MTGCard *> collection; map<int, MTGCard *> collection;
//collection[Constants::TOTAL_NUMBER_OF_CARDS];
MTGAllCards(); MTGAllCards();
~MTGAllCards(); ~MTGAllCards();
MTGAllCards(TexturesCache * cache); MTGAllCards(TexturesCache * cache);
MTGCard * _(int id);
void destroyAllCards(); void destroyAllCards();
MTGAllCards(const char * config_file, const char * set_name); MTGAllCards(const char * config_file, const char * set_name);
MTGAllCards(const char * config_file, const char * set_name, TexturesCache * cache); MTGAllCards(const char * config_file, const char * set_name, TexturesCache * cache);
@@ -75,22 +77,31 @@ class MTGAllCards {
}; };
class MTGDeck:public MTGAllCards{ class MTGDeck{
protected: protected:
string filename; string filename;
MTGAllCards * allcards;
int total_cards;
public: public:
TexturesCache * mCache;
MTGAllCards * database;
map <int,int> cards;
string meta_desc; string meta_desc;
string meta_name; string meta_name;
int totalCards();
MTGDeck(TexturesCache * cache, MTGAllCards * _allcards);
MTGDeck(const char * config_file, TexturesCache * cache, MTGAllCards * _allcards, int meta_only = 0); MTGDeck(const char * config_file, TexturesCache * cache, MTGAllCards * _allcards, int meta_only = 0);
int addRandomCards(int howmany, int setId = -1, int rarity = -1, const char * subtype = NULL); int addRandomCards(int howmany, int setId = -1, int rarity = -1, const char * subtype = NULL);
int add(int cardid); int add(int cardid);
int add(MTGDeck * deck); // adds the contents of "deck" into myself
int remove(int cardid); int remove(int cardid);
int removeAll(); int removeAll();
int add(MTGCard * card); int add(MTGCard * card);
int remove(MTGCard * card); int remove(MTGCard * card);
int save(); int save();
MTGCard * getCardById(int id);
}; };
+12 -14
View File
@@ -8,10 +8,10 @@ DeckDataWrapper::DeckDataWrapper(MTGDeck * deck){
for (int i = 0; i <= Constants::MTG_NB_COLORS; i++){ for (int i = 0; i <= Constants::MTG_NB_COLORS; i++){
colors[i] = 0; colors[i] = 0;
} }
for (int i = 0; i < deck->totalCards(); i++){ map<int,int>::iterator it;
MTGCard * card = deck->_(i); for (it = deck->cards.begin(); it!=deck->cards.end(); it++){
Add(card); MTGCard * card = deck->getCardById(it->first);
Add(card,it->second);
} }
currentColor = -1; currentColor = -1;
} }
@@ -33,7 +33,7 @@ DeckDataWrapper::~DeckDataWrapper(){
SAFE_DELETE(parent); SAFE_DELETE(parent);
} }
void DeckDataWrapper::updateCounts(MTGCard * card, int removed){ void DeckDataWrapper::updateCounts(MTGCard * card, int increment){
if (!card){ if (!card){
for (int i = 0; i < Constants::MTG_NB_COLORS+1; i++){ for (int i = 0; i < Constants::MTG_NB_COLORS+1; i++){
colors[i] = 0; colors[i] = 0;
@@ -47,8 +47,6 @@ void DeckDataWrapper::updateCounts(MTGCard * card, int removed){
} }
} }
}else{ }else{
int increment = 1;
if (removed) increment = -1;
colors[Constants::MTG_NB_COLORS] += increment; colors[Constants::MTG_NB_COLORS] += increment;
for (int i = 0; i < Constants::MTG_NB_COLORS; i++){ for (int i = 0; i < Constants::MTG_NB_COLORS; i++){
if (card->hasColor(i)) colors[i]+=increment; if (card->hasColor(i)) colors[i]+=increment;
@@ -56,20 +54,20 @@ void DeckDataWrapper::updateCounts(MTGCard * card, int removed){
} }
} }
int DeckDataWrapper::Add(MTGCard * card){ int DeckDataWrapper::Add(MTGCard * card, int quantity){
if(cards.find(card) == cards.end()){ if(cards.find(card) == cards.end()){
cards[card] = 1; cards[card] = quantity;
}else{ }else{
cards[card]++; cards[card]+= quantity;
} }
updateCounts(card); updateCounts(card,quantity);
return cards[card]; return cards[card];
} }
int DeckDataWrapper::Remove(MTGCard * card){ int DeckDataWrapper::Remove(MTGCard * card){
if(cards.find(card) == cards.end() || cards[card] == 0) return 0; if(cards.find(card) == cards.end() || cards[card] <= 0) return 0;
cards[card]--; cards[card]--;
updateCounts(card,1); updateCounts(card,-1);
return 1; return 1;
} }
@@ -165,7 +163,7 @@ int DeckDataWrapper::getCount(int color){
int DeckDataWrapper::totalPrice(){ int DeckDataWrapper::totalPrice(){
int total = 0; int total = 0;
PriceList * pricelist = NEW PriceList(RESPATH"/settings/prices.dat",this->parent); PriceList * pricelist = NEW PriceList(RESPATH"/settings/prices.dat",this->parent->database);
map<MTGCard *,int,Cmp1>::iterator it; map<MTGCard *,int,Cmp1>::iterator it;
for ( it=cards.begin() ; it != cards.end(); it++ ){ for ( it=cards.begin() ; it != cards.end(); it++ ){
MTGCard * current = (*it).first; MTGCard * current = (*it).first;
+1
View File
@@ -304,3 +304,4 @@ void MTGCard::setToughness(int _toughness){
int MTGCard::getToughness(){ int MTGCard::getToughness(){
return toughness; return toughness;
} }
+101 -58
View File
@@ -153,6 +153,7 @@ void MTGAllCards::initCounters(){
} }
void MTGAllCards::init(){ void MTGAllCards::init(){
tempCard = NULL;
mCache = NULL; mCache = NULL;
total_cards = 0; total_cards = 0;
initCounters(); initCounters();
@@ -179,12 +180,16 @@ MTGAllCards::MTGAllCards(){
} }
MTGAllCards::~MTGAllCards(){ MTGAllCards::~MTGAllCards(){
//Why don't we call destroyAllCards from here ???
} }
void MTGAllCards::destroyAllCards(){ void MTGAllCards::destroyAllCards(){
for (int i= 0; i < total_cards; i++){ map<int,MTGCard *>::iterator it;
SAFE_DELETE(collection[i]);
}; for (it = collection.begin(); it!=collection.end(); it++) delete(it->second);
collection.clear();
ids.clear();
} }
@@ -204,23 +209,21 @@ MTGAllCards::MTGAllCards(const char * config_file, const char * set_name, Textur
} }
MTGCard * MTGAllCards::_(int i){
if (i < total_cards) return collection[i];
return NULL;
}
int MTGAllCards::randomCardId(){ int MTGAllCards::randomCardId(){
int id = (rand() % total_cards); int id = (rand() % ids.size());
return collection[id]->getMTGId(); return ids[id];
} }
int MTGAllCards::countBySet(int setId){ int MTGAllCards::countBySet(int setId){
int result = 0; int result = 0;
for (int i=0; i< total_cards; i++){ map<int,MTGCard *>::iterator it;
if(collection[i]->setId == setId){
for (it = collection.begin(); it!=collection.end(); it++){
MTGCard * c = it->second;
if( c->setId == setId){
result++; result++;
} }
} }
@@ -230,8 +233,10 @@ int MTGAllCards::countBySet(int setId){
//TODO more efficient way ? //TODO more efficient way ?
int MTGAllCards::countByType(const char * _type){ int MTGAllCards::countByType(const char * _type){
int result = 0; int result = 0;
for (int i=0; i< total_cards; i++){ map<int,MTGCard *>::iterator it;
if(collection[i]->hasType(_type)){ for (it = collection.begin(); it!=collection.end(); it++){
MTGCard * c = it->second;
if(c->hasType(_type)){
result++; result++;
} }
} }
@@ -244,8 +249,10 @@ int MTGAllCards::countByColor(int color){
for (int i=0; i< Constants::MTG_NB_COLORS; i++){ for (int i=0; i< Constants::MTG_NB_COLORS; i++){
colorsCount[i] = 0; colorsCount[i] = 0;
} }
for (int i=0; i< total_cards; i++){ map<int,MTGCard *>::iterator it;
int j = collection[i]->getColor(); for (it = collection.begin(); it!=collection.end(); it++){
MTGCard * c = it->second;
int j = c->getColor();
colorsCount[j]++; colorsCount[j]++;
} }
@@ -268,16 +275,26 @@ int MTGAllCards::readConfLine(std::ifstream &file, int set_id){
switch(conf_read_mode) { switch(conf_read_mode) {
case 0: case 0:
if (s[0] == '['){ if (s[0] == '['){
collection.push_back(NEW MTGCard(mCache,set_id)); tempCard = NEW MTGCard(mCache,set_id);
conf_read_mode = 1; conf_read_mode = 1;
} }
break; break;
case 1: case 1:
if (s[0] == '[' && s[1] == '/'){ if (s[0] == '[' && s[1] == '/'){
conf_read_mode = 0; conf_read_mode = 0;
total_cards++; int newId = tempCard->getId();
if (collection.find(newId) != collection.end()){
char outBuf[4096];
sprintf(outBuf,"warning, card id collision! : %i - %s\n", newId, tempCard->name.c_str());
OutputDebugString (outBuf);
delete tempCard;
}else{ }else{
processConfLine(s, collection[total_cards]); ids.push_back(newId);
collection[newId] = tempCard;
total_cards++;
}
}else{
processConfLine(s, tempCard);
} }
break; break;
default: default:
@@ -292,16 +309,18 @@ int MTGAllCards::readConfLine(std::ifstream &file, int set_id){
MTGCard * MTGAllCards::getCardById(int id){ MTGCard * MTGAllCards::getCardById(int id){
int i; map<int, MTGCard *>::iterator it = collection.find(id);
for (i=0; i<total_cards; i++){ if ( it != collection.end()){
int cardId = collection[i]->getMTGId(); return (it->second);
if (cardId == id){
return collection[i];
}
} }
return 0; return 0;
} }
MTGCard * MTGAllCards::_(int index){
if (index >= total_cards) return NULL;
return getCardById(ids[index]);
}
MTGCard * MTGAllCards::getCardByName(string name){ MTGCard * MTGAllCards::getCardByName(string name){
if (!name.size()) return NULL; if (!name.size()) return NULL;
if (name[0] == '#') return NULL; if (name[0] == '#') return NULL;
@@ -314,11 +333,13 @@ MTGCard * MTGAllCards::getCardByName(string name){
name = name.substr(0,found); name = name.substr(0,found);
setId = MtgSets::SetsList->find(setName); setId = MtgSets::SetsList->find(setName);
} }
for (int i=0; i<total_cards; i++){ map<int,MTGCard *>::iterator it;
if (setId!=-1 && setId != collection[i]->setId) continue; for (it = collection.begin(); it!=collection.end(); it++){
string cardName = collection[i]->name; MTGCard * c = it->second;
if (setId!=-1 && setId != c->setId) continue;
string cardName = c->name;
std::transform(cardName.begin(), cardName.end(), cardName.begin(),::tolower ); std::transform(cardName.begin(), cardName.end(), cardName.begin(),::tolower );
if (cardName.compare(name) == 0) return collection[i]; if (cardName.compare(name) == 0) return c;
} }
return NULL; return NULL;
@@ -326,11 +347,16 @@ MTGCard * MTGAllCards::getCardByName(string name){
MTGDeck::MTGDeck(TexturesCache * cache, MTGAllCards * _allcards){
mCache = cache;
total_cards = 0;
database = _allcards;
}
MTGDeck::MTGDeck(const char * config_file, TexturesCache * cache, MTGAllCards * _allcards, int meta_only){ MTGDeck::MTGDeck(const char * config_file, TexturesCache * cache, MTGAllCards * _allcards, int meta_only){
mCache = cache; mCache = cache;
total_cards = 0; total_cards = 0;
allcards = _allcards; database = _allcards;
filename = config_file; filename = config_file;
size_t slash = filename.find_last_of("/"); size_t slash = filename.find_last_of("/");
size_t dot = filename.find("."); size_t dot = filename.find(".");
@@ -368,7 +394,7 @@ MTGDeck::MTGDeck(const char * config_file, TexturesCache * cache, MTGAllCards *
s=s.substr(0,found); s=s.substr(0,found);
OutputDebugString(s.c_str()); OutputDebugString(s.c_str());
} }
MTGCard * card = allcards->getCardByName(s); MTGCard * card = database->getCardByName(s);
if (card){ if (card){
for (int i = 0; i < nb; i++){ for (int i = 0; i < nb; i++){
add(card); add(card);
@@ -384,15 +410,20 @@ MTGDeck::MTGDeck(const char * config_file, TexturesCache * cache, MTGAllCards *
} }
int MTGDeck::totalCards(){
return total_cards;
}
MTGCard * MTGDeck::getCardById(int mtgId){
return database->getCardById(mtgId);
}
int MTGDeck::addRandomCards(int howmany, int setId, int rarity, const char * _subtype){ int MTGDeck::addRandomCards(int howmany, int setId, int rarity, const char * _subtype){
int collectionTotal = allcards->totalCards(); int collectionTotal = database->totalCards();
if (!collectionTotal) return 0; if (!collectionTotal) return 0;
if (setId == -1 && rarity == -1 && !_subtype){ if (setId == -1 && rarity == -1 && !_subtype){
for (int i = 0; i < howmany; i++){ for (int i = 0; i < howmany; i++){
int id = (rand() % collectionTotal); add(database->randomCardId());
add(allcards->_(id));
} }
return 1; return 1;
} }
@@ -404,60 +435,69 @@ int MTGDeck::addRandomCards(int howmany, int setId, int rarity, const char * _su
vector<int> subcollection; vector<int> subcollection;
int subtotal = 0; int subtotal = 0;
for (int i = 0; i < collectionTotal; i++){ for (int i = 0; i < collectionTotal; i++){
MTGCard * card = allcards->_(i); MTGCard * card = database->_(i);
if ((setId == -1 || card->setId == setId) && if ((setId == -1 || card->setId == setId) &&
(rarity == -1 || card->getRarity()==rarity) && (rarity == -1 || card->getRarity()==rarity) &&
(!_subtype || card->hasSubtype(subtype)) (!_subtype || card->hasSubtype(subtype))
){ ){
subcollection.push_back(i); subcollection.push_back(card->getId());
subtotal++; subtotal++;
} }
} }
if (subtotal == 0) return 0; if (subtotal == 0) return 0;
for (int i = 0; i < howmany; i++){ for (int i = 0; i < howmany; i++){
int id = (rand() % subtotal); int id = (rand() % subtotal);
add(allcards->_(subcollection[id])); add(subcollection[id]);
} }
return 1; return 1;
} }
int MTGDeck::add(MTGDeck * deck){
map<int,int>::iterator it;
for (it = deck->cards.begin(); it!=deck->cards.end(); it++){
for (int i = 0; i < it->second; i++){
add(it->first);
}
}
return deck->totalCards();
}
int MTGDeck::add(int cardid){ int MTGDeck::add(int cardid){
MTGCard * card = allcards->getCardById(cardid); if (!database->getCardById(cardid)) return 0;
add(card); if(cards.find(cardid) == cards.end()){
cards[cardid] = 1;
}else{
cards[cardid]++;
}
++total_cards;
//initCounters();
return total_cards; return total_cards;
} }
int MTGDeck::add(MTGCard * card){ int MTGDeck::add(MTGCard * card){
if (!card) return 0; if (!card) return 0;
collection.push_back(card); return (add(card->getId()));
++total_cards;
initCounters();
return total_cards;
} }
int MTGDeck::removeAll(){ int MTGDeck::removeAll(){
total_cards = 0; total_cards = 0;
collection.clear(); cards.clear();
initCounters(); //initCounters();
return 1; return 1;
} }
int MTGDeck::remove(int cardid){ int MTGDeck::remove(int cardid){
MTGCard * card = getCardById(cardid); if(cards.find(cardid) == cards.end() || cards[cardid] == 0) return 0;
return remove(card); cards[cardid]--;
total_cards--;
//initCounters();
return 1;
} }
int MTGDeck::remove(MTGCard * card){ int MTGDeck::remove(MTGCard * card){
for (int i = 0; i<total_cards; i++){ if (!card) return 0;
if (collection[i] == card){ return (remove(card->getId()));
collection.erase(collection.begin()+i);
total_cards--;
initCounters();
return 1;
}
}
return 0;
} }
int MTGDeck::save(){ int MTGDeck::save(){
@@ -467,10 +507,13 @@ int MTGDeck::save(){
#if defined (WIN32) || defined (LINUX) #if defined (WIN32) || defined (LINUX)
OutputDebugString("saving"); OutputDebugString("saving");
#endif #endif
for (int i = 0; i<total_cards; i++){ map<int,int>::iterator it;
sprintf(writer,"%i\n", collection[i]->getMTGId()); for (it = cards.begin(); it!=cards.end(); it++){
sprintf(writer,"%i\n", it->first);
for (int j = 0; j<it->second; j++){
file<<writer; file<<writer;
} }
}
file.close(); file.close();
} }
+5 -5
View File
@@ -35,16 +35,16 @@ MTGPlayerCards::MTGPlayerCards(MTGAllCards * _collection, int * idList, int idLi
MTGPlayerCards::MTGPlayerCards(MTGAllCards * _collection,MTGDeck * deck){ MTGPlayerCards::MTGPlayerCards(MTGAllCards * _collection,MTGDeck * deck){
init(); init();
collection = _collection; collection = _collection;
for (int i=0; i<deck->totalCards(); i++){ map<int,int>::iterator it;
MTGCard * card = deck->collection[i]; for (it = deck->cards.begin(); it!=deck->cards.end(); it++){
MTGCard * card = deck->getCardById(it->first);
if (card){ if (card){
for (int i = 0; i < it->second; i++){
MTGCardInstance * newCard = NEW MTGCardInstance(card, this); MTGCardInstance * newCard = NEW MTGCardInstance(card, this);
library->addCard(newCard); library->addCard(newCard);
} }
} }
}
} }
MTGPlayerCards::~MTGPlayerCards(){ MTGPlayerCards::~MTGPlayerCards(){
+15 -7
View File
@@ -251,18 +251,26 @@ void ShopItems::ButtonPressed(int controllerId, int controlId){
safeDeleteDisplay(); safeDeleteDisplay();
display = NEW CardDisplay(12,NULL, SCREEN_WIDTH - 200, SCREEN_HEIGHT/2,this,NULL,5); display = NEW CardDisplay(12,NULL, SCREEN_WIDTH - 200, SCREEN_HEIGHT/2,this,NULL,5);
int curNbcards = playerdata->collection->totalCards(); int curNbcards = playerdata->collection->totalCards();
MTGDeck * tempDeck = NEW MTGDeck(NULL,playerdata->collection->database);
playerdata->collection->addRandomCards(1, setIds[showPriceDialog],Constants::RARITY_R); tempDeck->addRandomCards(1, setIds[showPriceDialog],Constants::RARITY_R);
playerdata->collection->addRandomCards(3, setIds[showPriceDialog],Constants::RARITY_U); tempDeck->addRandomCards(3, setIds[showPriceDialog],Constants::RARITY_U);
playerdata->collection->addRandomCards(11, setIds[showPriceDialog],Constants::RARITY_C); tempDeck->addRandomCards(11, setIds[showPriceDialog],Constants::RARITY_C);
playerdata->collection->add(tempDeck);
int newNbCards = playerdata->collection->totalCards();;
for (int i = curNbcards; i < newNbCards ; i++){ int i = 0;
MTGCardInstance * card = NEW MTGCardInstance(playerdata->collection->_(i), NULL); for (map<int,int>::iterator it = tempDeck->cards.begin(); it!=tempDeck->cards.end(); it++){
displayCards[i-curNbcards] = card; MTGCard * c = tempDeck->getCardById(it->first);
for (int j = 0; j < it->second; j++){
MTGCardInstance * card = NEW MTGCardInstance(c, NULL);
displayCards[i] = card;
display->AddCard(card); display->AddCard(card);
i++;
} }
} }
delete tempDeck;
}
//Remove(showPriceDialog); //Remove(showPriceDialog);
showPriceDialog = -1; showPriceDialog = -1;
}else{ }else{
-4
View File
@@ -252,10 +252,6 @@
RelativePath=".\src\CardDisplay.cpp" RelativePath=".\src\CardDisplay.cpp"
> >
</File> </File>
<File
RelativePath=".\src\CardEffect.cpp"
>
</File>
<File <File
RelativePath=".\src\CardGui.cpp" RelativePath=".\src\CardGui.cpp"
> >