slight tweaks to transforms(

This commit is contained in:
omegablast2002@yahoo.com
2010-08-18 01:47:10 +00:00
parent 704a3018fa
commit af048ca230
2 changed files with 21 additions and 20 deletions
+13 -7
View File
@@ -220,10 +220,12 @@ class AACounter: public ActivatedAbility{
MTGCardInstance * _target = (MTGCardInstance *)target; MTGCardInstance * _target = (MTGCardInstance *)target;
if (nb>0){ if (nb>0){
for (int i=0; i < nb; i++){ for (int i=0; i < nb; i++){
while (_target->next) _target=_target->next;
_target->counters->addCounter(name.c_str(), power, toughness); _target->counters->addCounter(name.c_str(), power, toughness);
} }
}else{ }else{
for (int i=0; i < -nb; i++){ for (int i=0; i < -nb; i++){
while (_target->next) _target=_target->next;
_target->counters->removeCounter(name.c_str(), power, toughness); _target->counters->removeCounter(name.c_str(), power, toughness);
} }
} }
@@ -2476,7 +2478,6 @@ public:
_target->getManaCost()->add(type,amount); _target->getManaCost()->add(type,amount);
return MTGAbility::addToGame(); return MTGAbility::addToGame();
} }
AManaRedux * clone() const{ AManaRedux * clone() const{
AManaRedux * a = NEW AManaRedux(*this); AManaRedux * a = NEW AManaRedux(*this);
a->isClone = 1; a->isClone = 1;
@@ -2519,23 +2520,25 @@ public:
} }
int addToGame(){ int addToGame(){
MTGCardInstance * _target = (MTGCardInstance *)target; MTGCardInstance * _target = (MTGCardInstance *)target;
while (_target->next) _target=_target->next;
for (int j = 0; j < Constants::MTG_NB_COLORS; j++){ for (int j = 0; j < Constants::MTG_NB_COLORS; j++){
if (_target->hasColor(j)) if (_target->hasColor(j))
oldcolors.push_back(j); oldcolors.push_back(j);
_target->removeColor(j);
} }
list<int>::iterator it; list<int>::iterator it;
for ( it=types.begin() ; it != types.end(); it++ ){_target->addType(*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=oldcolors.begin() ; it != oldcolors.end(); it++ ){}
for ( it=abilities.begin() ; it != abilities.end(); it++ ){_target->basicAbilities[*it]++;} for ( it=abilities.begin() ; it != abilities.end(); it++ ){_target->basicAbilities[*it]++;}
for ( it=oldcolors.begin() ; it != oldcolors.end(); it++ ){}
return MTGAbility::addToGame();} return MTGAbility::addToGame();}
int destroy(){ int destroy(){
MTGCardInstance * _target = (MTGCardInstance *)target; MTGCardInstance * _target = (MTGCardInstance *)target;
list<int>::iterator it; list<int>::iterator it;
for ( it=types.begin() ; it != types.end(); it++ ){_target->removeType(*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=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=abilities.begin() ; it != abilities.end(); it++ ){_target->basicAbilities[*it]--;}
for ( it=oldcolors.begin() ; it != oldcolors.end(); it++ ){_target->setColor(*it);}
return 1;} return 1;}
ATransformer * clone() const{ ATransformer * clone() const{
ATransformer * a = NEW ATransformer(*this); ATransformer * a = NEW ATransformer(*this);
@@ -2569,7 +2572,6 @@ public:
list<int>types; list<int>types;
list<int>colors; list<int>colors;
ATransformerFOREVER(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities):MTGAbility(id,source,target){ 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++){ for (int j = 0; j < Constants::NB_BASIC_ABILITIES; j++){
size_t found = sabilities.find(Constants::MTGBasicAbilities[j]); size_t found = sabilities.find(Constants::MTGBasicAbilities[j]);
if (found != string::npos){ if (found != string::npos){
@@ -2593,11 +2595,15 @@ public:
s = "";} s = "";}
} }
} }
int addToGame(){ int addToGame(){
MTGCardInstance * _target = (MTGCardInstance *)target; MTGCardInstance * _target = (MTGCardInstance *)target;
for (int j = 0; j < Constants::MTG_NB_COLORS; j++){
if (_target->hasColor(j))
_target->removeColor(j);
}
list<int>::iterator it; list<int>::iterator it;
for ( it=types.begin() ; it != types.end(); it++ ){_target->addType(*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]++;} for ( it=abilities.begin() ; it != abilities.end(); it++ ){_target->basicAbilities[*it]++;}
return MTGAbility::addToGame();} return MTGAbility::addToGame();}
ATransformerFOREVER * clone() const{ ATransformerFOREVER * clone() const{
+8 -13
View File
@@ -1044,26 +1044,21 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
string sabilities; string sabilities;
if (end != real_end){ if (end != real_end){
int previous = end+1; int previous = end+1;
end = s.find(",",previous);
if (end == string::npos) end = real_end; if (end == string::npos) end = real_end;
string temp = s.substr(previous, end - previous); string temp = s.substr(previous, end - previous);
if (end == real_end){
sabilities = temp;
}
} }
if (end != real_end){ if (end != real_end){
sabilities = s.substr(end+1, real_end - 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 //Change Power/Toughness
WParsedPT * wppt = NEW WParsedPT(s,spell,card); WParsedPT * wppt = NEW WParsedPT(s,spell,card);
if (wppt->ok){ if (wppt->ok){