Merge pull request #816 from zethfoxster/master

add some handling of reveal to avoid a crash in demo for AI.
This commit is contained in:
zethfoxster
2016-07-30 10:51:26 -04:00
committed by GitHub

View File

@@ -416,7 +416,10 @@ bool MTGRevealingCards::CheckUserInput(JButton key)
{ {
if (this->source->controller() != game->isInterrupting) if (this->source->controller() != game->isInterrupting)
game->mLayers->stackLayer()->cancelInterruptOffer(ActionStack::DONT_INTERRUPT, false); game->mLayers->stackLayer()->cancelInterruptOffer(ActionStack::DONT_INTERRUPT, false);
if (key == 0)
key = JGE_BTN_NEXT;
if (key != JGE_BTN_OK && key != JGE_BTN_NEXT)
key = JGE_BTN_OK;
} }
if (JGE_BTN_SEC == key || JGE_BTN_PREV == key || JGE_BTN_NEXT == key || JGE_BTN_MENU == key)//android back button if (JGE_BTN_SEC == key || JGE_BTN_PREV == key || JGE_BTN_NEXT == key || JGE_BTN_MENU == key)//android back button
{ {
@@ -431,10 +434,9 @@ bool MTGRevealingCards::CheckUserInput(JButton key)
tc->source->getObserver()->cardClick(tc->source, 0, false); tc->source->getObserver()->cardClick(tc->source, 0, false);
//remove the first ability to avoid a menu react. //remove the first ability to avoid a menu react.
source->getObserver()->mLayers->stackLayer()->Remove(abilityFirst); source->getObserver()->mLayers->stackLayer()->Remove(abilityFirst);
abilityFirst->removeFromGame();
game->removeObserver(abilityFirst); game->removeObserver(abilityFirst);
if (!this->source->controller()->isAI())
game->Update(0); game->Update(0);
if (zone->cards.size())//generally only want to add ability 2 if anything is left in the zone. if (zone->cards.size())//generally only want to add ability 2 if anything is left in the zone.
@@ -461,8 +463,8 @@ bool MTGRevealingCards::CheckUserInput(JButton key)
if (!tc && !abilitySecond) if (!tc && !abilitySecond)
{ {
source->getObserver()->mLayers->stackLayer()->Remove(abilityFirst); source->getObserver()->mLayers->stackLayer()->Remove(abilityFirst);
abilityFirst->removeFromGame();
game->removeObserver(abilityFirst); game->removeObserver(abilityFirst);
if (!this->source->controller()->isAI())
game->Update(1); game->Update(1);
if (zone->cards.size()) if (zone->cards.size())
@@ -722,6 +724,10 @@ bool MTGScryCards::CheckUserInput(JButton key)
//in the future we will need a way to find out if the human is pressing the keys and which player. //in the future we will need a way to find out if the human is pressing the keys and which player.
if (this->source->controller() != game->isInterrupting) if (this->source->controller() != game->isInterrupting)
game->mLayers->stackLayer()->cancelInterruptOffer(ActionStack::DONT_INTERRUPT, false); game->mLayers->stackLayer()->cancelInterruptOffer(ActionStack::DONT_INTERRUPT, false);
if (key == 0)
key = JGE_BTN_NEXT;
if (key != JGE_BTN_OK && key != JGE_BTN_NEXT)
key = JGE_BTN_OK;
} }
if (JGE_BTN_SEC == key || JGE_BTN_PREV == key || JGE_BTN_NEXT == key || JGE_BTN_MENU == key) if (JGE_BTN_SEC == key || JGE_BTN_PREV == key || JGE_BTN_NEXT == key || JGE_BTN_MENU == key)
{ {
@@ -734,8 +740,8 @@ bool MTGScryCards::CheckUserInput(JButton key)
tc->source->getObserver()->cardClick(tc->source, 0, false); tc->source->getObserver()->cardClick(tc->source, 0, false);
//remove the first ability to avoid a menu react. //remove the first ability to avoid a menu react.
source->getObserver()->mLayers->stackLayer()->Remove(abilityFirst); source->getObserver()->mLayers->stackLayer()->Remove(abilityFirst);
abilityFirst->removeFromGame();
game->removeObserver(abilityFirst); game->removeObserver(abilityFirst);
if (!this->source->controller()->isAI())
game->Update(0); game->Update(0);
if (zone->cards.size()) if (zone->cards.size())
{ {
@@ -761,8 +767,8 @@ bool MTGScryCards::CheckUserInput(JButton key)
{ {
//remove the first ability to avoid a menu react. //remove the first ability to avoid a menu react.
source->getObserver()->mLayers->stackLayer()->Remove(abilityFirst); source->getObserver()->mLayers->stackLayer()->Remove(abilityFirst);
abilityFirst->removeFromGame();
game->removeObserver(abilityFirst); game->removeObserver(abilityFirst);
if (!this->source->controller()->isAI())
game->Update(1); game->Update(1);
if (zone->cards.size() || (revealDisplay && !zone->cards.size())) if (zone->cards.size() || (revealDisplay && !zone->cards.size()))