Skip to content

Commit

Permalink
initial commit v.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkolesidis committed Sep 16, 2021
1 parent 52b07f7 commit d27fe79
Show file tree
Hide file tree
Showing 3 changed files with 173 additions and 0 deletions.
73 changes: 73 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@

, ,
\\ \\
) \\ \\ _p_
)^\))\)) / *\
\_|| || / /^\`-'
__ -\ \\--/ /
<' \\___/ ___. )'
\`====\ )___/\\
// \`"
\\ / \
\`" +========+
|Dragon's|
|Dice |
|Roller |
""""""""""
Version 1.0
Created by Michael Kolesidis
==========================================================

Dragon's Dice Roller aims to be a lightweight, simple,
reliable and easy-to-use dice roller for RPG games.


How to Use
==========
When the program starts, you are promted to enter the type
of dice you want to be rolled and how many times. You should
provide two integer numbers seperated by a space. The first
number corresponds to the type of dice and the second to the
number of dice to be rolled.

For instance, the input "6 3" will give you the result of the
D6 dice rolled three times (or three D6 dive rolled at the same
time).

After the result of the roll appears on screen, you can enter
two numbers again for the next roll.

You can exit the program by entering 0 as either the first or
the second number (or both).



Supported Types of Dice
=======================

Input Dice
4 D4
6 D6
8 D8
10 D10
12 D12
20 D20



Files Included
==============
>> dragons_dice_roller.c
Source file written in C.

>> dragons_dice_roller
Unix executable

>> README.txt
The readme file






Binary file added dragons_dice_roller
Binary file not shown.
100 changes: 100 additions & 0 deletions dragons_dice_roller.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
* Dragon's Dice Roller
*
* Version 1.0
*
* Created by Michael Kolesidis
*/

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

int logo()
{
printf("\n , ,\n");
printf(" \\\\ \\\\\n");
printf(" ) \\\\ \\\\ _p_\n");
printf(" )^\\))\\)) / *\\\n");
printf(" \\_|| || / /^\\`-\'\n");
printf(" __ -\\ \\\\--/ /\n");
printf(" <\' \\\\___/ ___. )\'\n");
printf(" \\`====\\ )___/\\\\\n");
printf(" // \\`\"\n");
printf(" \\\\ / \\\n");
printf(" \\`\" +========+\n");
printf(" |Dragon's|\n");
printf(" |Dice |\n");
printf(" |Roller |\n");
printf(" \"\"\"\"\"\"\"\"\"\"\n");
return 0;
}

int roll_dice(int type, int times)
{
int value;

if (type == 4 || type == 6 || type == 8 || type == 10 || type == 12 || type == 20)
{
printf("===== D%d - %d Times =====\n", type, times);
for (int i = 0; i < times; i++)
{
switch (type)
{
case 4:
value = rand() % 4 + 1;
printf("%d\n", value);
break;

case 6:
value = rand() % 6 + 1;
printf("%d\n", value);
break;

case 8:
value = rand() % 8 + 1;
printf("%d\n", value);
break;

case 10:
value = rand() % 10 + 1;
printf("%d\n", value);
break;

case 12:
value = rand() % 12 + 1;
printf("%d\n", value);
break;

case 20:
value = rand() % 20 + 1;
printf("%d\n", value);
break;
}
}
printf("========================\n\n\n");
}
else
{
printf("Dice type should be 4, 6, 8, 10, 12 or 20!\n\n\n");
}
return 0;
}

int main()
{
int type, times;
srand(time(NULL));
logo();

printf("Which dice should I roll for you and how many times?\n");
scanf("%d %d", &type, &times);

while (type != 0 || times != 0)
{
roll_dice(type, times);
scanf("%d %d", &type, &times);
}

return 0;
}

0 comments on commit d27fe79

Please sign in to comment.