Merge pull request #737 from zethfoxster/master

merging to master
This commit is contained in:
zethfoxster
2016-07-09 09:11:33 -04:00
committed by GitHub
5 changed files with 51 additions and 9 deletions

View File

@@ -3256,6 +3256,7 @@ public:
}
else
{
a->forcedAlive = 1;
a->addToGame();
abilities[d] = a;
}
@@ -3278,6 +3279,7 @@ public:
if (abilities.find(card) != abilities.end()
&& !(forceDestroy == -1 && forcedAlive == 1)) //only embelms have forcedestroy = -1 and forcedalive = 1
{
abilities[card]->forcedAlive = 0;
game->removeObserver(abilities[card]);
abilities.erase(card);
}
@@ -6160,7 +6162,7 @@ public:
{
if(forceDestroy != -1)
return 1;
if(!(source->hasType(Subtypes::TYPE_INSTANT)||source->hasType(Subtypes::TYPE_INSTANT)) && !source->isInPlay(game))
if(!(source->hasType(Subtypes::TYPE_INSTANT)||source->hasType(Subtypes::TYPE_SORCERY)) && !source->isInPlay(game))
return 1;
return 0;
}

View File

@@ -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);

View File

@@ -426,6 +426,9 @@ uint8_t CardPrimitive::ConvertColorToBitMask(int inColor)
case Constants::MTG_COLOR_LAND:
value = kColorBitMask_Land;
break;
case Constants::MTG_COLOR_WASTE://the true colorless mana shares the kbitmask of land. kbitmask dictates the color of the quad(no image boarder), and the symbol. nothing more.
value = kColorBitMask_Land;
break;
default:
break;

View File

@@ -53,6 +53,7 @@ void GameObserver::cleanup()
actionsList.clear();
gameTurn.clear();
OpenedDisplay = NULL;
AffinityNeedsUpdate = false;
}
GameObserver::~GameObserver()
@@ -1079,7 +1080,24 @@ void GameObserver::Affinity()
}
}
}
////////////////////////////
///we handle trisnisphere seperately because its a desaster.
if (card->has(Constants::TRINISPHERE))
{
for (int jj = card->getManaCost()->getConvertedCost(); jj < 3; jj++)
{
card->getManaCost()->add(Constants::MTG_COLOR_ARTIFACT, 1);
card->countTrini++;
}
}
else
{
if (card->countTrini)
{
card->getManaCost()->remove(Constants::MTG_COLOR_ARTIFACT, card->countTrini);
card->countTrini = 0;
}
}
///////////////////////
bool NewAffinityFound = false;
for (unsigned int na = 0; na < card->cardsAbilities.size(); na++)
{
@@ -1092,30 +1110,31 @@ void GameObserver::Affinity()
}
}
bool DoReduceIncrease = false;
if (card->has(Constants::AFFINITYARTIFACTS) ||
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)
&&
AffinityNeedsUpdate
)
DoReduceIncrease = true;
if (!DoReduceIncrease)
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
//1mb a sec to run at all time even when no known reducers or increasers are in play.
//memory snapshot shots pointed to this as such a heavy load that games with many cards inplay
//would slow to a crawl.
//only do any of the following if a card with the stated ability is in your hand.
//kicker is an addon to normal cost, suspend is not casting. add cost as needed EXACTLY as seen below.
card->getManaCost()->resetCosts();
ManaCost * newCost = NEW ManaCost();
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())
@@ -1170,6 +1189,7 @@ void GameObserver::Affinity()
}//end
}
}
AffinityNeedsUpdate = false;
}
void GameObserver::Render()
@@ -1579,6 +1599,7 @@ int GameObserver::receiveEvent(WEvent * e)
SAFE_DELETE(ev);
eventsQueue.pop();
}
AffinityNeedsUpdate = true;
return result;
}

View File

@@ -970,6 +970,14 @@ ManaCost * MTGCardInstance::computeNewCost(MTGCardInstance * card,ManaCost * Cos
string type = "";
ManaCost * original = NEW ManaCost();
original->copy(Data);
Cost->copy(original);
if (Cost->extraCosts)
{
for (unsigned int i = 0; i < Cost->extraCosts->costs.size(); i++)
{
Cost->extraCosts->costs[i]->setSource(card);
}
}
if (card->getIncreasedManaCost()->getConvertedCost() || card->getReducedManaCost()->getConvertedCost())
{//start1
if (card->getIncreasedManaCost()->getConvertedCost())
@@ -1076,6 +1084,13 @@ ManaCost * MTGCardInstance::computeNewCost(MTGCardInstance * card,ManaCost * Cos
Cost->extraCosts->costs[i]->setSource(card);
}
}
if (Cost->extraCosts)
{
for (unsigned int i = 0; i < Cost->extraCosts->costs.size(); i++)
{
Cost->extraCosts->costs[i]->setSource(card);
}
}
int reduce = 0;
if (card->has(Constants::AFFINITYGREENCREATURES))
{