home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / pascal / rehack / text / rolldice.txt < prev    next >
Encoding:
Text File  |  1993-06-23  |  1.7 KB  |  52 lines

  1. ROLDIC.ZIP --
  2.  
  3. rollDice function:
  4.  
  5.    int rollDice( const char far *specifier );
  6.  
  7.    returns badRollValue (-32768 [0x8000]) if the specifier is invalid.
  8.  
  9.    The specifier string must contain a roll spec, whose format is:
  10.  
  11.         nDs
  12.  
  13.    n is the number of dice, D (or d) is a separator, and s is the size
  14.    of each die. For example:
  15.  
  16.         1d6     standard 6-side roll 1..6
  17.         1d100   percentile roll 1..100
  18.         3d6     D&D-style stat roll 3..18 in bell-shaped distribution
  19.  
  20.    Note: 0 is not acceptable for either n or s, and rollDice() returns
  21.    badRollValue if either is 0.
  22.  
  23.    The specifier may contain an adjustment value which is indicated by
  24.    either a + or - character, followed by the adjustor. The adjustor may 
  25.    either be a numeric constant, or another roll specifier. Examples:
  26.  
  27.         +10     add 10
  28.         -5      subtract 5
  29.         +1d4    add 1..4
  30.  
  31.    Complete specifier examples:
  32.  
  33.         3d6+4           returns 7..22 in a bell-shaped distribution
  34.         1d6+1d4         returns 2..10
  35.         3d6-3           returns 0..15
  36.  
  37.    One weird note:
  38.  
  39.    The following is a legal specifier: "1d6+1d6+1d6". This is the same
  40.    as "3d6" (rollDice() is invoked recursively). 
  41.  
  42.    The following, too, is legal, but does not have the effect you might 
  43.    think:
  44.  
  45.        "1d6-1d6+1d6"
  46.  
  47.    You might think that this is the same as 2d6-1d6. In fact, because the
  48.    adjustment factor is "1d6+1d6", and is a negative adjustment, the net
  49.    effect is that "1d6-1d6+1d6" simplifies to "1d6-2d6". This is because 
  50.    the adjustment is first computed (recursively, if necessary), and then
  51.    checked to see if it is negative.
  52.