Improved in-game menu (now the Cancel choice is on top and it's possibile to open/close the taskboard during game), improved add/remove "counter" keyword in order to avoid the trigger if needed (e.g. loop avoidance), fixed Italian and Spanish languages.

This commit is contained in:
Vittorio Alfieri
2021-06-18 12:22:16 +02:00
parent 5f0883943a
commit 5b7d8662b7
8 changed files with 70 additions and 38 deletions

View File

@@ -147,6 +147,7 @@ GameState(parent, "duel")
menu = NULL;
popupScreen = NULL;
mGamePhase = DUEL_STATE_UNSET;
taskList = NEW TaskList(options.profileFile(PLAYER_TASKS).c_str());
#ifdef TESTSUITE
testSuite = NULL;
@@ -929,40 +930,45 @@ void GameStateDuel::Update(float dt)
{
menu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), DUEL_MENU_GAME_MENU, this, Fonts::MENU_FONT, SCREEN_WIDTH / 2 - 100, 25);
int cardsinhand = game->currentPlayer->game->hand->nb_cards;
//almosthumane - mulligan
if ((game->turn < 1) && (cardsinhand != 0) && game->getCurrentGamePhase() == MTG_PHASE_FIRSTMAIN
&& game->currentPlayer->game->inPlay->nb_cards == 0 && game->currentPlayer->game->graveyard->nb_cards == 0
&& game->currentPlayer->game->exile->nb_cards == 0 && game->currentlyActing() == (Player*)game->currentPlayer) //1st Play Check
//IF there was no play at the moment automatically mulligan
{
menu->Add(MENUITEM_MULLIGAN, "Mulligan");
}
//END almosthumane - mulligan
if(game->getCurrentGamePhase() == MTG_PHASE_COMBATATTACKERS){ // During attack phase it shows a button to toggle all creatures to attack mode
menu->Add(MENUITEM_TOGGLEATTACK_ALL_CREATURES, "Toggle Attack all Creatures");
}
menu->Add(MENUITEM_MAIN_MENU, "Back to main menu");
#ifdef TESTSUITE
menu->Add(MENUITEM_UNDO, "Undo");
#endif
#ifdef TESTSUITE
menu->Add(MENUITEM_LOAD, "Load");
#endif
if (mParent->players[1] == PLAYER_TYPE_CPU && (mParent->gameType == GAME_TYPE_COMMANDER || mParent->gameType == GAME_TYPE_CLASSIC || mParent->gameType == GAME_TYPE_DEMO))
{
menu->Add(MENUITEM_SHOW_SCORE, "Show current score");
if (mParent->players[0] == PLAYER_TYPE_CPU)
menu->Add(MENUITEM_CANCEL, "Cancel");
if(taskList->getState() != TaskList::TASKS_ACTIVE){
//almosthumane - mulligan
if ((game->turn < 1) && (cardsinhand != 0) && game->getCurrentGamePhase() == MTG_PHASE_FIRSTMAIN
&& game->currentPlayer->game->inPlay->nb_cards == 0 && game->currentPlayer->game->graveyard->nb_cards == 0
&& game->currentPlayer->game->exile->nb_cards == 0 && game->currentlyActing() == (Player*)game->currentPlayer) //1st Play Check
//IF there was no play at the moment automatically mulligan
{
if (tournament->getFastTimerMode())
menu->Add(MENUITEM_SPEED_NORMAL, "set Speed to NORMAL");
else
menu->Add(MENUITEM_SPEED_FAST, "set Speed to FAST");
menu->Add(MENUITEM_MULLIGAN, "Mulligan");
}
//END almosthumane - mulligan
if(game->getCurrentGamePhase() == MTG_PHASE_COMBATATTACKERS){ // During attack phase it shows a button to toggle all creatures to attack mode
menu->Add(MENUITEM_TOGGLEATTACK_ALL_CREATURES, "Toggle Attack all Creatures");
}
menu->Add(MENUITEM_MAIN_MENU, "Back to main menu");
#ifdef TESTSUITE
menu->Add(MENUITEM_UNDO, "Undo");
#endif
#ifdef TESTSUITE
menu->Add(MENUITEM_LOAD, "Load");
#endif
if (mParent->players[1] == PLAYER_TYPE_CPU && (mParent->gameType == GAME_TYPE_COMMANDER || mParent->gameType == GAME_TYPE_CLASSIC || mParent->gameType == GAME_TYPE_DEMO))
{
menu->Add(MENUITEM_SHOW_SCORE, "Show current score");
if (mParent->players[0] == PLAYER_TYPE_CPU)
{
if (tournament->getFastTimerMode())
menu->Add(MENUITEM_SPEED_NORMAL, "set Speed to NORMAL");
else
menu->Add(MENUITEM_SPEED_FAST, "set Speed to FAST");
}
}
}
menu->Add(MENUITEM_CANCEL, "Cancel");
}
if(taskList->getState() != TaskList::TASKS_ACTIVE){
menu->Add(MENUITEM_TASKBOARD, "Open task board");
} else {
menu->Add(MENUITEM_TASKBOARD, "Close task board");
}
setGamePhase(DUEL_STATE_MENU);
}
@@ -1038,6 +1044,8 @@ void GameStateDuel::Update(float dt)
default:
if (JGE_BTN_OK == mEngine->ReadButton()) mParent->SetNextState(GAME_STATE_MENU);
}
if(taskList && taskList->getState() == TaskList::TASKS_IN)
taskList->Update(dt);
}
void GameStateDuel::Render()
@@ -1235,6 +1243,11 @@ void GameStateDuel::Render()
}
}
}
if(taskList && taskList->getState() == TaskList::TASKS_ACTIVE){
taskList->Render();
if(menu)
menu->Render();
}
}
void GameStateDuel::ButtonPressed(int controllerId, int controlId)
@@ -1667,6 +1680,15 @@ void GameStateDuel::ButtonPressed(int controllerId, int controlId)
// menu->Close();
// mGamePhase = DUEL_STATE_CONTINUE;
// break;
case MENUITEM_TASKBOARD:
if(taskList->getState() != TaskList::TASKS_ACTIVE){
taskList->Start();
} else {
taskList->End();
}
menu->Close();
setGamePhase(DUEL_STATE_CANCEL);
break;
case MENUITEM_TOGGLEATTACK_ALL_CREATURES:
for(unsigned int i = 0; i < game->players[0]->inPlay()->cards.size(); i++){
if(game->players[0]->inPlay()->cards[i]->canAttack()){