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
+16 -4
View File
@@ -3909,9 +3909,12 @@ public:
string newtoughness; string newtoughness;
bool newtoughnessfound; bool newtoughnessfound;
int oldtoughness; 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 addToGame();
int destroy(); int destroy();
const char * getMenuText(); const char * getMenuText();
@@ -3934,8 +3937,11 @@ public:
bool newtoughnessfound; bool newtoughnessfound;
int oldtoughness; int oldtoughness;
bool remove; 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(); int addToGame();
const char * getMenuText(); const char * getMenuText();
AForeverTransformer * clone() const; AForeverTransformer * clone() const;
@@ -3951,8 +3957,11 @@ public:
bool newpowerfound; bool newpowerfound;
string newtoughness; string newtoughness;
bool newtoughnessfound; 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(); int resolve();
const char * getMenuText(); const char * getMenuText();
ATransformerUEOT * clone() const; ATransformerUEOT * clone() const;
@@ -3968,8 +3977,11 @@ public:
bool newpowerfound; bool newpowerfound;
string newtoughness; string newtoughness;
bool newtoughnessfound; 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(); int resolve();
const char * getMenuText(); const char * getMenuText();
ATransformerFOREVER * clone() const; ATransformerFOREVER * clone() const;
+118 -70
View File
@@ -2209,8 +2209,8 @@ AAlterCost::~AAlterCost()
} }
// ATransformer // ATransformer
ATransformer::ATransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities,string newpower,bool newpowerfound,string newtoughness,bool 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) MTGAbility(id, source, target),newpower(newpower),newpowerfound(newpowerfound),newtoughness(newtoughness),newtoughnessfound(newtoughnessfound),newAbilitiesList(newAbilitiesList),newAbilityFound(newAbilityFound)
{ {
PopulateAbilityIndexVector(abilities, sabilities); PopulateAbilityIndexVector(abilities, sabilities);
@@ -2250,77 +2250,89 @@ ATransformer::ATransformer(int id, MTGCardInstance * source, MTGCardInstance * t
menu = stypes; menu = stypes;
} }
int ATransformer::addToGame() int ATransformer::addToGame()
{
MTGCardInstance * _target = (MTGCardInstance *) target;
if (_target)
{ {
while (_target->next) MTGCardInstance * _target = (MTGCardInstance *) target;
_target = _target->next; if (_target)
for (int j = 0; j < Constants::MTG_NB_COLORS; j++)
{ {
if (_target->hasColor(j)) while (_target->next)
oldcolors.push_back(j); _target = _target->next;
} for (int j = 0; j < Constants::MTG_NB_COLORS; 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); 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++) for (it = types.begin(); it != types.end(); it++)
{
if (remove )
{ {
_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++) return MTGAbility::addToGame();
{
_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();
}
int ATransformer::destroy() int ATransformer::destroy()
{ {
@@ -2363,6 +2375,17 @@ int ATransformer::destroy()
{ {
_target->toughness = oldtoughness; _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; return 1;
} }
@@ -2383,12 +2406,19 @@ ATransformer * ATransformer::clone() const
ATransformer::~ATransformer() ATransformer::~ATransformer()
{ {
if(!isClone)
{
for (unsigned int k = 0; k < newAbilitiesList.size();k++)
{
SAFE_DELETE(newAbilitiesList[k]);
}
}
} }
// AForeverTransformer // AForeverTransformer
AForeverTransformer::AForeverTransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, AForeverTransformer::AForeverTransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes,
string sabilities,string newpower,bool newpowerfound, string newtoughness,bool 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) MTGAbility(id, source, target),newpower(newpower),newpowerfound(newpowerfound),newtoughness(newtoughness),newtoughnessfound(newtoughnessfound),newAbilitiesList(newAbilitiesList),newAbilityFound(newAbilityFound)
{ {
aType = MTGAbility::STANDARD_BECOMES; aType = MTGAbility::STANDARD_BECOMES;
@@ -2438,6 +2468,17 @@ int AForeverTransformer::addToGame()
{ {
_target->basicAbilities[*it]++; _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 ) if(newpowerfound )
{ {
WParsedInt * val = NEW WParsedInt(newpower,NULL, source); WParsedInt * val = NEW WParsedInt(newpower,NULL, source);
@@ -2473,13 +2514,20 @@ AForeverTransformer * AForeverTransformer::clone() const
} }
AForeverTransformer::~AForeverTransformer() AForeverTransformer::~AForeverTransformer()
{ {
if(!isClone)
{
for (unsigned int k = 0; k < newAbilitiesList.size();k++)
{
SAFE_DELETE(newAbilitiesList[k]);
}
}
} }
//ATransformerUEOT //ATransformerUEOT
ATransformerUEOT::ATransformerUEOT(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities,string newpower,bool newpowerfound,string newtoughness,bool 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) 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; aType = MTGAbility::STANDARD_BECOMES;
} }
@@ -2509,10 +2557,10 @@ ATransformerUEOT::~ATransformerUEOT()
} }
// ATransformerFOREVER // ATransformerFOREVER
ATransformerFOREVER::ATransformerFOREVER(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities,string newpower,bool newpowerfound,string newtoughness,bool 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) 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; aType = MTGAbility::STANDARD_BECOMES;
} }
+12 -3
View File
@@ -2527,6 +2527,8 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
bool newtoughnessfound = false; bool newtoughnessfound = false;
string newtoughness = ""; string newtoughness = "";
vector <string> abilities = split(sabilities, ','); vector <string> abilities = split(sabilities, ',');
bool newAbilityFound = false;
vector<MTGAbility *> newAbilitiesList;
for(unsigned int j = 0;j < abilities.size();j++) for(unsigned int j = 0;j < abilities.size();j++)
{ {
@@ -2542,19 +2544,26 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
int toughnessstart = abilities[j].find("settoughness="); int toughnessstart = abilities[j].find("settoughness=");
newtoughness = abilities[j].substr(toughnessstart + 13).c_str(); 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; MTGAbility * a;
if (forceFOREVER) 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) 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 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; return a;
} }