couple bug fixes, changed a subkeyword of transforms "removesubtypes" to "removealltypes" remove all the types of the card, added "removecreaturesubtypes" to maintain previous support it was used for.

This commit is contained in:
omegablast2002@yahoo.com
2011-05-09 15:55:34 +00:00
parent b1ea63cd79
commit 01cfbf5a02
5 changed files with 71 additions and 55 deletions
+1
View File
@@ -3471,6 +3471,7 @@ public:
vector<int> dontremove; vector<int> dontremove;
bool addNewColors; bool addNewColors;
bool remove; bool remove;
bool removeCreatureSubtypes;
bool removeTypes; bool removeTypes;
string menu; string menu;
string newpower; string newpower;
+16 -15
View File
@@ -2418,14 +2418,13 @@ ATransformer::ATransformer(int id, MTGCardInstance * source, MTGCardInstance * t
PopulateAbilityIndexVector(abilities, sabilities); PopulateAbilityIndexVector(abilities, sabilities);
PopulateColorIndexVector(colors, sabilities); PopulateColorIndexVector(colors, sabilities);
//this subkeyword adds a color without removing the existing colors. //this subkeyword adds a color without removing the existing colors.
addNewColors = (sabilities.find("newcolors") != string::npos); addNewColors = (sabilities.find("newcolors") != string::npos);
remove = (stypes == "removesubtypes"); remove = (stypes.find("removesubtypes") != string::npos);
removeTypes = (stypes == "removetypes"); removeCreatureSubtypes = (stypes.find("removecreaturesubtypes") != string::npos);
removeTypes = (stypes.find("removetypes") != string::npos);
//Gains or loses all creature subtypes if (stypes.find("allsubtypes") != string::npos || stypes.find("removecreaturesubtypes") != string::npos)
if (stypes == "allsubtypes" || stypes == "removesubtypes")
{ {
for (size_t i = 0; i <Subtypes::subtypesList->getValuesById().size(); ++i) for (size_t i = 0; i <Subtypes::subtypesList->getValuesById().size(); ++i)
{ {
@@ -2435,13 +2434,9 @@ ATransformer::ATransformer(int id, MTGCardInstance * source, MTGCardInstance * t
//Erwan 2011/5/6 String comparison is expensive. Any way to do this in a cleaner way? //Erwan 2011/5/6 String comparison is expensive. Any way to do this in a cleaner way?
//I think this is releated to the fact that "Pestilence Rats" is a type for some reason, maybe we don't need that anymore //I think this is releated to the fact that "Pestilence Rats" is a type for some reason, maybe we don't need that anymore
//TODO Remove the following block if possible //TODO Remove the following block if possible
{
string s = Subtypes::subtypesList->find(i); string s = Subtypes::subtypesList->find(i);
if (s.find(" ") != string::npos) if (s.find(" ") != string::npos)
continue; continue;
}
types.push_back(i); types.push_back(i);
} }
} }
@@ -2500,16 +2495,20 @@ int ATransformer::addToGame()
for (int i = 0; i < Subtypes::LAST_TYPE; ++ i) for (int i = 0; i < Subtypes::LAST_TYPE; ++ i)
_target->removeType(i,1); _target->removeType(i,1);
} }
for (it = types.begin(); it != types.end(); it++)
{
if (remove) if (remove)
{
for (it = oldtypes.begin(); it != oldtypes.end(); it++)
{ {
_target->removeType(*it); _target->removeType(*it);
} }
else }
for (it = types.begin(); it != types.end(); it++)
{ {
if(_target->hasSubtype(*it)) if(removeCreatureSubtypes)
{
_target->removeType(*it);
}
else if(_target->hasSubtype(*it))
{ {
//we generally don't want to give a creature type creature again //we generally don't want to give a creature type creature again
//all it does is create a sloppy mess of the subtype line on alternative quads //all it does is create a sloppy mess of the subtype line on alternative quads
@@ -2523,7 +2522,6 @@ int ATransformer::addToGame()
_target->addType(*it); _target->addType(*it);
} }
} }
}
for (it = colors.begin(); it != colors.end(); it++) for (it = colors.begin(); it != colors.end(); it++)
{ {
@@ -2688,6 +2686,9 @@ int ATransformer::destroy()
newAbilities.erase(_target); newAbilities.erase(_target);
} }
} }
//we reset the name in the case that we removed or added types to a card, so that it retains its original name when the effect is removed.
_target->name.clear();
_target->setName(_target->model->data->name.c_str());
} }
return 1; return 1;
} }
+16 -5
View File
@@ -685,7 +685,11 @@ MTGAbility * AbilityFactory::getCoreAbility(MTGAbility * a)
return getCoreAbility(abi->abilities[0]); return getCoreAbility(abi->abilities[0]);
if (NestedAbility * na = dynamic_cast<NestedAbility*> (a)) if (NestedAbility * na = dynamic_cast<NestedAbility*> (a))
{
if(na->ability)
//only atempt to return a nestedability if it contains a valid ability. example where this causes a bug otherwise. AEquip is considered nested, but contains no ability.
return getCoreAbility(na->ability); return getCoreAbility(na->ability);
}
return a; return a;
} }
@@ -1942,18 +1946,25 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
{ {
vector<string> becomesParameters = split(splitBecomes[1], ','); vector<string> becomesParameters = split(splitBecomes[1], ',');
string stypes = becomesParameters[0]; string stypes = becomesParameters[0];
string newPower = "";
string newToughness = "";
bool ptFound = false;
if(becomesParameters.size() >1)
{
vector<string> pt = split(becomesParameters[1], '/'); vector<string> pt = split(becomesParameters[1], '/');
string newPower = pt[0]; newPower = pt[0];
string newToughness = pt[1]; newToughness = pt[1];
ptFound = true;
}
string sabilities = (becomesParameters.size() > 2) ? becomesParameters[2] : ""; string sabilities = (becomesParameters.size() > 2) ? becomesParameters[2] : "";
if (oneShot || forceUEOT) if (oneShot || forceUEOT)
return NEW ATransformerInstant(id, card, target, stypes, sabilities,newPower,true,newToughness,true,vector<string>(),false,forceFOREVER); return NEW ATransformerInstant(id, card, target, stypes, sabilities,newPower,ptFound,newToughness,ptFound,vector<string>(),false,forceFOREVER);
if(forceFOREVER) if(forceFOREVER)
return NEW ATransformerInstant(id, card, target, stypes, sabilities,newPower,true,newToughness,true,vector<string>(),false,forceFOREVER); return NEW ATransformerInstant(id, card, target, stypes, sabilities,newPower,ptFound,newToughness,ptFound,vector<string>(),false,forceFOREVER);
return NEW ATransformer(id, card, target, stypes, sabilities,newPower,true,newToughness,true,vector<string>(),false,forceFOREVER); return NEW ATransformer(id, card, target, stypes, sabilities,newPower,ptFound,newToughness,ptFound,vector<string>(),false,forceFOREVER);
} }
//bloodthirst //bloodthirst
+3
View File
@@ -936,8 +936,11 @@ bool TypeTargetChooser::canTarget(Targetable * target,bool withoutProtections)
for (int i = 0; i < nbtypes; i++) for (int i = 0; i < nbtypes; i++)
{ {
if (card->hasSubtype(types[i])) return true; if (card->hasSubtype(types[i])) return true;
if(card->getLCName().size())
{
if (Subtypes::subtypesList->find(card->getLCName()) == types[i]) return true; if (Subtypes::subtypesList->find(card->getLCName()) == types[i]) return true;
} }
}
return false; return false;
} }
else if (target->typeAsTarget() == TARGET_STACKACTION) else if (target->typeAsTarget() == TARGET_STACKACTION)