Fix for issue 700 (Basic Lands randomly stop working)
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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)
|
||||||
@@ -2241,19 +2240,15 @@ public:
|
|||||||
tc->targetter = NULL;
|
tc->targetter = NULL;
|
||||||
includeSelf = _includeSelf;
|
includeSelf = _includeSelf;
|
||||||
if(ability->aType == MTGAbility::STANDARD_PREVENT)
|
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);
|
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)
|
||||||
@@ -2267,7 +2262,7 @@ public:
|
|||||||
if(card->isPhased || source->isPhased)
|
if(card->isPhased || source->isPhased)
|
||||||
return 0;
|
return 0;
|
||||||
if ((includeSelf || card != source) && tc->canTarget(card))
|
if ((includeSelf || card != source) && tc->canTarget(card))
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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;
|
||||||
|
|||||||
@@ -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])
|
||||||
@@ -2857,8 +2871,30 @@ int ALoseAbilities::addToGame()
|
|||||||
continue;
|
continue;
|
||||||
if (currentAction->source == _target)
|
if (currentAction->source == _target)
|
||||||
{
|
{
|
||||||
storedAbilities.push_back(currentAction);
|
bool canRemove = true;
|
||||||
al->removeFromGame(currentAction);
|
|
||||||
|
//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();
|
newPhase = g->getCurrentGamePhase();
|
||||||
currentPhase = newPhase;
|
currentPhase = newPhase;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int TriggerAtPhase::trigger()
|
int TriggerAtPhase::trigger()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user