Centralize completeMission and failMission logic.
This commit is contained in:
parent
cd1068b2a7
commit
1cd8b42664
|
@ -134,18 +134,6 @@ static void doBattle(void)
|
|||
if (battle.status != MS_IN_PROGRESS)
|
||||
{
|
||||
battle.missionFinishedTimer--;
|
||||
|
||||
if (battle.missionFinishedTimer == 0)
|
||||
{
|
||||
if (battle.status == MS_COMPLETE)
|
||||
{
|
||||
selectWidget("continue", "battleWon");
|
||||
}
|
||||
else
|
||||
{
|
||||
selectWidget("retry", "battleLost");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
battle.stats[STAT_TIME]++;
|
||||
|
@ -247,6 +235,14 @@ static void handleKeyboard(void)
|
|||
{
|
||||
battle.status = MS_PAUSED;
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
if (app.keyboard[SDL_SCANCODE_F10])
|
||||
{
|
||||
completeMission();
|
||||
battle.missionFinishedTimer = -FPS;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void start(void)
|
||||
|
|
|
@ -65,6 +65,7 @@ extern void checkTrigger(char *name, int type);
|
|||
extern void resetWaypoints(void);
|
||||
extern void doPlayerSelect(void);
|
||||
extern void destroyGrid(void);
|
||||
extern void completeMission(void);
|
||||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
|
|
|
@ -98,16 +98,24 @@ void loadMission(char *filename)
|
|||
|
||||
void completeMission(void)
|
||||
{
|
||||
battle.status = MS_COMPLETE;
|
||||
battle.missionFinishedTimer = FPS;
|
||||
if (battle.status == MS_IN_PROGRESS)
|
||||
{
|
||||
battle.status = MS_COMPLETE;
|
||||
battle.missionFinishedTimer = FPS;
|
||||
selectWidget("continue", "battleWon");
|
||||
|
||||
game.stats[STAT_MISSIONS_COMPLETED]++;
|
||||
game.stats[STAT_MISSIONS_COMPLETED]++;
|
||||
}
|
||||
}
|
||||
|
||||
void failMission(void)
|
||||
{
|
||||
battle.status = MS_FAILED;
|
||||
battle.missionFinishedTimer = FPS;
|
||||
if (battle.status == MS_IN_PROGRESS)
|
||||
{
|
||||
battle.status = MS_FAILED;
|
||||
battle.missionFinishedTimer = FPS;
|
||||
selectWidget("retry", "battleLost");
|
||||
}
|
||||
}
|
||||
|
||||
static void loadObjectives(cJSON *node)
|
||||
|
|
|
@ -37,6 +37,7 @@ extern void initPlayer(void);
|
|||
extern long flagsToLong(char *flags);
|
||||
extern Entity *spawnWaypoint(void);
|
||||
extern void activateNextWaypoint(void);
|
||||
extern void selectWidget(const char *name, const char *group);
|
||||
|
||||
extern Battle battle;
|
||||
extern Entity *player;
|
||||
|
|
Loading…
Reference in New Issue