Game Util: Roll any number of 6 sided dice (2003)

This commit is contained in:
kougyokugentou 2021-10-24 16:18:01 -07:00
parent 683dc10c85
commit ff415d0d93

53
demos/rd6.c Normal file
View File

@ -0,0 +1,53 @@
/* rd6 - Roll X number of 6 sided dice. Perfect for the board game Axis and Allies.
Copyright (C) 2003 Shaun Marquardt
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <time.h>
#include "random.h"
void main()
{
for(;;)
{
int number = 0, numdice = 0, count = 0, col = 0;
char tmp[3];
printf("\nHow many 6 sided dice do you wish to roll? ");
numdice = atoi(gets(tmp));
if( (numdice<1) || (numdice>100) )
{
printf("Please enter an number between 1 and 100.\n");
main();
}
seedrnd();
for(count=0;count<numdice;count++)
{
number = rnd(6)+1;
printf("%-2d", number);
if( (++col % 30) == 0) printf("\n\r");
}
} //end main for loop
}