Fix for issue 700 (Basic Lands randomly stop working)

This commit is contained in:
wagic.the.homebrew
2011-07-09 09:25:31 +00:00
parent d23a826fef
commit 8546f3dff8
5 changed files with 48 additions and 18 deletions
+1 -1
View File
@@ -563,7 +563,7 @@ threaten.txt
throne_of_bone.txt throne_of_bone.txt
thunder-thrash_elder.txt thunder-thrash_elder.txt
tidal_warrior_i646.txt tidal_warrior_i646.txt
tidal_warrior_i650.txt tidal_warrior_i649.txt
tidal_warrior_i652.txt tidal_warrior_i652.txt
titanic_ultimatum.txt titanic_ultimatum.txt
tolsimir_wolfblood.txt tolsimir_wolfblood.txt
+6 -12
View File
@@ -2232,7 +2232,6 @@ class ALord: public ListMaintainerAbility, public NestedAbility
public: public:
int includeSelf; int includeSelf;
map<Damageable *, MTGAbility *> abilities; map<Damageable *, MTGAbility *> abilities;
vector<MTGAbility *> bermudaTriangle; //Hack: Lost abilities that need to be properly removed if they reappear
ALord(int _id, MTGCardInstance * card, TargetChooser * _tc, int _includeSelf, MTGAbility * a) : ALord(int _id, MTGCardInstance * card, TargetChooser * _tc, int _includeSelf, MTGAbility * a) :
ListMaintainerAbility(_id, card), NestedAbility(a) ListMaintainerAbility(_id, card), NestedAbility(a)
@@ -2244,16 +2243,12 @@ public:
aType = MTGAbility::STANDARD_PREVENT; aType = MTGAbility::STANDARD_PREVENT;
} }
void Update(float dt) //returns true if it is me who created ability a attached to Damageable d
bool isParentOf(Damageable * d, MTGAbility * a)
{ {
ListMaintainerAbility::Update(dt); if (abilities.find(d) != abilities.end())
return (abilities[d] == a);
//This is a hack to avoid some abilities "combing back from the dead" because of the loseAbility keyword :/ return false;
for (int i = (int)(bermudaTriangle.size()) - 1 ; i >= 0 ; --i)
{
if (game->removeObserver(bermudaTriangle[i]))
bermudaTriangle.erase(bermudaTriangle.begin()+i);
}
} }
int canBeInList(Player *p) int canBeInList(Player *p)
@@ -2323,8 +2318,7 @@ public:
{ {
if (abilities.find(card) != abilities.end()) if (abilities.find(card) != abilities.end())
{ {
if (!game->removeObserver(abilities[card])) game->removeObserver(abilities[card]);
bermudaTriangle.push_back(abilities[card]);
abilities.erase(card); abilities.erase(card);
} }
return 1; return 1;
+36
View File
@@ -2847,6 +2847,20 @@ int ALoseAbilities::addToGame()
ActionLayer * al = game->mLayers->actionLayer(); ActionLayer * al = game->mLayers->actionLayer();
//Build a list of Lords in game, this is a hack mostly for lands, see below
vector <ALord *> lordsInGame;
for (int i = (int)(al->mObjects.size()) - 1; i > 0; i--) //0 is not a mtgability...hackish
{
if (al->mObjects[i])
{
MTGAbility * currentAction = (MTGAbility *) al->mObjects[i];
ALord * l = dynamic_cast<ALord*> (currentAction);
if(l)
lordsInGame.push_back(l);
}
}
for (int i = (int)(al->mObjects.size()) - 1; i > 0; i--) //0 is not a mtgability...hackish for (int i = (int)(al->mObjects.size()) - 1; i > 0; i--) //0 is not a mtgability...hackish
{ {
if (al->mObjects[i]) if (al->mObjects[i])
@@ -2856,12 +2870,34 @@ int ALoseAbilities::addToGame()
if(la) if(la)
continue; continue;
if (currentAction->source == _target) if (currentAction->source == _target)
{
bool canRemove = true;
//Hack: we don't remove abilities on the card if they are provided by an external lord ability.
//This is partly to solve the following issues:
// http://code.google.com/p/wagic/issues/detail?id=647
// http://code.google.com/p/wagic/issues/detail?id=700
// But also because "most" abilities granted by lords will actually go away by themselves,
// based on the fact that we usually remove abilities AND change the type of the card
//Also in a general way we don't want to remove the card's abilities if it is provided by a Lord,
//although there is also a problem with us not handling the P/T layer correctly
for (size_t i = 0; i < lordsInGame.size(); ++i)
{
if (lordsInGame[i]->isParentOf(_target, currentAction))
{
canRemove = false;
break;
}
}
if (canRemove)
{ {
storedAbilities.push_back(currentAction); storedAbilities.push_back(currentAction);
al->removeFromGame(currentAction); al->removeFromGame(currentAction);
} }
} }
} }
}
return MTGAbility::addToGame(); return MTGAbility::addToGame();
} }
+1 -1
View File
@@ -3903,7 +3903,7 @@ TriggerAtPhase::TriggerAtPhase(int id, MTGCardInstance * source, Targetable * ta
newPhase = g->getCurrentGamePhase(); newPhase = g->getCurrentGamePhase();
currentPhase = newPhase; currentPhase = newPhase;
} }
} }
int TriggerAtPhase::trigger() int TriggerAtPhase::trigger()
{ {