-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
52b07f7
commit d27fe79
Showing
3 changed files
with
173 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, ×); | ||
|
||
while (type != 0 || times != 0) | ||
{ | ||
roll_dice(type, times); | ||
scanf("%d %d", &type, ×); | ||
} | ||
|
||
return 0; | ||
} |