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

@@ -270,18 +270,37 @@ int
xlev_to_rank(xlev)
int xlev;
{
/*
* 1..2 => 0
* 3..5 => 1
* 6..9 => 2
* 10..13 => 3
* ...
* 26..29 => 7
* 30 => 8
* Conversion is precise but only partially reversible.
*/
return (xlev <= 2) ? 0 : (xlev <= 30) ? ((xlev + 2) / 4) : 8;
}
#if 0 /* not currently needed */
/* convert rank index (0..8) to experience level (1..30) */
int
rank_to_xlev(rank)
int rank;
{
return (rank <= 0) ? 1 : (rank <= 8) ? ((rank * 4) - 2) : 30;
/*
* 0 => 1..2
* 1 => 3..5
* 2 => 6..9
* 3 => 10..13
* ...
* 7 => 26..29
* 8 => 30
* We return the low end of each range.
*/
return (rank < 1) ? 1 : (rank < 2) ? 3
: (rank < 8) ? ((rank * 4) - 2) : 30;
}
#endif
const char *
rank_of(lev, monnum, female)