multi tokens images on same source
you can specifiy tnum:number on token parameters and it will concatenate the default token id and the specified number. example: token(Saproling, Creature Saproling, 1/1, green, tnum:15) if the source id is 12345, the default token id will be -12345, concat tnum, id will be -1234515 and the game will try to find the image 1234515t.jpg
This commit is contained in:
@@ -3547,6 +3547,7 @@ public:
|
||||
vector<MTGAbility *> currentAbilities;
|
||||
MTGAbility * andAbility;
|
||||
Player * tokenReciever;
|
||||
string cID;
|
||||
//by id
|
||||
ATokenCreator(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable *, ManaCost * _cost, int tokenId,string starfound, WParsedInt * multiplier = NULL,
|
||||
int who = 0,bool aLivingWeapon = false) :
|
||||
@@ -3557,6 +3558,7 @@ public:
|
||||
if (card) name = card->data->getName();
|
||||
battleReady = false;
|
||||
andAbility = NULL;
|
||||
cID = "";
|
||||
}
|
||||
//by name, card still require valid card.dat info, this just makes the primitive code far more readable. token(Eldrazi scion) instead of token(-1234234)...
|
||||
ATokenCreator(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable *, ManaCost * _cost, string cardName, string starfound, WParsedInt * multiplier = NULL,
|
||||
@@ -3569,10 +3571,11 @@ public:
|
||||
if (card) name = card->data->getName();
|
||||
battleReady = false;
|
||||
andAbility = NULL;
|
||||
cID = "";
|
||||
}
|
||||
//by construction
|
||||
ATokenCreator(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable *, ManaCost * _cost, string sname, string stypes, int _power, int _toughness,
|
||||
string sabilities, string starfound,WParsedInt * multiplier = NULL, int _who = 0,bool aLivingWeapon = false,string spt = "") :
|
||||
string sabilities, string starfound,WParsedInt * multiplier = NULL, int _who = 0,bool aLivingWeapon = false,string spt = "", string tnum = "") :
|
||||
ActivatedAbility(observer, _id, _source, _cost, 0),sabilities(sabilities),starfound(starfound), multiplier(multiplier), who(_who),aLivingWeapon(aLivingWeapon),spt(spt)
|
||||
{
|
||||
power = _power;
|
||||
@@ -3582,6 +3585,7 @@ public:
|
||||
aType = MTGAbility::STANDARD_TOKENCREATOR;
|
||||
battleReady = false;
|
||||
andAbility = NULL;
|
||||
cID = tnum;
|
||||
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;
|
||||
|
||||
@@ -3683,6 +3687,16 @@ public:
|
||||
}
|
||||
}
|
||||
string tokenText = "";
|
||||
if(!cID.empty())
|
||||
{
|
||||
string customId = "";
|
||||
ostringstream tokID;
|
||||
tokID << abs(myToken->getId());
|
||||
customId.append(""+tokID.str()+cID);
|
||||
customId = cReplaceString(customId," ","");
|
||||
WParsedInt newID(customId, NULL, source);
|
||||
myToken->setMTGId(-newID.getValue());
|
||||
}
|
||||
if(sabilities.find("token(") == string::npos)
|
||||
{
|
||||
tokenText = "(";
|
||||
|
||||
@@ -2420,15 +2420,21 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
string sname = tokenParameters[0];
|
||||
string stypes = tokenParameters[1];
|
||||
string spt = tokenParameters[2];
|
||||
|
||||
string cID = "";
|
||||
//reconstructing string abilities from the split version,
|
||||
// then we re-split it again in the token constructor,
|
||||
// this needs to be improved
|
||||
string sabilities = (tokenParameters.size() > 3)? tokenParameters[3] : "";
|
||||
for (size_t i = 4; i < tokenParameters.size(); ++i)
|
||||
{
|
||||
sabilities.append(",");
|
||||
sabilities.append(tokenParameters[i]);
|
||||
string tnum = tokenParameters[i];
|
||||
if(tnum.find("tnum:"))
|
||||
cID = cReplaceString(tnum,"tnum:","");
|
||||
else
|
||||
{
|
||||
sabilities.append(",");
|
||||
sabilities.append(tokenParameters[i]);
|
||||
}
|
||||
}
|
||||
int value = 0;
|
||||
if (spt.find("xx/xx") != string::npos)
|
||||
@@ -2441,7 +2447,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
|
||||
ATokenCreator * tok = NEW ATokenCreator(
|
||||
observer, id, card,target, NULL, sname, stypes, power + value, toughness + value,
|
||||
sabilities, starfound, multiplier, who, aLivingWeapon, spt);
|
||||
sabilities, starfound, multiplier, who, aLivingWeapon, spt, cID);
|
||||
tok->oneShot = 1;
|
||||
if(aLivingWeapon)
|
||||
tok->forceDestroy = 1;
|
||||
|
||||
Reference in New Issue
Block a user