modified transforms( ability. mods in first comment.
This commit is contained in:
@@ -2490,22 +2490,20 @@ public:
|
||||
list<int>abilities;
|
||||
list<int>types;
|
||||
list<int>colors;
|
||||
list<int>oldcolors;
|
||||
ATransformer(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++){
|
||||
MTGCardInstance * _target = (MTGCardInstance *)target;
|
||||
for (int j = 0; j < Constants::NB_BASIC_ABILITIES; j++){
|
||||
size_t found = sabilities.find(Constants::MTGBasicAbilities[j]);
|
||||
if (found != string::npos){
|
||||
abilities.push_back(j);
|
||||
}
|
||||
abilities.push_back(j);}
|
||||
}
|
||||
for (int j = 0; j < Constants::MTG_NB_COLORS; j++){
|
||||
size_t found = sabilities.find(Constants::MTGColorStrings[j]);
|
||||
if (found != string::npos){
|
||||
colors.push_back(j);
|
||||
}
|
||||
colors.push_back(j);}
|
||||
}
|
||||
|
||||
string s = stypes;
|
||||
while (s.size()){
|
||||
size_t found = s.find(" ");
|
||||
@@ -2516,49 +2514,97 @@ public:
|
||||
}else{
|
||||
int id = Subtypes::subtypesList->find(s);
|
||||
types.push_back(id);
|
||||
s = "";
|
||||
}
|
||||
}
|
||||
s = "";}
|
||||
}
|
||||
}
|
||||
|
||||
int addToGame(){
|
||||
MTGCardInstance * _target = (MTGCardInstance *)target;
|
||||
list<int>::iterator it;
|
||||
for ( it=types.begin() ; it != types.end(); it++ ){
|
||||
_target->addType(*it);
|
||||
}
|
||||
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();
|
||||
}
|
||||
for (int j = 0; j < Constants::MTG_NB_COLORS; j++){
|
||||
if (_target->hasColor(j))
|
||||
oldcolors.push_back(j);
|
||||
}
|
||||
list<int>::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=abilities.begin() ; it != abilities.end(); it++ ){_target->basicAbilities[*it]++;}
|
||||
return MTGAbility::addToGame();}
|
||||
int destroy(){
|
||||
MTGCardInstance * _target = (MTGCardInstance *)target;
|
||||
list<int>::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=abilities.begin() ; it != abilities.end(); it++ ){
|
||||
_target->basicAbilities[*it]--;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
ATransformer * clone() const{
|
||||
list<int>::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]--;}
|
||||
return 1;}
|
||||
ATransformer * clone() const{
|
||||
ATransformer * a = NEW ATransformer(*this);
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
return a;}
|
||||
~ATransformer(){}
|
||||
};
|
||||
//Adds types/abilities/P/T to a card (until end of turn)
|
||||
class ATransformerUEOT: public InstantAbility{
|
||||
public:
|
||||
ATransformer * ability;
|
||||
ATransformerUEOT(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities):InstantAbility(id,source,target){
|
||||
ability = NEW ATransformer(id,source,target,types,abilities);}
|
||||
int resolve(){
|
||||
ATransformer * a = ability->clone();
|
||||
GenericInstantAbility * wrapper = NEW GenericInstantAbility(1,source,(Damageable *)(this->target),a);
|
||||
wrapper->addToGame();
|
||||
return 1;}
|
||||
ATransformerUEOT * clone() const{
|
||||
ATransformerUEOT * a = NEW ATransformerUEOT(*this);
|
||||
a->ability = this->ability->clone();
|
||||
a->isClone = 1;
|
||||
return a;}
|
||||
~ATransformerUEOT(){
|
||||
delete ability;
|
||||
}};
|
||||
//transforms forever
|
||||
class ATransformerFOREVER:public MTGAbility{
|
||||
public:
|
||||
list<int>abilities;
|
||||
list<int>types;
|
||||
list<int>colors;
|
||||
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){
|
||||
abilities.push_back(j);}
|
||||
}
|
||||
for (int j = 0; j < Constants::MTG_NB_COLORS; j++){
|
||||
size_t found = sabilities.find(Constants::MTGColorStrings[j]);
|
||||
if (found != string::npos){
|
||||
colors.push_back(j);}
|
||||
}
|
||||
string s = stypes;
|
||||
while (s.size()){
|
||||
size_t found = s.find(" ");
|
||||
if (found != string::npos){
|
||||
int id = Subtypes::subtypesList->find(s.substr(0,found));
|
||||
types.push_back(id);
|
||||
s = s.substr(found+1);
|
||||
}else{
|
||||
int id = Subtypes::subtypesList->find(s);
|
||||
types.push_back(id);
|
||||
s = "";}
|
||||
}
|
||||
}
|
||||
|
||||
~ATransformer(){
|
||||
}
|
||||
|
||||
int addToGame(){
|
||||
MTGCardInstance * _target = (MTGCardInstance *)target;
|
||||
list<int>::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=abilities.begin() ; it != abilities.end(); it++ ){_target->basicAbilities[*it]++;}
|
||||
return MTGAbility::addToGame();}
|
||||
ATransformerFOREVER * clone() const{
|
||||
ATransformerFOREVER * a = NEW ATransformerFOREVER(*this);
|
||||
a->isClone = 1;
|
||||
return a;}
|
||||
~ATransformerFOREVER(){}
|
||||
};
|
||||
//Adds types/abilities/P/T to a card (aura)
|
||||
class ABecomes:public MTGAbility{
|
||||
|
||||
@@ -265,7 +265,7 @@ class AbilityFactory{
|
||||
Counter * parseCounter(string s, MTGCardInstance * target, Spell * spell = NULL);
|
||||
int parsePowerToughness(string s, int *power, int *toughness);
|
||||
int getAbilities(vector<MTGAbility *> * v, Spell * spell, MTGCardInstance * card = NULL, int id = 0,MTGGameZone * dest = NULL);
|
||||
MTGAbility * parseMagicLine(string s, int id, Spell * spell, MTGCardInstance *card, int activated = 0, int forceUEOT = 0,int oneShot = 0, MTGGameZone * dest = NULL);
|
||||
MTGAbility * parseMagicLine(string s, int id, Spell * spell, MTGCardInstance *card, int activated = 0, int forceUEOT = 0,int oneShot = 0,int forceForever = 0, MTGGameZone * dest = NULL);
|
||||
int abilityEfficiency(MTGAbility * a, Player * p, int mode = MODE_ABILITY, TargetChooser * tc = NULL);
|
||||
int magicText(int id, Spell * spell, MTGCardInstance * card = NULL, int mode = MODE_PUTINTOPLAY, TargetChooser * tc = NULL, MTGGameZone * dest = NULL);
|
||||
static int computeX(Spell * spell, MTGCardInstance * card);
|
||||
|
||||
@@ -226,7 +226,7 @@ MTGAbility * AbilityFactory::getCoreAbility(MTGAbility * a){
|
||||
//Parses a string and returns the corresponding MTGAbility object
|
||||
//Returns NULL if parsing failed
|
||||
//Beware, Spell CAN be null when the function is called by the AI trying to analyze the effects of a given card
|
||||
MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTGCardInstance *card, int activated, int forceUEOT, int oneShot, MTGGameZone * dest){
|
||||
MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTGCardInstance *card, int activated, int forceUEOT, int oneShot,int forceFOREVER, MTGGameZone * dest){
|
||||
size_t found;
|
||||
|
||||
string whitespaces (" \t\f\v\n\r");
|
||||
@@ -722,6 +722,8 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
if (found!= string::npos) forceUEOT = 1;
|
||||
found = s.find("oneshot");
|
||||
if (found!= string::npos) oneShot = 1;
|
||||
found = s.find("forever");
|
||||
if (found!= string::npos) forceFOREVER = 1;
|
||||
|
||||
//PreventCombat Damage
|
||||
found = s.find("preventallcombatdamage");
|
||||
@@ -939,10 +941,6 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//Becomes... (animate artifact...: becomes(Creature, manacost/manacost)
|
||||
found = s.find("becomes(");
|
||||
if (found != string::npos){
|
||||
@@ -983,9 +981,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
if (end != string::npos){amount = atoi(s.substr(start+1,end-start-1).c_str());}
|
||||
else{amount = atoi(s.substr(start+1).c_str());}
|
||||
MTGAbility * a = NEW AManaRedux(id,card,target,amount,0);
|
||||
return a;
|
||||
}
|
||||
//ManaRedux
|
||||
return a;}
|
||||
found = s.find("green:");
|
||||
if (found != string::npos){
|
||||
size_t start = s.find(":",found);
|
||||
@@ -994,9 +990,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
if (end != string::npos){amount = atoi(s.substr(start+1,end-start-1).c_str());}
|
||||
else{amount = atoi(s.substr(start+1).c_str());}
|
||||
MTGAbility * a = NEW AManaRedux(id,card,target,amount,1);
|
||||
return a;
|
||||
}
|
||||
//ManaRedux
|
||||
return a;}
|
||||
found = s.find("blue:");
|
||||
if (found != string::npos){
|
||||
size_t start = s.find(":",found);
|
||||
@@ -1005,9 +999,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
if (end != string::npos){amount = atoi(s.substr(start+1,end-start-1).c_str());}
|
||||
else{amount = atoi(s.substr(start+1).c_str());}
|
||||
MTGAbility * a = NEW AManaRedux(id,card,target,amount,2);
|
||||
return a;
|
||||
}
|
||||
//ManaRedux
|
||||
return a;}
|
||||
found = s.find("red:");
|
||||
if (found != string::npos){
|
||||
size_t start = s.find(":",found);
|
||||
@@ -1016,9 +1008,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
if (end != string::npos){amount = atoi(s.substr(start+1,end-start-1).c_str());}
|
||||
else{amount = atoi(s.substr(start+1).c_str());}
|
||||
MTGAbility * a = NEW AManaRedux(id,card,target,amount,3);
|
||||
return a;
|
||||
}
|
||||
//ManaRedux
|
||||
return a;}
|
||||
found = s.find("black:");
|
||||
if (found != string::npos){
|
||||
size_t start = s.find(":",found);
|
||||
@@ -1027,9 +1017,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
if (end != string::npos){amount = atoi(s.substr(start+1,end-start-1).c_str());}
|
||||
else{amount = atoi(s.substr(start+1).c_str());}
|
||||
MTGAbility * a = NEW AManaRedux(id,card,target,amount,4);
|
||||
return a;
|
||||
}
|
||||
//ManaRedux
|
||||
return a;}
|
||||
found = s.find("white:");
|
||||
if (found != string::npos){
|
||||
size_t start = s.find(":",found);
|
||||
@@ -1040,23 +1028,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
MTGAbility * a = NEW AManaRedux(id,card,target,amount,5);
|
||||
return a;
|
||||
}
|
||||
|
||||
//resetcost
|
||||
//resetcost dirty code
|
||||
found = s.find("resetcost");
|
||||
if (found != string::npos){
|
||||
MTGAbility * a = NEW AResetCost(id,card,target);
|
||||
return a;}
|
||||
////one less mana
|
||||
// found = s.find("oneless");
|
||||
// if (found != string::npos){
|
||||
//MTGAbility * a = NEW AOneless(id,card,target);
|
||||
// return a;}
|
||||
////more more mana
|
||||
// found = s.find("onemore");
|
||||
// if (found != string::npos){
|
||||
//MTGAbility * a = NEW AOnemore(id,card,target);
|
||||
// return a;}
|
||||
|
||||
return a;
|
||||
}
|
||||
//transform....(hivestone,living enchantment)
|
||||
found = s.find("transforms(");
|
||||
if (found != string::npos){
|
||||
@@ -1079,10 +1056,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
}
|
||||
MTGAbility * ab;
|
||||
if (forceUEOT){
|
||||
ab = NEW ATransformer(id,card,target,stypes,sabilities);
|
||||
ab = NEW ATransformerUEOT(id,card,target,stypes,sabilities);
|
||||
}else{
|
||||
ab = NEW ATransformer(id,card,target,stypes,sabilities);
|
||||
}return ab;
|
||||
}if(forceFOREVER){ab = NEW ATransformerFOREVER(id,card,target,stypes,sabilities);
|
||||
}
|
||||
return ab;
|
||||
}
|
||||
|
||||
//Change Power/Toughness
|
||||
@@ -1325,7 +1304,7 @@ int AbilityFactory::getAbilities(vector<MTGAbility *> * v, Spell * spell, MTGCar
|
||||
magicText = "";
|
||||
}
|
||||
|
||||
MTGAbility * a = parseMagicLine(line, result, spell, card,0,0,0,dest);
|
||||
MTGAbility * a = parseMagicLine(line, result, spell, card,0,0,0,0,dest);
|
||||
if (a){
|
||||
v->push_back(a);
|
||||
result++;
|
||||
|
||||
Reference in New Issue
Block a user