Added isOptional and optional stats, to allow for optional mission tracking.

This commit is contained in:
Steve 2016-05-15 13:53:19 +01:00
parent 5722b19ec0
commit 038a119965
6 changed files with 17 additions and 3 deletions

View File

@ -337,6 +337,7 @@ enum
STAT_PERCENT_COMPLETE, STAT_PERCENT_COMPLETE,
STAT_MISSIONS_STARTED, STAT_MISSIONS_STARTED,
STAT_MISSIONS_COMPLETED, STAT_MISSIONS_COMPLETED,
STAT_OPTIONAL_COMPLETED,
STAT_CHALLENGES_STARTED, STAT_CHALLENGES_STARTED,
STAT_CHALLENGES_COMPLETED, STAT_CHALLENGES_COMPLETED,
STAT_SHOTS_FIRED, STAT_SHOTS_FIRED,

View File

@ -606,7 +606,7 @@ static void drawStarSystemDetail(void)
{ {
drawText(525, SCREEN_HEIGHT - 95, 18, TA_LEFT, colors.yellow, _("Note: this is an epic mission.")); drawText(525, SCREEN_HEIGHT - 95, 18, TA_LEFT, colors.yellow, _("Note: this is an epic mission."));
} }
else if (selectedStarSystem->side == SIDE_PANDORAN) else if (game.currentMission->isOptional)
{ {
drawText(525, SCREEN_HEIGHT - 95, 18, TA_LEFT, colors.cyan, _("Note: this is an optional mission.")); drawText(525, SCREEN_HEIGHT - 95, 18, TA_LEFT, colors.cyan, _("Note: this is an optional mission."));
} }

View File

@ -51,7 +51,10 @@ Mission *loadMissionMeta(char *filename)
STRNCPY(mission->filename, filename, MAX_DESCRIPTION_LENGTH); STRNCPY(mission->filename, filename, MAX_DESCRIPTION_LENGTH);
mission->requires = getJSONValue(root, "requires", 0); mission->requires = getJSONValue(root, "requires", 0);
mission->isOptional = getJSONValue(root, "isOptional", 0);
mission->requiresOptional = getJSONValue(root, "requiresOptional", 0);
if (cJSON_GetObjectItem(root, "epic")) if (cJSON_GetObjectItem(root, "epic"))
{ {
mission->epic = 1; mission->epic = 1;
@ -256,6 +259,11 @@ void completeMission(void)
selectWidget("continue", "battleWon"); selectWidget("continue", "battleWon");
game.stats[STAT_MISSIONS_COMPLETED]++; game.stats[STAT_MISSIONS_COMPLETED]++;
if (game.currentMission->isOptional)
{
game.stats[STAT_OPTIONAL_COMPLETED]++;
}
completeConditions(); completeConditions();
@ -448,7 +456,7 @@ void updateAllMissions(void)
int isMissionAvailable(Mission *mission, Mission *prev) int isMissionAvailable(Mission *mission, Mission *prev)
{ {
return (prev->completed && mission->requires <= game.completedMissions) || dev.debug; return (prev->completed && mission->requires <= game.completedMissions && game.stats[STAT_OPTIONAL_COMPLETED] >= mission->requiresOptional) || dev.debug;
} }
static unsigned long hashcode(const char *str) static unsigned long hashcode(const char *str)

View File

@ -36,6 +36,7 @@ void initStats(void)
statDescription[STAT_PERCENT_COMPLETE] = _("Percent Complete"); statDescription[STAT_PERCENT_COMPLETE] = _("Percent Complete");
statDescription[STAT_MISSIONS_STARTED] = _("Missions Started"); statDescription[STAT_MISSIONS_STARTED] = _("Missions Started");
statDescription[STAT_MISSIONS_COMPLETED] = _("Missons Completed"); statDescription[STAT_MISSIONS_COMPLETED] = _("Missons Completed");
statDescription[STAT_OPTIONAL_COMPLETED] = _("Optional Missions Completed");
statDescription[STAT_CHALLENGES_STARTED] = _("Challenges Started"); statDescription[STAT_CHALLENGES_STARTED] = _("Challenges Started");
statDescription[STAT_CHALLENGES_COMPLETED] = _("Challenges Completed"); statDescription[STAT_CHALLENGES_COMPLETED] = _("Challenges Completed");
statDescription[STAT_SHOTS_FIRED] = _("Shots Fired"); statDescription[STAT_SHOTS_FIRED] = _("Shots Fired");

View File

@ -274,6 +274,7 @@ struct Mission {
char description[MAX_DESCRIPTION_LENGTH]; char description[MAX_DESCRIPTION_LENGTH];
char filename[MAX_DESCRIPTION_LENGTH]; char filename[MAX_DESCRIPTION_LENGTH];
int requires; int requires;
int requiresOptional;
char pilot[MAX_NAME_LENGTH]; char pilot[MAX_NAME_LENGTH];
char squadron[MAX_NAME_LENGTH]; char squadron[MAX_NAME_LENGTH];
char craft[MAX_NAME_LENGTH]; char craft[MAX_NAME_LENGTH];
@ -282,6 +283,7 @@ struct Mission {
int completedChallenges; int completedChallenges;
int totalChallenges; int totalChallenges;
int epic; int epic;
int isOptional;
ChallengeData challengeData; ChallengeData challengeData;
SDL_Rect rect; SDL_Rect rect;
Mission *next; Mission *next;

View File

@ -103,6 +103,7 @@ void initLookups(void)
addLookup("TT_PLAYER_ESCAPED", TT_PLAYER_ESCAPED); addLookup("TT_PLAYER_ESCAPED", TT_PLAYER_ESCAPED);
addLookup("TT_ITEM", TT_ITEM); addLookup("TT_ITEM", TT_ITEM);
addLookup("TT_STOLEN", TT_STOLEN); addLookup("TT_STOLEN", TT_STOLEN);
addLookup("TT_MISC", TT_MISC);
addLookup("WT_BUTTON", WT_BUTTON); addLookup("WT_BUTTON", WT_BUTTON);
addLookup("WT_SELECT", WT_SELECT); addLookup("WT_SELECT", WT_SELECT);
@ -155,6 +156,7 @@ void initLookups(void)
addLookup("STAT_PERCENT_COMPLETE", STAT_PERCENT_COMPLETE); addLookup("STAT_PERCENT_COMPLETE", STAT_PERCENT_COMPLETE);
addLookup("STAT_MISSIONS_STARTED", STAT_MISSIONS_STARTED); addLookup("STAT_MISSIONS_STARTED", STAT_MISSIONS_STARTED);
addLookup("STAT_MISSIONS_COMPLETED", STAT_MISSIONS_COMPLETED); addLookup("STAT_MISSIONS_COMPLETED", STAT_MISSIONS_COMPLETED);
addLookup("STAT_OPTIONAL_COMPLETED", STAT_OPTIONAL_COMPLETED);
addLookup("STAT_CHALLENGES_STARTED", STAT_CHALLENGES_STARTED); addLookup("STAT_CHALLENGES_STARTED", STAT_CHALLENGES_STARTED);
addLookup("STAT_CHALLENGES_COMPLETED", STAT_CHALLENGES_COMPLETED); addLookup("STAT_CHALLENGES_COMPLETED", STAT_CHALLENGES_COMPLETED);
addLookup("STAT_SHOTS_FIRED", STAT_SHOTS_FIRED); addLookup("STAT_SHOTS_FIRED", STAT_SHOTS_FIRED);