Prototyping stats trophies.
This commit is contained in:
parent
f867e793bd
commit
93dd00c785
|
@ -58,13 +58,17 @@
|
||||||
"id" : "FIRE_100000",
|
"id" : "FIRE_100000",
|
||||||
"title" : "Your name's on one of these!",
|
"title" : "Your name's on one of these!",
|
||||||
"description" : "Fire 100,000 shots",
|
"description" : "Fire 100,000 shots",
|
||||||
"value" : "TROPHY_SILVER"
|
"value" : "TROPHY_SILVER",
|
||||||
|
"stat" : "STAT_SHOTS_FIRED",
|
||||||
|
"statValue" : 10000
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : "MISSILE_1000",
|
"id" : "MISSILE_1000",
|
||||||
"title" : "Dodge this!",
|
"title" : "Dodge this!",
|
||||||
"description" : "Launch 1,000 missiles",
|
"description" : "Launch 1,000 missiles",
|
||||||
"value" : "TROPHY_SILVER"
|
"value" : "TROPHY_SILVER",
|
||||||
|
"stat" : "STAT_MISSILES_FIRED",
|
||||||
|
"statValue" : 1000
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : "ATAF_DESTROYED",
|
"id" : "ATAF_DESTROYED",
|
||||||
|
|
|
@ -59,6 +59,8 @@ void initChallengeHome(void)
|
||||||
|
|
||||||
unlockChallenges();
|
unlockChallenges();
|
||||||
|
|
||||||
|
checkStatTrophies();
|
||||||
|
|
||||||
saveGame();
|
saveGame();
|
||||||
|
|
||||||
app.delegate.logic = &logic;
|
app.delegate.logic = &logic;
|
||||||
|
@ -150,6 +152,8 @@ static void logic(void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
doTrophies();
|
||||||
|
|
||||||
doWidgets();
|
doWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,6 +250,8 @@ static void draw(void)
|
||||||
drawOptions();
|
drawOptions();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
doTrophyAlert();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drawChallenges(void)
|
static void drawChallenges(void)
|
||||||
|
|
|
@ -60,6 +60,9 @@ extern void playMusic(char *filename);
|
||||||
extern char *timeToString(long millis, int showHours);
|
extern char *timeToString(long millis, int showHours);
|
||||||
extern char *getChallengeDescription(Challenge *c);
|
extern char *getChallengeDescription(Challenge *c);
|
||||||
extern void clearInput(void);
|
extern void clearInput(void);
|
||||||
|
extern void doTrophies(void);
|
||||||
|
extern void drawTrophyAlert(void);
|
||||||
|
extern void checkStatTrophies(void);
|
||||||
|
|
||||||
extern App app;
|
extern App app;
|
||||||
extern Battle battle;
|
extern Battle battle;
|
||||||
|
|
|
@ -88,6 +88,8 @@ void initGalacticMap(void)
|
||||||
|
|
||||||
updatePandoranAdvance();
|
updatePandoranAdvance();
|
||||||
|
|
||||||
|
checkStatTrophies();
|
||||||
|
|
||||||
saveGame();
|
saveGame();
|
||||||
|
|
||||||
pulseTimer = 0;
|
pulseTimer = 0;
|
||||||
|
@ -170,6 +172,8 @@ static void logic(void)
|
||||||
|
|
||||||
arrowPulse += 0.1;
|
arrowPulse += 0.1;
|
||||||
|
|
||||||
|
doTrophies();
|
||||||
|
|
||||||
doWidgets();
|
doWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,6 +363,8 @@ static void draw(void)
|
||||||
drawOptions();
|
drawOptions();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
drawTrophyAlerts();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drawPulses(void)
|
static void drawPulses(void)
|
||||||
|
|
|
@ -60,6 +60,9 @@ extern StarSystem *getStarSystem(char *name);
|
||||||
extern void showOKDialog(void (*callback)(void), const char *format, ...);
|
extern void showOKDialog(void (*callback)(void), const char *format, ...);
|
||||||
extern char *getTranslatedString(char *string);
|
extern char *getTranslatedString(char *string);
|
||||||
extern void clearInput(void);
|
extern void clearInput(void);
|
||||||
|
extern void doTrophies(void);
|
||||||
|
extern void drawTrophyAlert(void);
|
||||||
|
extern void checkStatTrophies(void);
|
||||||
|
|
||||||
extern App app;
|
extern App app;
|
||||||
extern Colors colors;
|
extern Colors colors;
|
||||||
|
|
|
@ -159,6 +159,13 @@ static void loadTrophyData(char *filename)
|
||||||
t->value = lookup(cJSON_GetObjectItem(node, "value")->valuestring);
|
t->value = lookup(cJSON_GetObjectItem(node, "value")->valuestring);
|
||||||
t->hidden = getJSONValue(node, "hidden", 0);
|
t->hidden = getJSONValue(node, "hidden", 0);
|
||||||
|
|
||||||
|
/* can't use the getJSONValue here, as it could lead to false positives */
|
||||||
|
if (cJSON_GetObjectItem(node, "stat"))
|
||||||
|
{
|
||||||
|
t->stat = lookup(cJSON_GetObjectItem(node, "stat")->valuestring));
|
||||||
|
t->statValue = cJSON_GetObjectItem(node, "statValue")->valueint;
|
||||||
|
}
|
||||||
|
|
||||||
tail->next = t;
|
tail->next = t;
|
||||||
tail = t;
|
tail = t;
|
||||||
}
|
}
|
||||||
|
@ -166,3 +173,18 @@ static void loadTrophyData(char *filename)
|
||||||
cJSON_Delete(root);
|
cJSON_Delete(root);
|
||||||
free(text);
|
free(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void checkStatTrophies(void)
|
||||||
|
{
|
||||||
|
Trophy *t;
|
||||||
|
|
||||||
|
for (t = game.trophyHead.next ; t != NULL ; t = t->next)
|
||||||
|
{
|
||||||
|
if (!t->awarded && game.stats[t->stat] >= t->statValue)
|
||||||
|
{
|
||||||
|
t->awarded = 1;
|
||||||
|
t->awardDate = time(NULL);
|
||||||
|
t->notify = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -349,6 +349,8 @@ struct Trophy {
|
||||||
char description[MAX_DESCRIPTION_LENGTH];
|
char description[MAX_DESCRIPTION_LENGTH];
|
||||||
int value;
|
int value;
|
||||||
int hidden;
|
int hidden;
|
||||||
|
int stat;
|
||||||
|
int statValue;
|
||||||
int awarded;
|
int awarded;
|
||||||
unsigned long awardDate;
|
unsigned long awardDate;
|
||||||
int notify;
|
int notify;
|
||||||
|
|
Loading…
Reference in New Issue