diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..f50d683 --- /dev/null +++ b/README.txt @@ -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 + + + + + + diff --git a/dragons_dice_roller b/dragons_dice_roller new file mode 100755 index 0000000..a4c8218 Binary files /dev/null and b/dragons_dice_roller differ diff --git a/dragons_dice_roller.c b/dragons_dice_roller.c new file mode 100644 index 0000000..9fdae62 --- /dev/null +++ b/dragons_dice_roller.c @@ -0,0 +1,100 @@ +/* + * Dragon's Dice Roller + * + * Version 1.0 + * + * Created by Michael Kolesidis + */ + +#include +#include +#include + +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; +} \ No newline at end of file