MCPcopy Create free account
hub / github.com/NetHack/NetHack / xlev_to_rank

Function xlev_to_rank

src/botl.c:297–311  ·  view source on GitHub ↗

convert experience level (1..30) to rank index (0..8) */

Source from the content-addressed store, hash-verified

295
296/* convert experience level (1..30) to rank index (0..8) */
297int
298xlev_to_rank(int xlev)
299{
300 /*
301 * 1..2 => 0
302 * 3..5 => 1
303 * 6..9 => 2
304 * 10..13 => 3
305 * ...
306 * 26..29 => 7
307 * 30 => 8
308 * Conversion is precise but only partially reversible.
309 */
310 return (xlev <= 2) ? 0 : (xlev <= 30) ? ((xlev + 2) / 4) : 8;
311}
312
313/* convert rank index (0..8) to experience level (1..30) */
314int

Callers 3

pluslvlFunction · 0.85
critically_low_hpFunction · 0.85
rank_ofFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected