diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index a4cddbe02..224b1f367 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -220,10 +220,12 @@ class AACounter: public ActivatedAbility{ MTGCardInstance * _target = (MTGCardInstance *)target; if (nb>0){ for (int i=0; i < nb; i++){ + while (_target->next) _target=_target->next; _target->counters->addCounter(name.c_str(), power, toughness); } }else{ for (int i=0; i < -nb; i++){ + while (_target->next) _target=_target->next; _target->counters->removeCounter(name.c_str(), power, toughness); } } @@ -2476,7 +2478,6 @@ public: _target->getManaCost()->add(type,amount); return MTGAbility::addToGame(); } - AManaRedux * clone() const{ AManaRedux * a = NEW AManaRedux(*this); a->isClone = 1; @@ -2519,23 +2520,25 @@ public: } int addToGame(){ MTGCardInstance * _target = (MTGCardInstance *)target; + while (_target->next) _target=_target->next; for (int j = 0; j < Constants::MTG_NB_COLORS; j++){ if (_target->hasColor(j)) oldcolors.push_back(j); + _target->removeColor(j); } list::iterator it; for ( it=types.begin() ; it != types.end(); it++ ){_target->addType(*it);} - for ( it=colors.begin() ; it != colors.end(); it++ ){_target->setColor(*it,1);} - for ( it=oldcolors.begin() ; it != oldcolors.end(); it++ ){} + for ( it=colors.begin() ; it != colors.end(); it++ ){_target->setColor(*it);} for ( it=abilities.begin() ; it != abilities.end(); it++ ){_target->basicAbilities[*it]++;} + for ( it=oldcolors.begin() ; it != oldcolors.end(); it++ ){} return MTGAbility::addToGame();} int destroy(){ MTGCardInstance * _target = (MTGCardInstance *)target; list::iterator it; for ( it=types.begin() ; it != types.end(); it++ ){_target->removeType(*it);} for ( it=colors.begin() ; it != colors.end(); it++ ){_target->removeColor(*it);} - for ( it=oldcolors.begin() ; it != oldcolors.end(); it++ ){_target->setColor(*it);} for ( it=abilities.begin() ; it != abilities.end(); it++ ){_target->basicAbilities[*it]--;} + for ( it=oldcolors.begin() ; it != oldcolors.end(); it++ ){_target->setColor(*it);} return 1;} ATransformer * clone() const{ ATransformer * a = NEW ATransformer(*this); @@ -2569,7 +2572,6 @@ public: listtypes; listcolors; ATransformerFOREVER(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities):MTGAbility(id,source,target){ - //TODO this is a copy/past of other code that's all around the place, everything should be in a dedicated parser class; for (int j = 0; j < Constants::NB_BASIC_ABILITIES; j++){ size_t found = sabilities.find(Constants::MTGBasicAbilities[j]); if (found != string::npos){ @@ -2593,11 +2595,15 @@ public: s = "";} } } - int addToGame(){ + int addToGame(){ MTGCardInstance * _target = (MTGCardInstance *)target; + for (int j = 0; j < Constants::MTG_NB_COLORS; j++){ + if (_target->hasColor(j)) + _target->removeColor(j); + } list::iterator it; for ( it=types.begin() ; it != types.end(); it++ ){_target->addType(*it);} - for ( it=colors.begin() ; it != colors.end(); it++ ){_target->setColor(*it,1);} + for ( it=colors.begin() ; it != colors.end(); it++ ){_target->setColor(*it);} for ( it=abilities.begin() ; it != abilities.end(); it++ ){_target->basicAbilities[*it]++;} return MTGAbility::addToGame();} ATransformerFOREVER * clone() const{ diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index e7cff0f7f..8f994df14 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -1044,26 +1044,21 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG string sabilities; if (end != real_end){ int previous = end+1; - end = s.find(",",previous); if (end == string::npos) end = real_end; string temp = s.substr(previous, end - previous); - if (end == real_end){ - sabilities = temp; - } } if (end != real_end){ sabilities = s.substr(end+1, real_end - end); - } - MTGAbility * ab; - if (forceUEOT){ - ab = NEW ATransformerUEOT(id,card,target,stypes,sabilities); - }else{ - ab = NEW ATransformer(id,card,target,stypes,sabilities); - }if(forceFOREVER){ab = NEW ATransformerFOREVER(id,card,target,stypes,sabilities); } - return ab; + MTGAbility * a; + if (forceUEOT){ + a = NEW ATransformerUEOT(id,card,target,stypes,sabilities); + }else{ + a = NEW ATransformer(id,card,target,stypes,sabilities); + }if(forceFOREVER){a = NEW ATransformerFOREVER(id,card,target,stypes,sabilities); + } + return a; } - //Change Power/Toughness WParsedPT * wppt = NEW WParsedPT(s,spell,card); if (wppt->ok){