Fix for token cloning
Some tokens when cloned produces miscalculated PT(Using foreach, aslongas and others that needs CDA). This should fix the issue. TODO: add tests and updated mtg.txt ...
This commit is contained in:
@@ -2320,6 +2320,16 @@ public:
|
|||||||
aType = MTGAbility::STANDARD_PUMP;
|
aType = MTGAbility::STANDARD_PUMP;
|
||||||
cda = PT.find("cdaactive") != string::npos;
|
cda = PT.find("cdaactive") != string::npos;
|
||||||
}
|
}
|
||||||
|
string ReplaceString(string subject, const string& search, const string& replace)
|
||||||
|
{
|
||||||
|
size_t pos = 0;
|
||||||
|
while ((pos = subject.find(search, pos)) != string::npos)
|
||||||
|
{
|
||||||
|
subject.replace(pos, search.length(), replace);
|
||||||
|
pos += replace.length();
|
||||||
|
}
|
||||||
|
return subject;
|
||||||
|
}
|
||||||
void Update(float)
|
void Update(float)
|
||||||
{
|
{
|
||||||
if(!nonstatic)
|
if(!nonstatic)
|
||||||
@@ -2331,7 +2341,10 @@ public:
|
|||||||
if(PT.size())
|
if(PT.size())
|
||||||
{
|
{
|
||||||
SAFE_DELETE(wppt);
|
SAFE_DELETE(wppt);
|
||||||
wppt = NEW WParsedPT(PT,NULL,(MTGCardInstance *) source);
|
if(cda)
|
||||||
|
wppt = NEW WParsedPT(ReplaceString(PT, "cdaactive", ""),NULL,(MTGCardInstance *) source);
|
||||||
|
else
|
||||||
|
wppt = NEW WParsedPT(ReplaceString(PT, "nonstatic", ""),NULL,(MTGCardInstance *) source);
|
||||||
}
|
}
|
||||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||||
_target->power += wppt->power.getValue();
|
_target->power += wppt->power.getValue();
|
||||||
@@ -2342,7 +2355,10 @@ public:
|
|||||||
if(PT.size())
|
if(PT.size())
|
||||||
{
|
{
|
||||||
SAFE_DELETE(wppt);
|
SAFE_DELETE(wppt);
|
||||||
wppt = NEW WParsedPT(PT,NULL,(MTGCardInstance *) source);
|
if(cda)
|
||||||
|
wppt = NEW WParsedPT(ReplaceString(PT, "cdaactive", ""),NULL,(MTGCardInstance *) source);
|
||||||
|
else
|
||||||
|
wppt = NEW WParsedPT(ReplaceString(PT, "nonstatic", ""),NULL,(MTGCardInstance *) source);
|
||||||
}
|
}
|
||||||
((MTGCardInstance *) target)->origpower = wppt->power.getValue();
|
((MTGCardInstance *) target)->origpower = wppt->power.getValue();
|
||||||
((MTGCardInstance *) target)->origtoughness = (wppt->toughness.getValue() + ((MTGCardInstance *) target)->life)-((MTGCardInstance *) target)->life;//what?
|
((MTGCardInstance *) target)->origtoughness = (wppt->toughness.getValue() + ((MTGCardInstance *) target)->life)-((MTGCardInstance *) target)->life;//what?
|
||||||
@@ -2354,7 +2370,10 @@ public:
|
|||||||
if(PT.size())
|
if(PT.size())
|
||||||
{
|
{
|
||||||
SAFE_DELETE(wppt);
|
SAFE_DELETE(wppt);
|
||||||
wppt = NEW WParsedPT(PT,NULL,(MTGCardInstance *) source);
|
if(cda)
|
||||||
|
wppt = NEW WParsedPT(ReplaceString(PT, "cdaactive", ""),NULL,(MTGCardInstance *) source);
|
||||||
|
else
|
||||||
|
wppt = NEW WParsedPT(ReplaceString(PT, "nonstatic", ""),NULL,(MTGCardInstance *) source);
|
||||||
}
|
}
|
||||||
if(cda)
|
if(cda)
|
||||||
{//Characteristic-defining abilities
|
{//Characteristic-defining abilities
|
||||||
@@ -2402,7 +2421,10 @@ public:
|
|||||||
if(PT.size())
|
if(PT.size())
|
||||||
{
|
{
|
||||||
SAFE_DELETE(wppt);
|
SAFE_DELETE(wppt);
|
||||||
wppt = NEW WParsedPT(PT,NULL,(MTGCardInstance *) source);
|
if(cda)
|
||||||
|
wppt = NEW WParsedPT(ReplaceString(PT, "cdaactive", ""),NULL,(MTGCardInstance *) source);
|
||||||
|
else
|
||||||
|
wppt = NEW WParsedPT(ReplaceString(PT, "nonstatic", ""),NULL,(MTGCardInstance *) source);
|
||||||
}
|
}
|
||||||
sprintf(menuText, "%i/%i", wppt->power.getValue(), wppt->toughness.getValue());
|
sprintf(menuText, "%i/%i", wppt->power.getValue(), wppt->toughness.getValue());
|
||||||
return menuText;
|
return menuText;
|
||||||
|
|||||||
@@ -2536,12 +2536,13 @@ int AACloner::resolve()
|
|||||||
spell->source->fresh = 1;
|
spell->source->fresh = 1;
|
||||||
spell->source->model = spell->source;
|
spell->source->model = spell->source;
|
||||||
spell->source->model->data = spell->source;
|
spell->source->model->data = spell->source;
|
||||||
if(_target->isToken)
|
//commenting this out fixes some problems when duplicating tokens 9/16/2015
|
||||||
|
/*if(_target->isToken)
|
||||||
{
|
{
|
||||||
spell->source->power = _target->origpower;
|
spell->source->power = _target->origpower;
|
||||||
spell->source->toughness = _target->origtoughness;
|
spell->source->toughness = _target->origtoughness;
|
||||||
spell->source->life = _target->origtoughness;
|
spell->source->life = _target->origtoughness;
|
||||||
}
|
}*/
|
||||||
list<int>::iterator it;
|
list<int>::iterator it;
|
||||||
for (it = awith.begin(); it != awith.end(); it++)
|
for (it = awith.begin(); it != awith.end(); it++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ Token::Token(string _name, MTGCardInstance * source, int _power, int _toughness)
|
|||||||
lifeOrig = life;
|
lifeOrig = life;
|
||||||
origpower = _power;
|
origpower = _power;
|
||||||
origtoughness = _toughness;
|
origtoughness = _toughness;
|
||||||
|
basepower = power;
|
||||||
|
basetoughness = toughness;
|
||||||
rarity = Constants::RARITY_T;
|
rarity = Constants::RARITY_T;
|
||||||
name = _name;
|
name = _name;
|
||||||
if (name.size() && name[0] >= 97 && name[0] <= 122) name[0] -= 32; //Poor man's camelcase. We assume strings we get are either Camelcased or lowercase
|
if (name.size() && name[0] >= 97 && name[0] <= 122) name[0] -= 32; //Poor man's camelcase. We assume strings we get are either Camelcased or lowercase
|
||||||
@@ -25,6 +27,9 @@ Token::Token(string _name, MTGCardInstance * source, int _power, int _toughness)
|
|||||||
attacker = 0;
|
attacker = 0;
|
||||||
defenser = NULL;
|
defenser = NULL;
|
||||||
banding = NULL;
|
banding = NULL;
|
||||||
|
pbonus = 0;
|
||||||
|
tbonus = 0;
|
||||||
|
isSettingBase = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Token(int id) :
|
Token::Token(int id) :
|
||||||
@@ -45,7 +50,11 @@ Token::Token(const Token& source) :
|
|||||||
life = source.life;
|
life = source.life;
|
||||||
lifeOrig = source.life;
|
lifeOrig = source.life;
|
||||||
origpower = source.origpower;
|
origpower = source.origpower;
|
||||||
origtoughness = source.origpower;
|
origtoughness = source.origtoughness;
|
||||||
|
basepower = source.origpower;
|
||||||
|
basetoughness = source.origpower;
|
||||||
|
pbonus = source.pbonus;
|
||||||
|
tbonus = source.tbonus;
|
||||||
rarity = source.rarity;
|
rarity = source.rarity;
|
||||||
name = source.name;
|
name = source.name;
|
||||||
setId = source.setId;
|
setId = source.setId;
|
||||||
@@ -56,6 +65,7 @@ Token::Token(const Token& source) :
|
|||||||
attacker = source.attacker;
|
attacker = source.attacker;
|
||||||
defenser = source.defenser;
|
defenser = source.defenser;
|
||||||
banding = source.banding;
|
banding = source.banding;
|
||||||
|
isSettingBase = source.isSettingBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user