roll_MdN.c

skylib_fluffos_v3/mudlib/secure/simul_efun/roll_MdN.c · 518 B

From the archive skylib_fluffos_v3.zip

Download the archive   « Back to the archive contents

#if !efun_defined(roll_MdN)
/**
 * This method rolls a bunch of dice to get a nice weighted medium.
 * @param dice the number of dice to roll
 * @param sides the number of sides each dice has
 * @return the total of the rolls
 * @see efun::random()
 * @see shuffle()
 * @example
 * roll_MdN(3, 6);
 * roll_MdN(1, 20);
 */
int roll_MdN( int dice, int sides ) {
    int roll;

    if( dice > 0 && sides > 0 )
        while( dice-- )
            roll += 1 + random( sides );

    return roll;

} /* roll_MdN() */
#endif

Site Stats

Snippets: 1791
Codebases: 571