Fix for issue 700 (Basic Lands randomly stop working)
This commit is contained in:
@@ -563,7 +563,7 @@ threaten.txt
|
||||
throne_of_bone.txt
|
||||
thunder-thrash_elder.txt
|
||||
tidal_warrior_i646.txt
|
||||
tidal_warrior_i650.txt
|
||||
tidal_warrior_i649.txt
|
||||
tidal_warrior_i652.txt
|
||||
titanic_ultimatum.txt
|
||||
tolsimir_wolfblood.txt
|
||||
|
||||
@@ -2232,7 +2232,6 @@ class ALord: public ListMaintainerAbility, public NestedAbility
|
||||
public:
|
||||
int includeSelf;
|
||||
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) :
|
||||
ListMaintainerAbility(_id, card), NestedAbility(a)
|
||||
@@ -2241,19 +2240,15 @@ public:
|
||||
tc->targetter = NULL;
|
||||
includeSelf = _includeSelf;
|
||||
if(ability->aType == MTGAbility::STANDARD_PREVENT)
|
||||
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);
|
||||
|
||||
//This is a hack to avoid some abilities "combing back from the dead" because of the loseAbility keyword :/
|
||||
for (int i = (int)(bermudaTriangle.size()) - 1 ; i >= 0 ; --i)
|
||||
{
|
||||
if (game->removeObserver(bermudaTriangle[i]))
|
||||
bermudaTriangle.erase(bermudaTriangle.begin()+i);
|
||||
}
|
||||
if (abilities.find(d) != abilities.end())
|
||||
return (abilities[d] == a);
|
||||
return false;
|
||||
}
|
||||
|
||||
int canBeInList(Player *p)
|
||||
@@ -2267,7 +2262,7 @@ public:
|
||||
if(card->isPhased || source->isPhased)
|
||||
return 0;
|
||||
if ((includeSelf || card != source) && tc->canTarget(card))
|
||||
return 1;
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2323,8 +2318,7 @@ public:
|
||||
{
|
||||
if (abilities.find(card) != abilities.end())
|
||||
{
|
||||
if (!game->removeObserver(abilities[card]))
|
||||
bermudaTriangle.push_back(abilities[card]);
|
||||
game->removeObserver(abilities[card]);
|
||||
abilities.erase(card);
|
||||
}
|
||||
return 1;
|
||||
|
||||
@@ -2847,6 +2847,20 @@ int ALoseAbilities::addToGame()
|
||||
|
||||
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
|
||||
{
|
||||
if (al->mObjects[i])
|
||||
@@ -2857,8 +2871,30 @@ int ALoseAbilities::addToGame()
|
||||
continue;
|
||||
if (currentAction->source == _target)
|
||||
{
|
||||
storedAbilities.push_back(currentAction);
|
||||
al->removeFromGame(currentAction);
|
||||
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);
|
||||
al->removeFromGame(currentAction);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3903,7 +3903,7 @@ TriggerAtPhase::TriggerAtPhase(int id, MTGCardInstance * source, Targetable * ta
|
||||
newPhase = g->getCurrentGamePhase();
|
||||
currentPhase = newPhase;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int TriggerAtPhase::trigger()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user