diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 999478091..5cfe84047 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -3928,11 +3928,11 @@ public: bool newtoughnessfound; int oldtoughness; map > newAbilities; - vector newAbilitiesList; + vector newAbilitiesList; bool newAbilityFound; - ATransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound,vector newAbilitiesList,bool newAbilityFound = false); + ATransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound,vector newAbilitiesList,bool newAbilityFound = false); int addToGame(); int destroy(); const char * getMenuText(); @@ -3955,11 +3955,11 @@ public: bool newtoughnessfound; int oldtoughness; bool remove; - vector newAbilitiesList; + vector newAbilitiesList; map > newAbilities; bool newAbilityFound; - AForeverTransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities,string newpower = "",bool newpowerfound = false,string newtoughness = "",bool newtoughnessfound = false,vectornewAbilitiesList = vector(),bool newAbilityFound = false); + AForeverTransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities,string newpower = "",bool newpowerfound = false,string newtoughness = "",bool newtoughnessfound = false,vectornewAbilitiesList = vector(),bool newAbilityFound = false); int addToGame(); const char * getMenuText(); AForeverTransformer * clone() const; @@ -3975,11 +3975,11 @@ public: bool newpowerfound; string newtoughness; bool newtoughnessfound; - vector newAbilitiesList; + vector newAbilitiesList; map > newAbilities; bool newAbilityFound; - ATransformerUEOT(int id, MTGCardInstance * source, MTGCardInstance * target, string types = "", string abilities = "",string newpower = "",bool newpowerfound = false,string newtoughness = "",bool newtoughnessfound = false,vectornewAbilitiesList = vector(),bool newAbilityFound = false); + ATransformerUEOT(int id, MTGCardInstance * source, MTGCardInstance * target, string types = "", string abilities = "",string newpower = "",bool newpowerfound = false,string newtoughness = "",bool newtoughnessfound = false,vectornewAbilitiesList = vector(),bool newAbilityFound = false); int resolve(); const char * getMenuText(); ATransformerUEOT * clone() const; @@ -3995,11 +3995,11 @@ public: bool newpowerfound; string newtoughness; bool newtoughnessfound; - vector newAbilitiesList; + vector newAbilitiesList; map > newAbilities; bool newAbilityFound; - ATransformerFOREVER(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities,string newpower = "",bool newpowerfound = false,string newtoughness = "",bool newtoughnessfound = false,vectornewAbilitiesList = vector(),bool newAbilityFound = false); + ATransformerFOREVER(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities,string newpower = "",bool newpowerfound = false,string newtoughness = "",bool newtoughnessfound = false,vectornewAbilitiesList = vector(),bool newAbilityFound = false); int resolve(); const char * getMenuText(); ATransformerFOREVER * clone() const; diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 40d75e786..e84765410 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -2210,7 +2210,7 @@ AAlterCost::~AAlterCost() } // ATransformer -ATransformer::ATransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound,vector newAbilitiesList,bool newAbilityFound) : +ATransformer::ATransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound,vector newAbilitiesList,bool newAbilityFound) : MTGAbility(id, source, target),newpower(newpower),newpowerfound(newpowerfound),newtoughness(newtoughness),newtoughnessfound(newtoughnessfound),newAbilitiesList(newAbilitiesList),newAbilityFound(newAbilityFound) { @@ -2307,9 +2307,9 @@ ATransformer::ATransformer(int id, MTGCardInstance * source, MTGCardInstance * t { for (unsigned int k = 0 ; k < newAbilitiesList.size();k++) { - - MTGAbility * aNew = newAbilitiesList[k]->clone(); - + AbilityFactory af; + MTGAbility * aNew = af.parseMagicLine(newAbilitiesList[k],NULL, NULL, _target); + aNew->isClone = 1; GenericTargetAbility * gta = dynamic_cast (aNew); if (gta) { @@ -2329,7 +2329,13 @@ ATransformer::ATransformer(int id, MTGCardInstance * source, MTGCardInstance * t } aNew->target = _target; aNew->source = (MTGCardInstance *) _target; - aNew->addToGame(); + if(aNew->oneShot) + { + aNew->resolve(); + delete aNew; + } + else + aNew->addToGame(); newAbilities[_target].push_back(aNew); } } @@ -2426,18 +2432,11 @@ ATransformer * ATransformer::clone() const ATransformer::~ATransformer() { - if(!isClone) - { - for (unsigned int k = 0; k < newAbilitiesList.size();k++) - { - SAFE_DELETE(newAbilitiesList[k]); - } - } } // AForeverTransformer AForeverTransformer::AForeverTransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, - string sabilities,string newpower,bool newpowerfound, string newtoughness,bool newtoughnessfound,vector newAbilitiesList,bool newAbilityFound) : + string sabilities,string newpower,bool newpowerfound, string newtoughness,bool newtoughnessfound,vector newAbilitiesList,bool newAbilityFound) : MTGAbility(id, source, target),newpower(newpower),newpowerfound(newpowerfound),newtoughness(newtoughness),newtoughnessfound(newtoughnessfound),newAbilitiesList(newAbilitiesList),newAbilityFound(newAbilityFound) { aType = MTGAbility::STANDARD_BECOMES; @@ -2492,8 +2491,9 @@ int AForeverTransformer::addToGame() { for (unsigned int k = 0 ; k < newAbilitiesList.size();k++) { - - MTGAbility * aNew = newAbilitiesList[k]->clone(); + AbilityFactory af; + MTGAbility * aNew = af.parseMagicLine(newAbilitiesList[k],NULL, NULL, _target); + aNew->isClone = 1; GenericTargetAbility * gta = dynamic_cast (aNew); if (gta) @@ -2514,6 +2514,12 @@ int AForeverTransformer::addToGame() } aNew->target = _target; aNew->source = (MTGCardInstance *) _target; + if(aNew->oneShot) + { + aNew->resolve(); + delete aNew; + } + else aNew->addToGame(); newAbilities[_target].push_back(aNew); } @@ -2553,17 +2559,10 @@ AForeverTransformer * AForeverTransformer::clone() const } AForeverTransformer::~AForeverTransformer() { - if(!isClone) - { - for (unsigned int k = 0; k < newAbilitiesList.size();k++) - { - SAFE_DELETE(newAbilitiesList[k]); - } - } } //ATransformerUEOT -ATransformerUEOT::ATransformerUEOT(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound,vectornewAbilitiesList,bool newAbilityFound) : +ATransformerUEOT::ATransformerUEOT(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound,vectornewAbilitiesList,bool newAbilityFound) : InstantAbility(id, source, target),newpower(newpower),newpowerfound(newpowerfound),newtoughness(newtoughness),newtoughnessfound(newtoughnessfound),newAbilitiesList(newAbilitiesList),newAbilityFound(newAbilityFound) { ability = NEW ATransformer(id, source, target, types, abilities,newpower,newpowerfound,newtoughness,newtoughnessfound,newAbilitiesList,newAbilityFound); @@ -2596,7 +2595,7 @@ ATransformerUEOT::~ATransformerUEOT() } // ATransformerFOREVER -ATransformerFOREVER::ATransformerFOREVER(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound,vectornewAbilitiesList,bool newAbilityFound) : +ATransformerFOREVER::ATransformerFOREVER(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound,vectornewAbilitiesList,bool newAbilityFound) : InstantAbility(id, source, target),newpower(newpower),newpowerfound(newpowerfound),newtoughness(newtoughness),newtoughnessfound(newtoughnessfound),newAbilitiesList(newAbilitiesList),newAbilityFound(newAbilityFound) { ability = NEW AForeverTransformer(id, source, target, types, abilities,newpower,newpowerfound,newtoughness,newtoughnessfound,newAbilitiesList,newAbilityFound); diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 41a4813d9..a3ada6c41 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -2548,7 +2548,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG string newtoughness = ""; vector abilities = split(sabilities, ','); bool newAbilityFound = false; - vector newAbilitiesList; + vector newAbilitiesList; storedString.erase(); storedString.append(extraTransforms); extraTransforms.erase(); @@ -2571,7 +2571,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG newAbilityFound = true; size_t NewSkill = abilities[j].find("["); string newAbilities = abilities[j].substr(NewSkill + 1,abilities[j].find(']') - 1); - newAbilitiesList.push_back(parseMagicLine(newAbilities, id, spell, card)); + newAbilitiesList.push_back(newAbilities.c_str()); } } MTGAbility * a;