Erwan
- _cards.dat parsing error fixes on erroneous files - replaced cards array with a vector for MTGGameZones
This commit is contained in:
@@ -21,7 +21,7 @@ class GameApp;
|
|||||||
class MTGCard;
|
class MTGCard;
|
||||||
|
|
||||||
|
|
||||||
#define MAX_SETS 30
|
#define MAX_SETS 50
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class MTGGameZone {
|
|||||||
public:
|
public:
|
||||||
Player * owner;
|
Player * owner;
|
||||||
//Both cards and cardsMap contain the cards of a zone. The long term objective is to get rid of the array
|
//Both cards and cardsMap contain the cards of a zone. The long term objective is to get rid of the array
|
||||||
MTGCardInstance * cards[MTG_MAX_PLAYER_CARDS];
|
vector<MTGCardInstance *> cards; //[MTG_MAX_PLAYER_CARDS];
|
||||||
map<MTGCardInstance *,int> cardsMap;
|
map<MTGCardInstance *,int> cardsMap;
|
||||||
int nb_cards;
|
int nb_cards;
|
||||||
MTGGameZone();
|
MTGGameZone();
|
||||||
|
|||||||
@@ -238,9 +238,9 @@ int MTGAllCards::totalCards(){
|
|||||||
int MTGAllCards::readConfLine(std::ifstream &file, int set_id){
|
int MTGAllCards::readConfLine(std::ifstream &file, int set_id){
|
||||||
|
|
||||||
string s;
|
string s;
|
||||||
int result = 0;
|
int result = 1;
|
||||||
if(std::getline(file,s)) result = 1;
|
if(!std::getline(file,s)) return 0;
|
||||||
if (!s.size()) return 0;
|
if (!s.size()) return -1;
|
||||||
if (s[s.size()-1] == '\r') s.erase(s.size()-1); //Handle DOS files
|
if (s[s.size()-1] == '\r') s.erase(s.size()-1); //Handle DOS files
|
||||||
switch(conf_read_mode) {
|
switch(conf_read_mode) {
|
||||||
case 0:
|
case 0:
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ MTGPlayerCards::MTGPlayerCards(MTGAllCards * _collection, int * idList, int idLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MTGPlayerCards::~MTGPlayerCards(){
|
MTGPlayerCards::~MTGPlayerCards(){
|
||||||
@@ -44,6 +45,7 @@ void MTGPlayerCards::initGame(int shuffle, int draw){
|
|||||||
if (shuffle) library->shuffle();
|
if (shuffle) library->shuffle();
|
||||||
if (draw){
|
if (draw){
|
||||||
for (int i=0;i<7;i++){
|
for (int i=0;i<7;i++){
|
||||||
|
OutputDebugString("draw\n");
|
||||||
drawFromLibrary();
|
drawFromLibrary();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -167,18 +169,19 @@ MTGCardInstance * MTGGameZone::removeCard(MTGCardInstance * card, int createCopy
|
|||||||
cardsMap.erase(card);
|
cardsMap.erase(card);
|
||||||
for (i=0; i<(nb_cards); i++) {
|
for (i=0; i<(nb_cards); i++) {
|
||||||
if (cards[i] == card){
|
if (cards[i] == card){
|
||||||
cards[i] = cards[nb_cards -1];
|
//cards[i] = cards[nb_cards -1];
|
||||||
nb_cards--;
|
nb_cards--;
|
||||||
MTGCardInstance * copy = card;
|
cards.erase(cards.begin()+i);
|
||||||
|
MTGCardInstance * copy = card;
|
||||||
if (card->isToken){ //TODO better than this ?
|
if (card->isToken){ //TODO better than this ?
|
||||||
return card;
|
return card;
|
||||||
}
|
}
|
||||||
card->lastController = card->controller();
|
card->lastController = card->controller();
|
||||||
if (createCopy) {
|
if (createCopy) {
|
||||||
copy = NEW MTGCardInstance(card->model,card->owner->game);
|
copy = NEW MTGCardInstance(card->model,card->owner->game);
|
||||||
copy->previous = card;
|
copy->previous = card;
|
||||||
card->next = copy;
|
card->next = copy;
|
||||||
}
|
}
|
||||||
copy->previousZone = this;
|
copy->previousZone = this;
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
@@ -232,7 +235,7 @@ void MTGGameZone::shuffle(){
|
|||||||
|
|
||||||
void MTGGameZone::addCard(MTGCardInstance * card){
|
void MTGGameZone::addCard(MTGCardInstance * card){
|
||||||
if (!card) return;
|
if (!card) return;
|
||||||
cards[nb_cards] = card;
|
cards.push_back(card);
|
||||||
nb_cards++;
|
nb_cards++;
|
||||||
cardsMap[card] = 1;
|
cardsMap[card] = 1;
|
||||||
|
|
||||||
@@ -242,8 +245,9 @@ MTGCardInstance * MTGGameZone::draw(){
|
|||||||
if (!nb_cards) return NULL;
|
if (!nb_cards) return NULL;
|
||||||
nb_cards--;
|
nb_cards--;
|
||||||
lastCardDrawn = cards[nb_cards];
|
lastCardDrawn = cards[nb_cards];
|
||||||
cardsMap.erase(cards[nb_cards]);
|
cards.pop_back();
|
||||||
return cards[nb_cards];
|
cardsMap.erase( lastCardDrawn);
|
||||||
|
return lastCardDrawn;
|
||||||
}
|
}
|
||||||
|
|
||||||
MTGCardInstance * MTGLibrary::draw(){
|
MTGCardInstance * MTGLibrary::draw(){
|
||||||
|
|||||||
Reference in New Issue
Block a user