corrected Prismatic omen issue,

added newability[whatever ability] to transforms classes.
this allows for transforms to also add activated or mtgabilities to cards it targets.
example Prismatic omen:
auto=lord(land|myBattlefield) transforms(plains forest mountain swamp island,newability[{t}:add{w}],newability[{t}:add{g}],newability[{t}:add{r}],newability[{t}:add{b}],newability[{t}:add{u}])
Issue: 573
This commit is contained in:
omegablast2002@yahoo.com
2011-03-28 23:39:29 +00:00
parent b600b8c41a
commit c03a444525
3 changed files with 148 additions and 79 deletions

View File

@@ -3909,9 +3909,12 @@ public:
string newtoughness;
bool newtoughnessfound;
int oldtoughness;
map<Damageable *, vector<MTGAbility *>> newAbilities;
vector<MTGAbility *> newAbilitiesList;
bool newAbilityFound;
ATransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound);
ATransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound,vector<MTGAbility *> newAbilitiesList,bool newAbilityFound = false);
int addToGame();
int destroy();
const char * getMenuText();
@@ -3934,8 +3937,11 @@ public:
bool newtoughnessfound;
int oldtoughness;
bool remove;
vector<MTGAbility *> newAbilitiesList;
map<Damageable *, vector<MTGAbility *>> newAbilities;
bool newAbilityFound;
AForeverTransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound);
AForeverTransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities,string newpower = "",bool newpowerfound = false,string newtoughness = "",bool newtoughnessfound = false,vector<MTGAbility*>newAbilitiesList = vector<MTGAbility*>(),bool newAbilityFound = false);
int addToGame();
const char * getMenuText();
AForeverTransformer * clone() const;
@@ -3951,8 +3957,11 @@ public:
bool newpowerfound;
string newtoughness;
bool newtoughnessfound;
vector<MTGAbility *> newAbilitiesList;
map<Damageable *, vector<MTGAbility *>> newAbilities;
bool newAbilityFound;
ATransformerUEOT(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound);
ATransformerUEOT(int id, MTGCardInstance * source, MTGCardInstance * target, string types = "", string abilities = "",string newpower = "",bool newpowerfound = false,string newtoughness = "",bool newtoughnessfound = false,vector<MTGAbility*>newAbilitiesList = vector<MTGAbility*>(),bool newAbilityFound = false);
int resolve();
const char * getMenuText();
ATransformerUEOT * clone() const;
@@ -3968,8 +3977,11 @@ public:
bool newpowerfound;
string newtoughness;
bool newtoughnessfound;
vector<MTGAbility *> newAbilitiesList;
map<Damageable *, vector<MTGAbility *>> newAbilities;
bool newAbilityFound;
ATransformerFOREVER(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities,string newpower = "",bool newpowerfound = false,string newtoughness = "",bool newtoughnessfound = false);
ATransformerFOREVER(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities,string newpower = "",bool newpowerfound = false,string newtoughness = "",bool newtoughnessfound = false,vector<MTGAbility*>newAbilitiesList = vector<MTGAbility*>(),bool newAbilityFound = false);
int resolve();
const char * getMenuText();
ATransformerFOREVER * clone() const;

View File

@@ -2209,13 +2209,13 @@ AAlterCost::~AAlterCost()
}
// ATransformer
ATransformer::ATransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound) :
MTGAbility(id, source, target),newpower(newpower),newpowerfound(newpowerfound),newtoughness(newtoughness),newtoughnessfound(newtoughnessfound)
ATransformer::ATransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound,vector<MTGAbility *> newAbilitiesList,bool newAbilityFound) :
MTGAbility(id, source, target),newpower(newpower),newpowerfound(newpowerfound),newtoughness(newtoughness),newtoughnessfound(newtoughnessfound),newAbilitiesList(newAbilitiesList),newAbilityFound(newAbilityFound)
{
PopulateAbilityIndexVector(abilities, sabilities);
PopulateColorIndexVector(colors, sabilities);
remove = false;
if (stypes == "removesubtypes")
remove = true;
@@ -2250,77 +2250,89 @@ ATransformer::ATransformer(int id, MTGCardInstance * source, MTGCardInstance * t
menu = stypes;
}
int ATransformer::addToGame()
{
MTGCardInstance * _target = (MTGCardInstance *) target;
if (_target)
int ATransformer::addToGame()
{
while (_target->next)
_target = _target->next;
for (int j = 0; j < Constants::MTG_NB_COLORS; j++)
MTGCardInstance * _target = (MTGCardInstance *) target;
if (_target)
{
if (_target->hasColor(j))
oldcolors.push_back(j);
}
for (int j = Subtypes::LAST_TYPE + 1;; j++)
{
string otypes = Subtypes::subtypesList->find(j);
if (otypes == "")
break;
if (otypes.find(" ") != string::npos)
continue;
if (_target->hasSubtype(j))
while (_target->next)
_target = _target->next;
for (int j = 0; j < Constants::MTG_NB_COLORS; j++)
{
oldtypes.push_back(j);
if (_target->hasColor(j))
oldcolors.push_back(j);
}
for (int j = Subtypes::LAST_TYPE + 1;; j++)
{
string otypes = Subtypes::subtypesList->find(j);
if (otypes == "")
break;
if (otypes.find(" ") != string::npos)
continue;
if (_target->hasSubtype(j))
{
oldtypes.push_back(j);
}
}
list<int>::iterator it;
for (it = colors.begin(); it != colors.end(); it++)
{
_target->setColor(0, 1);
}
}
list<int>::iterator it;
for (it = colors.begin(); it != colors.end(); it++)
{
_target->setColor(0, 1);
}
for (it = types.begin(); it != types.end(); it++)
{
if (remove )
for (it = types.begin(); it != types.end(); it++)
{
_target->removeType(*it);
if (remove )
{
_target->removeType(*it);
}
else
{
_target->addType(*it);
}
}
else
for (it = colors.begin(); it != colors.end(); it++)
{
_target->addType(*it);
_target->setColor(*it);
}
for (it = abilities.begin(); it != abilities.end(); it++)
{
_target->basicAbilities[*it]++;
}
for (it = oldcolors.begin(); it != oldcolors.end(); it++)
{
}
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);
}
}
if(newpowerfound )
{
WParsedInt * val = NEW WParsedInt(newpower,NULL, source);
oldpower = _target->power;
_target->power += val->getValue();
_target->power -= oldpower;
delete val;
}
if(newtoughnessfound )
{
WParsedInt * val = NEW WParsedInt(newtoughness,NULL, source);
oldtoughness = _target->toughness;
_target->addToToughness(val->getValue());
_target->addToToughness(-oldtoughness);
delete val;
}
}
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++)
{
}
if(newpowerfound )
{
WParsedInt * val = NEW WParsedInt(newpower,NULL, source);
oldpower = _target->power;
_target->power += val->getValue();
_target->power -= oldpower;
delete val;
}
if(newtoughnessfound )
{
WParsedInt * val = NEW WParsedInt(newtoughness,NULL, source);
oldtoughness = _target->toughness;
_target->addToToughness(val->getValue());
_target->addToToughness(-oldtoughness);
delete val;
}
return MTGAbility::addToGame();
}
return MTGAbility::addToGame();
}
int ATransformer::destroy()
{
@@ -2363,6 +2375,17 @@ int ATransformer::destroy()
{
_target->toughness = oldtoughness;
}
if(newAbilityFound)
{
for (unsigned int i = 0;i < newAbilities[_target].size(); i++)
{
newAbilities[_target].at(i)->forceDestroy = 1;
}
if (newAbilities.find(_target) != newAbilities.end())
{
newAbilities.erase(_target);
}
}
}
return 1;
}
@@ -2383,12 +2406,19 @@ 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) :
MTGAbility(id, source, target),newpower(newpower),newpowerfound(newpowerfound),newtoughness(newtoughness),newtoughnessfound(newtoughnessfound)
string sabilities,string newpower,bool newpowerfound, string newtoughness,bool newtoughnessfound,vector<MTGAbility*> newAbilitiesList,bool newAbilityFound) :
MTGAbility(id, source, target),newpower(newpower),newpowerfound(newpowerfound),newtoughness(newtoughness),newtoughnessfound(newtoughnessfound),newAbilitiesList(newAbilitiesList),newAbilityFound(newAbilityFound)
{
aType = MTGAbility::STANDARD_BECOMES;
@@ -2438,6 +2468,17 @@ int AForeverTransformer::addToGame()
{
_target->basicAbilities[*it]++;
}
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);
}
}
if(newpowerfound )
{
WParsedInt * val = NEW WParsedInt(newpower,NULL, source);
@@ -2473,13 +2514,20 @@ 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) :
InstantAbility(id, source, target),newpower(newpower),newpowerfound(newpowerfound),newtoughness(newtoughness),newtoughnessfound(newtoughnessfound)
ATransformerUEOT::ATransformerUEOT(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound,vector<MTGAbility*>newAbilitiesList,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);
ability = NEW ATransformer(id, source, target, types, abilities,newpower,newpowerfound,newtoughness,newtoughnessfound,newAbilitiesList,newAbilityFound);
aType = MTGAbility::STANDARD_BECOMES;
}
@@ -2509,10 +2557,10 @@ ATransformerUEOT::~ATransformerUEOT()
}
// ATransformerFOREVER
ATransformerFOREVER::ATransformerFOREVER(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound) :
InstantAbility(id, source, target),newpower(newpower),newpowerfound(newpowerfound),newtoughness(newtoughness),newtoughnessfound(newtoughnessfound)
ATransformerFOREVER::ATransformerFOREVER(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound,vector<MTGAbility*>newAbilitiesList,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);
ability = NEW AForeverTransformer(id, source, target, types, abilities,newpower,newpowerfound,newtoughness,newtoughnessfound,newAbilitiesList,newAbilityFound);
aType = MTGAbility::STANDARD_BECOMES;
}

View File

@@ -2527,7 +2527,9 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
bool newtoughnessfound = false;
string newtoughness = "";
vector <string> abilities = split(sabilities, ',');
bool newAbilityFound = false;
vector<MTGAbility *> newAbilitiesList;
for(unsigned int j = 0;j < abilities.size();j++)
{
if(abilities[j].find("setpower=") != string::npos)
@@ -2542,19 +2544,26 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
int toughnessstart = abilities[j].find("settoughness=");
newtoughness = abilities[j].substr(toughnessstart + 13).c_str();
}
if(abilities[j].find("newability[") != string::npos)
{
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));
}
}
MTGAbility * a;
if (forceFOREVER)
{
a = NEW ATransformerFOREVER(id, card, target, stypes, sabilities,newpower,newpowerfound,newtoughness,newtoughnessfound);
a = NEW ATransformerFOREVER(id, card, target, stypes, sabilities,newpower,newpowerfound,newtoughness,newtoughnessfound,newAbilitiesList,newAbilityFound);
}
else if (forceUEOT)
{
a = NEW ATransformerUEOT(id, card, target, stypes, sabilities,newpower,newpowerfound,newtoughness,newtoughnessfound);
a = NEW ATransformerUEOT(id, card, target, stypes, sabilities,newpower,newpowerfound,newtoughness,newtoughnessfound,newAbilitiesList,newAbilityFound);
}
else
{
a = NEW ATransformer(id, card, target, stypes, sabilities,newpower,newpowerfound,newtoughness,newtoughnessfound);
a = NEW ATransformer(id, card, target, stypes, sabilities,newpower,newpowerfound,newtoughness,newtoughnessfound,newAbilitiesList,newAbilityFound);
}
return a;
}