Minor GameObserver refactor, should have no impact on the game.
This commit is contained in:
@@ -145,9 +145,6 @@ void GameObserver::nextGamePhase()
|
|||||||
DebugTrace("Untap Phase ------------- Turn " << turn );
|
DebugTrace("Untap Phase ------------- Turn " << turn );
|
||||||
untapPhase();
|
untapPhase();
|
||||||
break;
|
break;
|
||||||
case Constants::MTG_PHASE_DRAW:
|
|
||||||
//mLayers->stackLayer()->addDraw(currentPlayer,1);
|
|
||||||
break;
|
|
||||||
case Constants::MTG_PHASE_COMBATBLOCKERS:
|
case Constants::MTG_PHASE_COMBATBLOCKERS:
|
||||||
receiveEvent(NEW WEventAttackersChosen());
|
receiveEvent(NEW WEventAttackersChosen());
|
||||||
break;
|
break;
|
||||||
@@ -205,8 +202,6 @@ void GameObserver::userRequestNextGamePhase()
|
|||||||
if (WaitForExtraPayment(NULL))
|
if (WaitForExtraPayment(NULL))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool executeNextPhaseImmediately = true;
|
|
||||||
|
|
||||||
Phase * cPhaseOld = phaseRing->getCurrentPhase();
|
Phase * cPhaseOld = phaseRing->getCurrentPhase();
|
||||||
if ((cPhaseOld->id == Constants::MTG_PHASE_COMBATBLOCKERS && combatStep == ORDER)
|
if ((cPhaseOld->id == Constants::MTG_PHASE_COMBATBLOCKERS && combatStep == ORDER)
|
||||||
|| (cPhaseOld->id == Constants::MTG_PHASE_COMBATBLOCKERS && combatStep == TRIGGERS)
|
|| (cPhaseOld->id == Constants::MTG_PHASE_COMBATBLOCKERS && combatStep == TRIGGERS)
|
||||||
@@ -215,16 +210,11 @@ void GameObserver::userRequestNextGamePhase()
|
|||||||
|| options[Options::optionInterrupt(currentGamePhase)].number
|
|| options[Options::optionInterrupt(currentGamePhase)].number
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
executeNextPhaseImmediately = false;
|
mLayers->stackLayer()->AddNextGamePhase();
|
||||||
}
|
|
||||||
|
|
||||||
if (executeNextPhaseImmediately)
|
|
||||||
{
|
|
||||||
nextGamePhase();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mLayers->stackLayer()->AddNextGamePhase();
|
nextGamePhase();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -232,18 +222,16 @@ void GameObserver::userRequestNextGamePhase()
|
|||||||
int GameObserver::forceShuffleLibraries()
|
int GameObserver::forceShuffleLibraries()
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
if (players[0]->game->library->needShuffle)
|
for (int i = 0; i < 2 ; ++i)
|
||||||
{
|
{
|
||||||
players[0]->game->library->shuffle();
|
if (players[i]->game->library->needShuffle)
|
||||||
players[0]->game->library->needShuffle = false;
|
{
|
||||||
++result;
|
players[i]->game->library->shuffle();
|
||||||
}
|
players[i]->game->library->needShuffle = false;
|
||||||
if (players[1]->game->library->needShuffle)
|
++result;
|
||||||
{
|
}
|
||||||
players[1]->game->library->shuffle();
|
|
||||||
players[1]->game->library->needShuffle = false;
|
|
||||||
++result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,7 +420,7 @@ void GameObserver::gameStateBasedEffects()
|
|||||||
card->isPhased = true;
|
card->isPhased = true;
|
||||||
card->phasedTurn = turn;
|
card->phasedTurn = turn;
|
||||||
if(card->view)
|
if(card->view)
|
||||||
card->view->alpha = 50;
|
card->view->alpha = 50;
|
||||||
card->initAttackersDefensers();
|
card->initAttackersDefensers();
|
||||||
}
|
}
|
||||||
else if((card->has(Constants::PHASING) || card->isPhased)&& currentGamePhase == Constants::MTG_PHASE_UNTAP && currentPlayer == card->controller() && card->phasedTurn != turn)
|
else if((card->has(Constants::PHASING) || card->isPhased)&& currentGamePhase == Constants::MTG_PHASE_UNTAP && currentPlayer == card->controller() && card->phasedTurn != turn)
|
||||||
@@ -440,14 +428,14 @@ void GameObserver::gameStateBasedEffects()
|
|||||||
card->isPhased = false;
|
card->isPhased = false;
|
||||||
card->phasedTurn = turn;
|
card->phasedTurn = turn;
|
||||||
if(card->view)
|
if(card->view)
|
||||||
card->view->alpha = 255;
|
card->view->alpha = 255;
|
||||||
}
|
}
|
||||||
if (card->target && isInPlay(card->target) && (card->hasSubtype(Subtypes::TYPE_EQUIPMENT) || card->hasSubtype(Subtypes::TYPE_AURA)))
|
if (card->target && isInPlay(card->target) && (card->hasSubtype(Subtypes::TYPE_EQUIPMENT) || card->hasSubtype(Subtypes::TYPE_AURA)))
|
||||||
{
|
{
|
||||||
card->isPhased = card->target->isPhased;
|
card->isPhased = card->target->isPhased;
|
||||||
card->phasedTurn = card->target->phasedTurn;
|
card->phasedTurn = card->target->phasedTurn;
|
||||||
if(card->view && card->target->view)
|
if(card->view && card->target->view)
|
||||||
card->view->alpha = card->target->view->alpha;
|
card->view->alpha = card->target->view->alpha;
|
||||||
}
|
}
|
||||||
//////////////////////////
|
//////////////////////////
|
||||||
//forceDestroy over ride//
|
//forceDestroy over ride//
|
||||||
@@ -508,14 +496,7 @@ void GameObserver::gameStateBasedEffects()
|
|||||||
MTGGameZone * z = players[i]->game->inPlay;
|
MTGGameZone * z = players[i]->game->inPlay;
|
||||||
int nbcards = z->nb_cards;
|
int nbcards = z->nb_cards;
|
||||||
//------------------------------
|
//------------------------------
|
||||||
if (z->hasAbility(Constants::NOMAXHAND))
|
p->nomaxhandsize = (z->hasAbility(Constants::NOMAXHAND));
|
||||||
{
|
|
||||||
p->nomaxhandsize = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
p->nomaxhandsize = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////
|
/////////////////////////////////////////////////
|
||||||
//handle end of turn effects while we're at it.//
|
//handle end of turn effects while we're at it.//
|
||||||
@@ -536,9 +517,9 @@ void GameObserver::gameStateBasedEffects()
|
|||||||
c->addToToughness(1);
|
c->addToToughness(1);
|
||||||
c->flanked -= 1;
|
c->flanked -= 1;
|
||||||
}
|
}
|
||||||
if (c->fresh) c->fresh = 0;
|
c->fresh = 0;
|
||||||
if(c->wasDealtDamage && c->isInPlay())
|
if(c->wasDealtDamage && c->isInPlay())
|
||||||
c->wasDealtDamage = false;
|
c->wasDealtDamage = false;
|
||||||
c->damageToController = false;
|
c->damageToController = false;
|
||||||
c->damageToOpponent = false;
|
c->damageToOpponent = false;
|
||||||
|
|
||||||
@@ -597,14 +578,8 @@ void GameObserver::gameStateBasedEffects()
|
|||||||
if (z->cards[w]->hasColor(i))
|
if (z->cards[w]->hasColor(i))
|
||||||
++colored;
|
++colored;
|
||||||
}
|
}
|
||||||
if(colored > 1)
|
z->cards[w]->isMultiColored = (colored > 1) ? 1 : 0;
|
||||||
{
|
|
||||||
z->cards[w]->isMultiColored = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
z->cards[w]->isMultiColored = 0;
|
|
||||||
}
|
|
||||||
if(z->cards[w]->hasColor(Constants::MTG_COLOR_WHITE) && z->cards[w]->hasColor(Constants::MTG_COLOR_BLACK))
|
if(z->cards[w]->hasColor(Constants::MTG_COLOR_WHITE) && z->cards[w]->hasColor(Constants::MTG_COLOR_BLACK))
|
||||||
z->cards[w]->isBlackAndWhite = 1;
|
z->cards[w]->isBlackAndWhite = 1;
|
||||||
else
|
else
|
||||||
@@ -694,53 +669,55 @@ void GameObserver::Affinity()
|
|||||||
for (int k = zone->nb_cards - 1; k >= 0; k--)
|
for (int k = zone->nb_cards - 1; k >= 0; k--)
|
||||||
{
|
{
|
||||||
MTGCardInstance * card = zone->cards[k];
|
MTGCardInstance * card = zone->cards[k];
|
||||||
|
if (!card)
|
||||||
|
continue;
|
||||||
|
|
||||||
int color = 0;
|
int color = 0;
|
||||||
string type = "";
|
string type = "";
|
||||||
//only do any of the following if a card with the stated ability is in your hand.
|
//only do any of the following if a card with the stated ability is in your hand.
|
||||||
ManaCost * original = NEW ManaCost();
|
ManaCost * original = NEW ManaCost();
|
||||||
original->copy(card->model->data->getManaCost());
|
original->copy(card->model->data->getManaCost());
|
||||||
//have to run alter cost before affinity or the 2 cancel each other out.
|
//have to run alter cost before affinity or the 2 cancel each other out.
|
||||||
if(card && (card->getIncreasedManaCost()->getConvertedCost()||card->getReducedManaCost()->getConvertedCost()))
|
if(card->getIncreasedManaCost()->getConvertedCost()||card->getReducedManaCost()->getConvertedCost())
|
||||||
{
|
{
|
||||||
if(card->getIncreasedManaCost()->getConvertedCost())
|
if(card->getIncreasedManaCost()->getConvertedCost())
|
||||||
original->add(card->getIncreasedManaCost());
|
original->add(card->getIncreasedManaCost());
|
||||||
if(card->getReducedManaCost()->getConvertedCost())
|
if(card->getReducedManaCost()->getConvertedCost())
|
||||||
original->remove(card->getReducedManaCost());
|
original->remove(card->getReducedManaCost());
|
||||||
card->getManaCost()->copy(original);
|
card->getManaCost()->copy(original);
|
||||||
}
|
}
|
||||||
if(card &&
|
if(card->has(Constants::AFFINITYARTIFACTS)||
|
||||||
(card->has(Constants::AFFINITYARTIFACTS)||
|
|
||||||
card->has(Constants::AFFINITYFOREST)||
|
card->has(Constants::AFFINITYFOREST)||
|
||||||
card->has(Constants::AFFINITYGREENCREATURES)||
|
card->has(Constants::AFFINITYGREENCREATURES)||
|
||||||
card->has(Constants::AFFINITYISLAND)||
|
card->has(Constants::AFFINITYISLAND)||
|
||||||
card->has(Constants::AFFINITYMOUNTAIN)||
|
card->has(Constants::AFFINITYMOUNTAIN)||
|
||||||
card->has(Constants::AFFINITYPLAINS)||
|
card->has(Constants::AFFINITYPLAINS)||
|
||||||
card->has(Constants::AFFINITYSWAMP))){
|
card->has(Constants::AFFINITYSWAMP)){
|
||||||
if (card && card->has(Constants::AFFINITYARTIFACTS))
|
if (card->has(Constants::AFFINITYARTIFACTS))
|
||||||
{
|
{
|
||||||
type = "artifact";
|
type = "artifact";
|
||||||
}
|
}
|
||||||
else if (card && card->has(Constants::AFFINITYSWAMP))
|
else if (card->has(Constants::AFFINITYSWAMP))
|
||||||
{
|
{
|
||||||
type = "swamp";
|
type = "swamp";
|
||||||
}
|
}
|
||||||
else if (card && card->has(Constants::AFFINITYMOUNTAIN))
|
else if (card->has(Constants::AFFINITYMOUNTAIN))
|
||||||
{
|
{
|
||||||
type = "mountain";
|
type = "mountain";
|
||||||
}
|
}
|
||||||
else if (card && card->has(Constants::AFFINITYPLAINS))
|
else if (card->has(Constants::AFFINITYPLAINS))
|
||||||
{
|
{
|
||||||
type = "plains";
|
type = "plains";
|
||||||
}
|
}
|
||||||
else if (card && card->has(Constants::AFFINITYISLAND))
|
else if (card->has(Constants::AFFINITYISLAND))
|
||||||
{
|
{
|
||||||
type = "island";
|
type = "island";
|
||||||
}
|
}
|
||||||
else if (card && card->has(Constants::AFFINITYFOREST))
|
else if (card->has(Constants::AFFINITYFOREST))
|
||||||
{
|
{
|
||||||
type = "forest";
|
type = "forest";
|
||||||
}
|
}
|
||||||
else if (card && card->has(Constants::AFFINITYGREENCREATURES))
|
else if (card->has(Constants::AFFINITYGREENCREATURES))
|
||||||
{
|
{
|
||||||
color = 1;
|
color = 1;
|
||||||
type = "creature";
|
type = "creature";
|
||||||
@@ -764,8 +741,7 @@ void GameObserver::Affinity()
|
|||||||
card->getManaCost()->remove(color,1);
|
card->getManaCost()->remove(color,1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(original)
|
SAFE_DELETE(original);
|
||||||
delete original;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user