OSDN Git Service

日本語版
[nazghul-jp/nazghul-jp.git] / src / dice.h
1
2 /* A dice roll is specified by a string format. For example, "2d20+6". The
3  * legal formats are defined by a regular expression:
4  *
5  *      ([1-9][0-9]*]d[1-9][0-9]*)?([\+\-]?[1-9][0-9]*)?
6  *
7  * Which means the following are all legal examples:
8  *
9  *      "1d1"
10  *      "2"
11  *      "" (note: returns 0)
12  *      "5064d21023902-10909012"
13  *
14  * The result of the dice roll is returned. If the format is invalid then it
15  * will always return 0, but since 0 is a valid response you won't necessarily
16  * be able to tell. To check if a format is bad use the separate dice_valid()
17  * call, which returns non-zero if the format is ok and 0 otherwise.
18  *
19  */
20 extern int dice_roll(const char *fmt);
21 extern int dice_valid(const char *fmt);
22 extern int dice_average(const char *fmt);
23 extern int dice_roll_numeric(int num, int faces, int bias);