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 -1
View File
@@ -318,7 +318,7 @@ int AIAction::getEfficiency()
break;
}
case MTGAbility::STANDARD_PREVENT:
{
{
efficiency = 0;//starts out low to avoid spamming it when its not needed.
if (!target && !dynamic_cast<ALord*> (a))
break;
+48 -47
View File
@@ -2417,34 +2417,29 @@ ATransformer::ATransformer(int id, MTGCardInstance * source, MTGCardInstance * t
PopulateAbilityIndexVector(abilities, sabilities);
PopulateColorIndexVector(colors, sabilities);
//this subkeyword adds a color without removing the existing colors.
addNewColors = (sabilities.find("newcolors") != string::npos);
remove = (stypes == "removesubtypes");
removeTypes = (stypes == "removetypes");
remove = (stypes.find("removesubtypes") != string::npos);
removeCreatureSubtypes = (stypes.find("removecreaturesubtypes") != string::npos);
removeTypes = (stypes.find("removetypes") != string::npos);
//Gains or loses all creature subtypes
if (stypes == "allsubtypes" || stypes == "removesubtypes")
{
for (size_t i = 0; i <Subtypes::subtypesList->getValuesById().size(); ++i)
{
if (!Subtypes::subtypesList->isSubtypeOfType(i,Subtypes::TYPE_CREATURE))
continue;
if (stypes.find("allsubtypes") != string::npos || stypes.find("removecreaturesubtypes") != string::npos)
{
for (size_t i = 0; i <Subtypes::subtypesList->getValuesById().size(); ++i)
{
if (!Subtypes::subtypesList->isSubtypeOfType(i,Subtypes::TYPE_CREATURE))
continue;
//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
//TODO Remove the following block if possible
{
string s = Subtypes::subtypesList->find(i);
if (s.find(" ") != string::npos)
continue;
}
types.push_back(i);
}
}
//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
//TODO Remove the following block if possible
string s = Subtypes::subtypesList->find(i);
if (s.find(" ") != string::npos)
continue;
types.push_back(i);
}
}
else
{
PopulateSubtypesIndexVector(types, stypes);
@@ -2500,30 +2495,33 @@ int ATransformer::addToGame()
for (int i = 0; i < Subtypes::LAST_TYPE; ++ i)
_target->removeType(i,1);
}
for (it = types.begin(); it != types.end(); it++)
{
if (remove)
{
_target->removeType(*it);
}
else
{
if(_target->hasSubtype(*it))
{
//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
//also creates instances where a card gained a type from an ability like this one
//then loses the type through another ability, when this effect is destroyed the creature regains
//the type, which is wrong.
dontremove.push_back(*it);
}
else
{
_target->addType(*it);
}
}
}
if (remove)
{
for (it = oldtypes.begin(); it != oldtypes.end(); it++)
{
_target->removeType(*it);
}
}
for (it = types.begin(); it != types.end(); it++)
{
if(removeCreatureSubtypes)
{
_target->removeType(*it);
}
else if(_target->hasSubtype(*it))
{
//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
//also creates instances where a card gained a type from an ability like this one
//then loses the type through another ability, when this effect is destroyed the creature regains
//the type, which is wrong.
dontremove.push_back(*it);
}
else
{
_target->addType(*it);
}
}
for (it = colors.begin(); it != colors.end(); it++)
{
@@ -2688,6 +2686,9 @@ int ATransformer::destroy()
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;
}
+18 -7
View File
@@ -684,8 +684,12 @@ MTGAbility * AbilityFactory::getCoreAbility(MTGAbility * a)
if (MultiAbility * abi = dynamic_cast<MultiAbility*>(a))
return getCoreAbility(abi->abilities[0]);
if (NestedAbility * na = dynamic_cast<NestedAbility*> (a))
return getCoreAbility(na->ability);
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 a;
}
@@ -1942,18 +1946,25 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
{
vector<string> becomesParameters = split(splitBecomes[1], ',');
string stypes = becomesParameters[0];
string newPower = "";
string newToughness = "";
bool ptFound = false;
if(becomesParameters.size() >1)
{
vector<string> pt = split(becomesParameters[1], '/');
string newPower = pt[0];
string newToughness = pt[1];
newPower = pt[0];
newToughness = pt[1];
ptFound = true;
}
string sabilities = (becomesParameters.size() > 2) ? becomesParameters[2] : "";
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)
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
+3
View File
@@ -936,7 +936,10 @@ bool TypeTargetChooser::canTarget(Targetable * target,bool withoutProtections)
for (int i = 0; i < nbtypes; i++)
{
if (card->hasSubtype(types[i])) return true;
if(card->getLCName().size())
{
if (Subtypes::subtypesList->find(card->getLCName()) == types[i]) return true;
}
}
return false;
}