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:
@@ -0,0 +1,11 @@
|
|||||||
|
[card]
|
||||||
|
id=6536
|
||||||
|
name=Air Elemental
|
||||||
|
mana={3}{U}{U}
|
||||||
|
type=Creature
|
||||||
|
subtype=Elemental
|
||||||
|
power=4
|
||||||
|
toughness=4
|
||||||
|
text=Flying
|
||||||
|
rarity=U
|
||||||
|
[/card]
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,12 @@
|
|||||||
|
[card]
|
||||||
|
id=10487
|
||||||
|
name=Alert Shu Infantry
|
||||||
|
mana={2}{W}
|
||||||
|
type=Creature
|
||||||
|
subtype=Human Soldier
|
||||||
|
power=2
|
||||||
|
toughness=2
|
||||||
|
text=Vigilance
|
||||||
|
abilities=vigilance
|
||||||
|
rarity=U
|
||||||
|
[/card]
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -2112,7 +2112,7 @@ type=Instant
|
|||||||
[/card]
|
[/card]
|
||||||
[card]
|
[card]
|
||||||
text={5}, {T}: Put a 1/1 Insect artifact creature token with flying named Wasp onto the battlefield. (It can't be blocked except by creatures with flying or reach.)
|
text={5}, {T}: Put a 1/1 Insect artifact creature token with flying named Wasp onto the battlefield. (It can't be blocked except by creatures with flying or reach.)
|
||||||
auto={5},{T}:token(Wasp,creature artifact insect, 1/1,flying artifact)
|
auto={5},{T}:token(-1138)
|
||||||
id=1138
|
id=1138
|
||||||
name=The Hive
|
name=The Hive
|
||||||
rarity=R
|
rarity=R
|
||||||
@@ -2120,6 +2120,17 @@ mana={5}
|
|||||||
type=Artifact
|
type=Artifact
|
||||||
[/card]
|
[/card]
|
||||||
[card]
|
[card]
|
||||||
|
text=Flying
|
||||||
|
abilities=flying
|
||||||
|
id=-1138
|
||||||
|
name=Wasp
|
||||||
|
type=Artifact Creature
|
||||||
|
rarity=T
|
||||||
|
power=1
|
||||||
|
toughness=1
|
||||||
|
type=Artifact
|
||||||
|
[/card]
|
||||||
|
[card]
|
||||||
text=As The Rack enters the battlefield, choose an opponent. At the beginning of the chosen player's upkeep, The Rack deals X damage to that player, where X is 3 minus the number of cards in his or her hand.
|
text=As The Rack enters the battlefield, choose an opponent. At the beginning of the chosen player's upkeep, The Rack deals X damage to that player, where X is 3 minus the number of cards in his or her hand.
|
||||||
id=1139
|
id=1139
|
||||||
name=The Rack
|
name=The Rack
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ generic/targetController_life.txt
|
|||||||
generic/targetController_life2.txt
|
generic/targetController_life2.txt
|
||||||
generic/targetController_damage.txt
|
generic/targetController_damage.txt
|
||||||
generic/tokens.txt
|
generic/tokens.txt
|
||||||
|
generic/tokens2.txt
|
||||||
generic/trample.txt
|
generic/trample.txt
|
||||||
generic/trample_vs_indestructible.txt
|
generic/trample_vs_indestructible.txt
|
||||||
generic/trample_vs_multiblock.txt
|
generic/trample_vs_multiblock.txt
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
#Bug:Segfault in GuiPlay.cpp
|
||||||
|
[INIT]
|
||||||
|
SECONDMAIN
|
||||||
|
[PLAYER1]
|
||||||
|
inplay:135253
|
||||||
|
manapool:{5}
|
||||||
|
[PLAYER2]
|
||||||
|
inplay:hypnotic specter
|
||||||
|
[DO]
|
||||||
|
135253
|
||||||
|
eot
|
||||||
|
eot
|
||||||
|
next
|
||||||
|
#upkeep
|
||||||
|
next
|
||||||
|
#draw
|
||||||
|
next
|
||||||
|
#main
|
||||||
|
next
|
||||||
|
#combat begins
|
||||||
|
next
|
||||||
|
#attackers
|
||||||
|
-135253
|
||||||
|
next
|
||||||
|
#blockers
|
||||||
|
hypnotic specter
|
||||||
|
next
|
||||||
|
#damage
|
||||||
|
next
|
||||||
|
#end combat
|
||||||
|
eot
|
||||||
|
next
|
||||||
|
[ASSERT]
|
||||||
|
UPKEEP
|
||||||
|
[PLAYER1]
|
||||||
|
inplay:135253
|
||||||
|
[PLAYER2]
|
||||||
|
inplay:hypnotic specter
|
||||||
|
[END]
|
||||||
@@ -537,12 +537,18 @@ public:
|
|||||||
list<int>types;
|
list<int>types;
|
||||||
list<int>colors;
|
list<int>colors;
|
||||||
int power, toughness;
|
int power, toughness;
|
||||||
|
int tokenId;
|
||||||
string name;
|
string name;
|
||||||
WParsedInt * multiplier;
|
WParsedInt * multiplier;
|
||||||
|
ATokenCreator(int _id,MTGCardInstance * _source,ManaCost * _cost, int tokenId, int _doTap, WParsedInt * multiplier = NULL):ActivatedAbility(_id,_source,_cost,0,_doTap), multiplier(multiplier), tokenId(tokenId){
|
||||||
|
if(!multiplier) this->multiplier = NEW WParsedInt(1);
|
||||||
|
}
|
||||||
|
|
||||||
ATokenCreator(int _id,MTGCardInstance * _source,ManaCost * _cost, string sname, string stypes,int _power,int _toughness, string sabilities, int _doTap, WParsedInt * multiplier = NULL):ActivatedAbility(_id,_source,_cost,0,_doTap), multiplier(multiplier){
|
ATokenCreator(int _id,MTGCardInstance * _source,ManaCost * _cost, string sname, string stypes,int _power,int _toughness, string sabilities, int _doTap, WParsedInt * multiplier = NULL):ActivatedAbility(_id,_source,_cost,0,_doTap), multiplier(multiplier){
|
||||||
power = _power;
|
power = _power;
|
||||||
toughness = _toughness;
|
toughness = _toughness;
|
||||||
name = sname;
|
name = sname;
|
||||||
|
tokenId = 0;
|
||||||
if(!multiplier) this->multiplier = NEW WParsedInt(1);
|
if(!multiplier) this->multiplier = NEW WParsedInt(1);
|
||||||
|
|
||||||
//TODO this is a copy/past of other code that's all around the place, everything should be in a dedicated parser class;
|
//TODO this is a copy/past of other code that's all around the place, everything should be in a dedicated parser class;
|
||||||
@@ -578,20 +584,27 @@ public:
|
|||||||
|
|
||||||
int resolve(){
|
int resolve(){
|
||||||
for (int i = 0; i < multiplier->getValue(); ++i){
|
for (int i = 0; i < multiplier->getValue(); ++i){
|
||||||
Token * myToken = NEW Token(name,source,power,toughness);
|
MTGCardInstance * myToken;
|
||||||
list<int>::iterator it;
|
if (tokenId){
|
||||||
for ( it=types.begin() ; it != types.end(); it++ ){
|
MTGCard * card = GameApp::collection->getCardById(tokenId);
|
||||||
myToken->addType(*it);
|
myToken = NEW MTGCardInstance(card,source->controller()->game);
|
||||||
}
|
} else {
|
||||||
for ( it=colors.begin() ; it != colors.end(); it++ ){
|
myToken = NEW Token(name,source,power,toughness);
|
||||||
myToken->setColor(*it);
|
list<int>::iterator it;
|
||||||
}
|
for ( it=types.begin() ; it != types.end(); it++ ){
|
||||||
for ( it=abilities.begin() ; it != abilities.end(); it++ ){
|
myToken->addType(*it);
|
||||||
myToken->basicAbilities[*it] = 1;
|
}
|
||||||
|
for ( it=colors.begin() ; it != colors.end(); it++ ){
|
||||||
|
myToken->setColor(*it);
|
||||||
|
}
|
||||||
|
for ( it=abilities.begin() ; it != abilities.end(); it++ ){
|
||||||
|
myToken->basicAbilities[*it] = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
source->controller()->game->temp->addCard(myToken);
|
source->controller()->game->temp->addCard(myToken);
|
||||||
Spell * spell = NEW Spell(myToken);
|
Spell * spell = NEW Spell(myToken);
|
||||||
spell->resolve();
|
spell->resolve();
|
||||||
|
spell->source->isToken = 1;
|
||||||
delete spell;
|
delete spell;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class GameApp: public JApp
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
int players[2];
|
int players[2];
|
||||||
MTGAllCards * collection;
|
|
||||||
int gameType;
|
int gameType;
|
||||||
CardEffect *effect;
|
CardEffect *effect;
|
||||||
|
|
||||||
@@ -84,6 +84,7 @@ class GameApp: public JApp
|
|||||||
static int HasMusic;
|
static int HasMusic;
|
||||||
static string systemError;
|
static string systemError;
|
||||||
static JMusic* music;
|
static JMusic* music;
|
||||||
|
static MTGAllCards * collection;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ class MTGSets{
|
|||||||
public:
|
public:
|
||||||
friend class MTGSetInfo;
|
friend class MTGSetInfo;
|
||||||
MTGSets();
|
MTGSets();
|
||||||
|
~MTGSets();
|
||||||
|
|
||||||
int Add(const char * subtype);
|
int Add(const char * subtype);
|
||||||
int findSet(string value);
|
int findSet(string value);
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ class Constants
|
|||||||
RARITY_U = 'U',
|
RARITY_U = 'U',
|
||||||
RARITY_C = 'C',
|
RARITY_C = 'C',
|
||||||
RARITY_L = 'L',
|
RARITY_L = 'L',
|
||||||
|
RARITY_T = 'T', //Tokens
|
||||||
|
|
||||||
//Price for singles
|
//Price for singles
|
||||||
PRICE_1M = 3000,
|
PRICE_1M = 3000,
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class TargetChooser: public TargetsList {
|
|||||||
MTGCardInstance * targetter; //Optional, usually equals source, used for protection from...
|
MTGCardInstance * targetter; //Optional, usually equals source, used for protection from...
|
||||||
|
|
||||||
int maxtargets; //Set to -1 for "unlimited"
|
int maxtargets; //Set to -1 for "unlimited"
|
||||||
virtual int targetsZone(MTGGameZone * z){return 0;};
|
virtual bool targetsZone(MTGGameZone * z){return false;};
|
||||||
int ForceTargetListReady();
|
int ForceTargetListReady();
|
||||||
int targetsReadyCheck();
|
int targetsReadyCheck();
|
||||||
virtual int addTarget(Targetable * target);
|
virtual int addTarget(Targetable * target);
|
||||||
@@ -68,7 +68,7 @@ class TargetZoneChooser:public TargetChooser{
|
|||||||
int zones[10];
|
int zones[10];
|
||||||
int nbzones;
|
int nbzones;
|
||||||
int init(int * _zones, int _nbzones);
|
int init(int * _zones, int _nbzones);
|
||||||
int targetsZone(MTGGameZone * z);
|
bool targetsZone(MTGGameZone * z);
|
||||||
TargetZoneChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false);
|
TargetZoneChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false);
|
||||||
TargetZoneChooser(int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false);
|
TargetZoneChooser(int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false);
|
||||||
virtual bool canTarget(Targetable * _card);
|
virtual bool canTarget(Targetable * _card);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "../include/Translate.h"
|
#include "../include/Translate.h"
|
||||||
|
|
||||||
hgeParticleSystem* GameApp::Particles[] = {NULL,NULL,NULL,NULL,NULL,NULL};
|
hgeParticleSystem* GameApp::Particles[] = {NULL,NULL,NULL,NULL,NULL,NULL};
|
||||||
|
MTGAllCards * GameApp::collection = NULL;
|
||||||
int GameApp::HasMusic = 1;
|
int GameApp::HasMusic = 1;
|
||||||
JMusic * GameApp::music = NULL;
|
JMusic * GameApp::music = NULL;
|
||||||
string GameApp::systemError = "";
|
string GameApp::systemError = "";
|
||||||
@@ -66,7 +67,7 @@ GameApp::~GameApp()
|
|||||||
|
|
||||||
void GameApp::Create()
|
void GameApp::Create()
|
||||||
{
|
{
|
||||||
srand(time(0)); // initialize random
|
srand((unsigned int)time(0)); // initialize random
|
||||||
#if defined (WIN32)
|
#if defined (WIN32)
|
||||||
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
|
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
|
||||||
#elif not defined (LINUX)
|
#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
|
//Token creator. Name, type, p/t, abilities
|
||||||
found = s.find("token(");
|
found = s.find("token(");
|
||||||
if (found != string::npos){
|
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);
|
string sname = s.substr(found + 6,end - found - 6);
|
||||||
int previous = end+1;
|
size_t previous = end+1;
|
||||||
end = s.find(",",previous);
|
end = s.find(",",previous);
|
||||||
string stypes = s.substr(previous,end - previous);
|
string stypes = s.substr(previous,end - previous);
|
||||||
previous = end+1;
|
previous = end+1;
|
||||||
@@ -396,9 +408,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
|||||||
int power, toughness;
|
int power, toughness;
|
||||||
parsePowerToughness(spt,&power, &toughness);
|
parsePowerToughness(spt,&power, &toughness);
|
||||||
string sabilities = s.substr(end+1);
|
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);
|
ATokenCreator * tok = NEW ATokenCreator(id,card,NULL,sname,stypes,power,toughness,sabilities,0, multiplier);
|
||||||
tok->oneShot = 1;
|
tok->oneShot = 1;
|
||||||
return tok;
|
return tok;
|
||||||
|
|||||||
@@ -447,12 +447,7 @@ int MTGDeck::addRandomCards(int howmany, int * setIds, int nbSets, int rarity, c
|
|||||||
|
|
||||||
int collectionTotal = database->totalCards();
|
int collectionTotal = database->totalCards();
|
||||||
if (!collectionTotal) return 0;
|
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];
|
char subtype[4096];
|
||||||
if (_subtype)
|
if (_subtype)
|
||||||
sprintf(subtype, _subtype);
|
sprintf(subtype, _subtype);
|
||||||
@@ -462,7 +457,8 @@ int MTGDeck::addRandomCards(int howmany, int * setIds, int nbSets, int rarity, c
|
|||||||
int subtotal = 0;
|
int subtotal = 0;
|
||||||
for (int i = 0; i < collectionTotal; i++){
|
for (int i = 0; i < collectionTotal; i++){
|
||||||
MTGCard * card = database->_(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))
|
(!_subtype || card->hasSubtype(subtype))
|
||||||
){
|
){
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
@@ -612,6 +608,12 @@ MTGSets setlist; //Our global.
|
|||||||
MTGSets::MTGSets(){
|
MTGSets::MTGSets(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MTGSets::~MTGSets(){
|
||||||
|
for (size_t i = 0; i < setinfo.size(); ++i){
|
||||||
|
delete (setinfo[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MTGSetInfo* MTGSets::getInfo(int setID){
|
MTGSetInfo* MTGSets::getInfo(int setID){
|
||||||
if(setID < 0 || setID >= (int) setinfo.size())
|
if(setID < 0 || setID >= (int) setinfo.size())
|
||||||
return NULL;
|
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++)
|
for (int i = 0; i < nbzones; i++)
|
||||||
if (MTGGameZone::intToZone(zones[i],source) == z) return 1;
|
if (MTGGameZone::intToZone(zones[i],source) == z) return true;
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Player Target */
|
/* Player Target */
|
||||||
|
|||||||
Reference in New Issue
Block a user