diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index b7afe6702..40d75e786 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -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 (aNew); + if (gta) + { + ((GenericTargetAbility *)aNew)->source = _target; + ((GenericTargetAbility *)aNew)->ability->source = _target; + } + GenericActivatedAbility * gaa = dynamic_cast (aNew); + if (gaa) + { + ((GenericActivatedAbility *)aNew)->source = _target; + ((GenericActivatedAbility *)aNew)->ability->source = _target; + } + if (MultiAbility * abi = dynamic_cast(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 (aNew); + if (gta) + { + ((GenericTargetAbility *)aNew)->source = _target; + ((GenericTargetAbility *)aNew)->ability->source = _target; + } + GenericActivatedAbility * gaa = dynamic_cast (aNew); + if (gaa) + { + ((GenericActivatedAbility *)aNew)->source = _target; + ((GenericActivatedAbility *)aNew)->ability->source = _target; + } + if (MultiAbility * abi = dynamic_cast(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 ) { diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index d38796db6..75928e28e 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -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 effectParameters = split( transformsParamsString, ','); string stypes = effectParameters[0]; @@ -2535,7 +2549,9 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG vector abilities = split(sabilities, ','); bool newAbilityFound = false; vector 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) { diff --git a/projects/mtg/src/MTGGameZones.cpp b/projects/mtg/src/MTGGameZones.cpp index 3411948c3..17ee9b0dd 100644 --- a/projects/mtg/src/MTGGameZones.cpp +++ b/projects/mtg/src/MTGGameZones.cpp @@ -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) diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index a515631a7..0224bf160 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -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; }