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

Function somegold

src/steal.c:13–34  ·  view source on GitHub ↗

proportional subset of gold; return value actually fits in an int */

Source from the content-addressed store, hash-verified

11
12/* proportional subset of gold; return value actually fits in an int */
13long
14somegold(long lmoney)
15{
16 int igold = (lmoney >= (long) LARGEST_INT) ? LARGEST_INT : (int) lmoney;
17
18 if (igold < 50)
19 ; /* all gold */
20 else if (igold < 100)
21 igold = rn1(igold - 25 + 1, 25);
22 else if (igold < 500)
23 igold = rn1(igold - 50 + 1, 50);
24 else if (igold < 1000)
25 igold = rn1(igold - 100 + 1, 100);
26 else if (igold < 5000)
27 igold = rn1(igold - 500 + 1, 500);
28 else if (igold < 10000)
29 igold = rn1(igold - 1000 + 1, 1000);
30 else
31 igold = rn1(igold - 5000 + 1, 5000);
32
33 return (long) igold;
34}
35
36/*
37 * Find the first (and hopefully only) gold object in a chain.

Callers 2

stealgoldFunction · 0.85
dipfountainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected