slight adjustments to transforms parsing to allow for newability to also be a transforms. xx wasnt being set in a couple cases, removed the space i added to the 3 variables so they can be anywhere in the line.

This commit is contained in:
omegablast2002@yahoo.com
2011-03-30 17:45:05 +00:00
parent 8557e441b0
commit cba0c1218f
4 changed files with 70 additions and 16 deletions

View File

@@ -2307,7 +2307,26 @@ ATransformer::ATransformer(int id, MTGCardInstance * source, MTGCardInstance * t
{
for (unsigned int k = 0 ; k < newAbilitiesList.size();k++)
{
MTGAbility * aNew = newAbilitiesList[k]->clone();
GenericTargetAbility * gta = dynamic_cast<GenericTargetAbility*> (aNew);
if (gta)
{
((GenericTargetAbility *)aNew)->source = _target;
((GenericTargetAbility *)aNew)->ability->source = _target;
}
GenericActivatedAbility * gaa = dynamic_cast<GenericActivatedAbility*> (aNew);
if (gaa)
{
((GenericActivatedAbility *)aNew)->source = _target;
((GenericActivatedAbility *)aNew)->ability->source = _target;
}
if (MultiAbility * abi = dynamic_cast<MultiAbility*>(aNew))
{
((MultiAbility *)aNew)->source = _target;
((MultiAbility *)aNew)->abilities[0]->source = _target;
}
aNew->target = _target;
aNew->source = (MTGCardInstance *) _target;
aNew->addToGame();
@@ -2471,14 +2490,33 @@ int AForeverTransformer::addToGame()
}
if(newAbilityFound)
{
for (unsigned int k = 0 ; k < newAbilitiesList.size();k++)
{
MTGAbility * aNew = newAbilitiesList[k]->clone();
aNew->target = _target;
aNew->source = (MTGCardInstance *) _target;
aNew->addToGame();
newAbilities[_target].push_back(aNew);
}
for (unsigned int k = 0 ; k < newAbilitiesList.size();k++)
{
MTGAbility * aNew = newAbilitiesList[k]->clone();
GenericTargetAbility * gta = dynamic_cast<GenericTargetAbility*> (aNew);
if (gta)
{
((GenericTargetAbility *)aNew)->source = _target;
((GenericTargetAbility *)aNew)->ability->source = _target;
}
GenericActivatedAbility * gaa = dynamic_cast<GenericActivatedAbility*> (aNew);
if (gaa)
{
((GenericActivatedAbility *)aNew)->source = _target;
((GenericActivatedAbility *)aNew)->ability->source = _target;
}
if (MultiAbility * abi = dynamic_cast<MultiAbility*>(aNew))
{
((MultiAbility *)aNew)->source = _target;
((MultiAbility *)aNew)->abilities[0]->source = _target;
}
aNew->target = _target;
aNew->source = (MTGCardInstance *) _target;
aNew->addToGame();
newAbilities[_target].push_back(aNew);
}
}
if(newpowerfound )
{

View File

@@ -1946,13 +1946,13 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
if (s.find(" owner") != string::npos)
who = TargetChooser::OWNER;
found = s.find(" ueot");
found = s.find("ueot");
if (found != string::npos)
forceUEOT = 1;
found = s.find(" oneshot");
found = s.find("oneshot");
if (found != string::npos)
oneShot = 1;
found = s.find(" forever");
found = s.find("forever");
if (found != string::npos)
forceFOREVER = 1;
@@ -2522,8 +2522,22 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
found = s.find("transforms((");
if (found != string::npos)
{
string extraTransforms = "";
size_t stypesStartIndex = found + 12;
string transformsParamsString = storedString;//the string between found and real end is removed at start.
string transformsParamsString = "";
transformsParamsString.append(storedString);//the string between found and real end is removed at start.
found = transformsParamsString.find("transforms((");
if (found != string::npos && extraTransforms.empty())
{
size_t real_end = transformsParamsString.find("))", found);
size_t end = transformsParamsString.find(",", found);
if (end == string::npos)
end = real_end;
size_t stypesStartIndex = found + 12;
extraTransforms.append(transformsParamsString.substr(stypesStartIndex, real_end - stypesStartIndex).c_str());
transformsParamsString.erase(stypesStartIndex, real_end - stypesStartIndex);
}
vector<string> effectParameters = split( transformsParamsString, ',');
string stypes = effectParameters[0];
@@ -2535,7 +2549,9 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
vector <string> abilities = split(sabilities, ',');
bool newAbilityFound = false;
vector<MTGAbility *> newAbilitiesList;
storedString.erase();
storedString.append(extraTransforms);
extraTransforms.erase();
for(unsigned int j = 0;j < abilities.size();j++)
{
if(abilities[j].find("setpower=") != string::npos)
@@ -2558,7 +2574,6 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
newAbilitiesList.push_back(parseMagicLine(newAbilities, id, spell, card));
}
}
storedString.erase();
MTGAbility * a;
if (forceFOREVER)
{

View File

@@ -449,6 +449,7 @@ MTGCardInstance * MTGGameZone::removeCard(MTGCardInstance * card, int createCopy
copy->view = card->view;
copy->isToken = card->isToken;
copy->X = card->X;
copy->XX = card->X/2;
//stupid bug with tokens...
if (card->model == card)

View File

@@ -325,7 +325,7 @@ int MTGAlternativeCostRule::reactToClick(MTGCardInstance * card, ManaCost *alter
else
{
copy->X = spell->computeX(copy);
copy->XX = spell->computeXX(copy);
copy->XX = copy->X/2;
}
}
@@ -723,7 +723,7 @@ int MTGMorphCostRule::reactToClick(MTGCardInstance * card)
if (!card->has(Constants::STORM))
{
copy->X = spell->computeX(copy);
copy->XX = spell->computeXX(copy);
copy->XX = copy->X/2;
}
return 1;
}