diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 724ee26c6..1455526aa 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -3471,6 +3471,7 @@ public: vector dontremove; bool addNewColors; bool remove; + bool removeCreatureSubtypes; bool removeTypes; string menu; string newpower; diff --git a/projects/mtg/src/AIPlayer.cpp b/projects/mtg/src/AIPlayer.cpp index 4b677d320..ed03a47db 100644 --- a/projects/mtg/src/AIPlayer.cpp +++ b/projects/mtg/src/AIPlayer.cpp @@ -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 (a)) break; diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 43c175b34..fd8438bf5 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -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 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 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; } diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 9cad1d88e..38bfa91f5 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -684,8 +684,12 @@ MTGAbility * AbilityFactory::getCoreAbility(MTGAbility * a) if (MultiAbility * abi = dynamic_cast(a)) return getCoreAbility(abi->abilities[0]); - if (NestedAbility * na = dynamic_cast (a)) - return getCoreAbility(na->ability); + if (NestedAbility * na = dynamic_cast (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 becomesParameters = split(splitBecomes[1], ','); string stypes = becomesParameters[0]; + string newPower = ""; + string newToughness = ""; + bool ptFound = false; + if(becomesParameters.size() >1) + { vector 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(),false,forceFOREVER); + return NEW ATransformerInstant(id, card, target, stypes, sabilities,newPower,ptFound,newToughness,ptFound,vector(),false,forceFOREVER); if(forceFOREVER) - return NEW ATransformerInstant(id, card, target, stypes, sabilities,newPower,true,newToughness,true,vector(),false,forceFOREVER); + return NEW ATransformerInstant(id, card, target, stypes, sabilities,newPower,ptFound,newToughness,ptFound,vector(),false,forceFOREVER); - return NEW ATransformer(id, card, target, stypes, sabilities,newPower,true,newToughness,true,vector(),false,forceFOREVER); + return NEW ATransformer(id, card, target, stypes, sabilities,newPower,ptFound,newToughness,ptFound,vector(),false,forceFOREVER); } //bloodthirst diff --git a/projects/mtg/src/TargetChooser.cpp b/projects/mtg/src/TargetChooser.cpp index 18775e4c7..f5a158b47 100644 --- a/projects/mtg/src/TargetChooser.cpp +++ b/projects/mtg/src/TargetChooser.cpp @@ -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; }