Source: dice.h


Annotated List
Files
Globals
Hierarchy
Index
/***************************************************************************
              dice.h  -  random number functions for RPG applications
                             -------------------
    begin                : Sat Jan 22 2000
    copyright            : (C) 2000 by Daniel Roberge
    email                : droberge@uvic.ca
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the Lesser General Public License, published    *
 *   by the Free Software Foundation, Version 2 or later.   							 *
 *                                                                         *
 ***************************************************************************/

 #ifndef _DICE_H
 #define _DICE_H

 #include <stdlib.h>
 #include <time.h>

 /*--------------Random Number Functions--------------------------*/

 /**Returns a random number less than num*/
 int random(int num);
 /**Returns the result of 'rolling' coeff 'dice' with dno sides plus plus*/
 long dice(unsigned char coeff,unsigned char dno,short plus);
 bool compare(int,int,int,int);
 /**Returns a random number between 1 and 100*/
 int percentile(void);
 /**Returns the result of 'rolling' x standard cubic 'dice'*/
 int xd6(unsigned char x);
 /**Sets the random seed from the system clock*/
 void randomize(void);

 /*-------------------Dice Wrapper Class--------------------------*/

 /**Wraps the dice routines in a class.
   *@author Daniel Roberge
   */

 class Dice
 {
 	private:
 		unsigned char quantity, sides;
 		short modifier;
 	public:
 		/**Creates a set of 'null dice', which will always come up 0.*/
 		Dice();
 		/**Creates a set of dice from the specification in the args.*/
 		Dice(unsigned char number, unsigned char polygonNo, short bonus);
 		/**Creates a set of one die with the specified number of sides.*/
 		Dice(unsigned char polyNo);
 		
 		/**Sets the number of dice*/
 		void setNoDice(unsigned char newNo);
 		/**Sets the number of sides on the dice*/
 		void setSides(unsigned char newSides);
 		/**Sets the modifier on the roll*/
 		void setMod(short newMod);
 		
 		/**Gets the number of dice*/
 		int getNoDice();
 		/**Gets the number of sides on the dice*/
 		int getSides();
 		/**Gets the modifier on the roll*/
 		int getMod();
 		
 		/**Rolls the dice represented by this object*/
 		long roll();
 };

 /*---------------------------------------------------------------*/

 #endif

Generated by: droberge@magebook.localdomain on Mon Jul 3 13:20:08 200.