going to try only updating affinity() when cards move from anywhere to anywhere to help minimize the calls to this function. this atleast allows me to debug albeit slowly the follow issue ive been working to fix. not sure when this was introduced but it was not happening when i first coded this function. manacost->copy() did not slow the game to a crawl.
anyways, trinisphere and any card containing
other={H(land[basic]|mybattlefield)}{1} name(Pay /1/ and Return a Basic Land to Hand)
cost such as this with a CD tc.
This commit is contained in:
@@ -124,6 +124,7 @@ class GameObserver{
|
||||
void gameStateBasedEffects();
|
||||
void enchantmentStatus();
|
||||
void Affinity();
|
||||
bool AffinityNeedsUpdate;
|
||||
void addObserver(MTGAbility * observer);
|
||||
bool removeObserver(ActionElement * observer);
|
||||
void startGame(GameType, Rules * rules);
|
||||
|
||||
@@ -53,6 +53,7 @@ void GameObserver::cleanup()
|
||||
actionsList.clear();
|
||||
gameTurn.clear();
|
||||
OpenedDisplay = NULL;
|
||||
AffinityNeedsUpdate = false;
|
||||
}
|
||||
|
||||
GameObserver::~GameObserver()
|
||||
@@ -1092,20 +1093,22 @@ void GameObserver::Affinity()
|
||||
NewAffinityFound = true;
|
||||
}
|
||||
}
|
||||
bool DoReduceIncrease = false;
|
||||
if (card->has(Constants::AFFINITYARTIFACTS) ||
|
||||
card->has(Constants::AFFINITYFOREST) ||
|
||||
card->has(Constants::AFFINITYGREENCREATURES) ||
|
||||
card->has(Constants::AFFINITYISLAND) ||
|
||||
card->has(Constants::AFFINITYMOUNTAIN) ||
|
||||
card->has(Constants::AFFINITYPLAINS) ||
|
||||
card->has(Constants::AFFINITYSWAMP) ||
|
||||
card->has(Constants::TRINISPHERE) ||
|
||||
card->getIncreasedManaCost()->getConvertedCost() ||
|
||||
card->getReducedManaCost()->getConvertedCost() ||
|
||||
NewAffinityFound)
|
||||
DoReduceIncrease = true;
|
||||
if (!DoReduceIncrease)
|
||||
//bool DoReduceIncrease = false;
|
||||
//if (card->has(Constants::AFFINITYARTIFACTS) ||
|
||||
// card->has(Constants::AFFINITYFOREST) ||
|
||||
// card->has(Constants::AFFINITYGREENCREATURES) ||
|
||||
// card->has(Constants::AFFINITYISLAND) ||
|
||||
// card->has(Constants::AFFINITYMOUNTAIN) ||
|
||||
// card->has(Constants::AFFINITYPLAINS) ||
|
||||
// card->has(Constants::AFFINITYSWAMP) ||
|
||||
// card->has(Constants::TRINISPHERE) ||
|
||||
// card->getIncreasedManaCost()->getConvertedCost() ||
|
||||
// card->getReducedManaCost()->getConvertedCost() ||
|
||||
// NewAffinityFound)
|
||||
// DoReduceIncrease = true;
|
||||
//if (!DoReduceIncrease)
|
||||
// continue;
|
||||
if(!AffinityNeedsUpdate)//we only adjust cost when cards move from anywhere to anywhere.
|
||||
continue;
|
||||
//above we check if there are even any cards that effect cards manacost
|
||||
//if there are none, leave this function. manacost->copy( is a very expensive funtion
|
||||
@@ -1117,6 +1120,7 @@ void GameObserver::Affinity()
|
||||
card->getManaCost()->resetCosts();
|
||||
ManaCost *newCost = NEW ManaCost();
|
||||
newCost->copy(card->computeNewCost(card, card->getManaCost(), card->model->data->getManaCost()));
|
||||
|
||||
card->getManaCost()->copy(newCost);
|
||||
SAFE_DELETE(newCost);
|
||||
if (card->getManaCost()->getAlternative())
|
||||
@@ -1171,6 +1175,7 @@ void GameObserver::Affinity()
|
||||
}//end
|
||||
}
|
||||
}
|
||||
AffinityNeedsUpdate = false;
|
||||
}
|
||||
|
||||
void GameObserver::Render()
|
||||
|
||||
@@ -328,6 +328,7 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
|
||||
bool shufflelibrary = card->basicAbilities[(int)Constants::SHUFFLELIBRARYDEATH];
|
||||
bool inplaytoinplay = false;
|
||||
bool ripToken = false;
|
||||
g->AffinityNeedsUpdate = true;//we refresh affinity whenever a card is moved from anywhere to anywhere.
|
||||
if (g->players[0]->game->battlefield->hasName("Rest in Peace")||g->players[1]->game->battlefield->hasName("Rest in Peace"))
|
||||
ripToken = true;
|
||||
//Madness or Put in Play...
|
||||
|
||||
Reference in New Issue
Block a user