track eight more achievements

Record reaching experience level 3, 6, 10, 14, 18, 22, 26, and 30,
the levels where the character gets a new rank title, and report
those as achievements at end of game.  These achievements persist
even if enough levels to lose a rank are lost, and if lost ranks
are regained the original achievement is the one that gets tracked
and disclosed.
This commit is contained in:
PatR
2020-05-04 16:35:40 -07:00
parent 16562b2892
commit 116642ce1e
8 changed files with 117 additions and 28 deletions

View File

@@ -474,13 +474,16 @@ boolean condition;
static char *
encode_extended_achievements()
{
static char buf[N_ACH*40];
static char buf[N_ACH * 40];
char rnkbuf[40];
const char *achievement = NULL;
int i;
int i, achidx, absidx;
buf[0] = '\0';
for (i = 0; u.uachieved[i]; i++) {
switch (u.uachieved[i]) {
achidx = u.uachieved[i];
absidx = abs(achidx);
switch (absidx) {
case ACH_UWIN:
achievement = "ascended";
break;
@@ -517,7 +520,6 @@ encode_extended_achievements()
case ACH_SOKO_PRIZE:
achievement = "obtained_the_sokoban_prize";
break;
case ACH_ORCL:
achievement = "consulted_the_oracle";
break;
@@ -542,6 +544,15 @@ encode_extended_achievements()
case ACH_BGRM:
achievement = "entered_bigroom";
break;
/* rank 0 is the starting condition, not an achievement; 8 is Xp 30 */
case ACH_RNK1: case ACH_RNK2: case ACH_RNK3: case ACH_RNK4:
case ACH_RNK5: case ACH_RNK6: case ACH_RNK7: case ACH_RNK8:
Sprintf(rnkbuf, "attained_the_rank_of_%s",
rank_of(rank_to_xlev(absidx - (ACH_RNK1 - 1)),
Role_switch, (achidx < 0) ? TRUE : FALSE));
strNsubst(rnkbuf, " ", "_", 0); /* replace every ' ' with '_' */
achievement = lcase(rnkbuf);
break;
default:
continue;
}