home *** CD-ROM | disk | FTP | other *** search
- ROLDIC.ZIP --
-
- rollDice function:
-
- int rollDice( const char far *specifier );
-
- returns badRollValue (-32768 [0x8000]) if the specifier is invalid.
-
- The specifier string must contain a roll spec, whose format is:
-
- nDs
-
- n is the number of dice, D (or d) is a separator, and s is the size
- of each die. For example:
-
- 1d6 standard 6-side roll 1..6
- 1d100 percentile roll 1..100
- 3d6 D&D-style stat roll 3..18 in bell-shaped distribution
-
- Note: 0 is not acceptable for either n or s, and rollDice() returns
- badRollValue if either is 0.
-
- The specifier may contain an adjustment value which is indicated by
- either a + or - character, followed by the adjustor. The adjustor may
- either be a numeric constant, or another roll specifier. Examples:
-
- +10 add 10
- -5 subtract 5
- +1d4 add 1..4
-
- Complete specifier examples:
-
- 3d6+4 returns 7..22 in a bell-shaped distribution
- 1d6+1d4 returns 2..10
- 3d6-3 returns 0..15
-
- One weird note:
-
- The following is a legal specifier: "1d6+1d6+1d6". This is the same
- as "3d6" (rollDice() is invoked recursively).
-
- The following, too, is legal, but does not have the effect you might
- think:
-
- "1d6-1d6+1d6"
-
- You might think that this is the same as 2d6-1d6. In fact, because the
- adjustment factor is "1d6+1d6", and is a negative adjustment, the net
- effect is that "1d6-1d6+1d6" simplifies to "1d6-2d6". This is because
- the adjustment is first computed (recursively, if necessary), and then
- checked to see if it is negative.
-