Erwan
-fixed a memory leak - Added P02 and PTK - New way to create tokens in the parser, much more flexible, see the Hive in RV. Tokens can now be written as other cards, with a rarity of "T". I suggest their id to be the negative value of the card that generates them when possible. Naming convention for images is the same as before: a negative id such as -1138 will need a [id]t.jpg image (1138t.jpg). Positive ids work as "normal" pictures
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "../include/Translate.h"
|
||||
|
||||
hgeParticleSystem* GameApp::Particles[] = {NULL,NULL,NULL,NULL,NULL,NULL};
|
||||
MTGAllCards * GameApp::collection = NULL;
|
||||
int GameApp::HasMusic = 1;
|
||||
JMusic * GameApp::music = NULL;
|
||||
string GameApp::systemError = "";
|
||||
@@ -66,7 +67,7 @@ GameApp::~GameApp()
|
||||
|
||||
void GameApp::Create()
|
||||
{
|
||||
srand(time(0)); // initialize random
|
||||
srand((unsigned int)time(0)); // initialize random
|
||||
#if defined (WIN32)
|
||||
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
|
||||
#elif not defined (LINUX)
|
||||
|
||||
@@ -385,9 +385,21 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
//Token creator. Name, type, p/t, abilities
|
||||
found = s.find("token(");
|
||||
if (found != string::npos){
|
||||
int end = s.find(",", found);
|
||||
WParsedInt * multiplier = NULL;
|
||||
size_t star = s.find("*");
|
||||
if (star != string::npos) multiplier = NEW WParsedInt(s.substr(star+1),spell,card);
|
||||
|
||||
size_t end = s.find(")", found);
|
||||
int tokenId = atoi(s.substr(found + 6,end - found - 6).c_str());
|
||||
if (tokenId){
|
||||
ATokenCreator * tok = NEW ATokenCreator(id,card,NULL,tokenId,0, multiplier);
|
||||
tok->oneShot = 1;
|
||||
return tok;
|
||||
}
|
||||
|
||||
end = s.find(",", found);
|
||||
string sname = s.substr(found + 6,end - found - 6);
|
||||
int previous = end+1;
|
||||
size_t previous = end+1;
|
||||
end = s.find(",",previous);
|
||||
string stypes = s.substr(previous,end - previous);
|
||||
previous = end+1;
|
||||
@@ -396,9 +408,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
int power, toughness;
|
||||
parsePowerToughness(spt,&power, &toughness);
|
||||
string sabilities = s.substr(end+1);
|
||||
WParsedInt * multiplier = NULL;
|
||||
found = s.find("*");
|
||||
if (found != string::npos)multiplier = NEW WParsedInt(s.substr(found+1),spell,card);
|
||||
|
||||
ATokenCreator * tok = NEW ATokenCreator(id,card,NULL,sname,stypes,power,toughness,sabilities,0, multiplier);
|
||||
tok->oneShot = 1;
|
||||
return tok;
|
||||
|
||||
@@ -447,12 +447,7 @@ int MTGDeck::addRandomCards(int howmany, int * setIds, int nbSets, int rarity, c
|
||||
|
||||
int collectionTotal = database->totalCards();
|
||||
if (!collectionTotal) return 0;
|
||||
if (nbSets == 0 && rarity == -1 && !_subtype && !nbcolors){
|
||||
for (int i = 0; i < howmany; i++){
|
||||
add(database->randomCardId());
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
char subtype[4096];
|
||||
if (_subtype)
|
||||
sprintf(subtype, _subtype);
|
||||
@@ -462,7 +457,8 @@ int MTGDeck::addRandomCards(int howmany, int * setIds, int nbSets, int rarity, c
|
||||
int subtotal = 0;
|
||||
for (int i = 0; i < collectionTotal; i++){
|
||||
MTGCard * card = database->_(i);
|
||||
if ((rarity == -1 || card->getRarity()==rarity) &&
|
||||
int r = card->getRarity();
|
||||
if (r != Constants::RARITY_T && (rarity == -1 || r==rarity) &&
|
||||
(!_subtype || card->hasSubtype(subtype))
|
||||
){
|
||||
int ok = 0;
|
||||
@@ -612,6 +608,12 @@ MTGSets setlist; //Our global.
|
||||
MTGSets::MTGSets(){
|
||||
}
|
||||
|
||||
MTGSets::~MTGSets(){
|
||||
for (size_t i = 0; i < setinfo.size(); ++i){
|
||||
delete (setinfo[i]);
|
||||
}
|
||||
}
|
||||
|
||||
MTGSetInfo* MTGSets::getInfo(int setID){
|
||||
if(setID < 0 || setID >= (int) setinfo.size())
|
||||
return NULL;
|
||||
|
||||
@@ -530,10 +530,10 @@ OutputDebugString ("CHECKING INTERRUPTIBLE\n");
|
||||
}
|
||||
|
||||
|
||||
int TargetZoneChooser::targetsZone(MTGGameZone * z){
|
||||
bool TargetZoneChooser::targetsZone(MTGGameZone * z){
|
||||
for (int i = 0; i < nbzones; i++)
|
||||
if (MTGGameZone::intToZone(zones[i],source) == z) return 1;
|
||||
return 0;
|
||||
if (MTGGameZone::intToZone(zones[i],source) == z) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Player Target */
|
||||
|
||||
Reference in New Issue
Block a user