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;
+1 -1
View File
@@ -318,7 +318,7 @@ int AIAction::getEfficiency()
break; break;
} }
case MTGAbility::STANDARD_PREVENT: case MTGAbility::STANDARD_PREVENT:
{ {
efficiency = 0;//starts out low to avoid spamming it when its not needed. efficiency = 0;//starts out low to avoid spamming it when its not needed.
if (!target && !dynamic_cast<ALord*> (a)) if (!target && !dynamic_cast<ALord*> (a))
break; break;
+48 -47
View File
@@ -2417,34 +2417,29 @@ 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) {
{ if (!Subtypes::subtypesList->isSubtypeOfType(i,Subtypes::TYPE_CREATURE))
if (!Subtypes::subtypesList->isSubtypeOfType(i,Subtypes::TYPE_CREATURE)) continue;
continue;
//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)
continue;
if (s.find(" ") != string::npos) types.push_back(i);
continue; }
} }
types.push_back(i);
}
}
else else
{ {
PopulateSubtypesIndexVector(types, stypes); PopulateSubtypesIndexVector(types, stypes);
@@ -2500,30 +2495,33 @@ 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);
} }
if (remove)
for (it = types.begin(); it != types.end(); it++) {
{ for (it = oldtypes.begin(); it != oldtypes.end(); it++)
if (remove) {
{ _target->removeType(*it);
_target->removeType(*it); }
} }
else for (it = types.begin(); it != types.end(); it++)
{ {
if(_target->hasSubtype(*it)) if(removeCreatureSubtypes)
{ {
//we generally don't want to give a creature type creature again _target->removeType(*it);
//all it does is create a sloppy mess of the subtype line on alternative quads }
//also creates instances where a card gained a type from an ability like this one else if(_target->hasSubtype(*it))
//then loses the type through another ability, when this effect is destroyed the creature regains {
//the type, which is wrong. //we generally don't want to give a creature type creature again
dontremove.push_back(*it); //all it does is create a sloppy mess of the subtype line on alternative quads
} //also creates instances where a card gained a type from an ability like this one
else //then loses the type through another ability, when this effect is destroyed the creature regains
{ //the type, which is wrong.
_target->addType(*it); dontremove.push_back(*it);
} }
} else
} {
_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;
} }
+18 -7
View File
@@ -684,8 +684,12 @@ MTGAbility * AbilityFactory::getCoreAbility(MTGAbility * a)
if (MultiAbility * abi = dynamic_cast<MultiAbility*>(a)) if (MultiAbility * abi = dynamic_cast<MultiAbility*>(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))
return getCoreAbility(na->ability); {
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 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,7 +936,10 @@ 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;
} }