-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.cpp
87 lines (66 loc) · 3.48 KB
/
test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include <iostream>
#include <random>
#include "DiceRoll.hpp"
int main()
{
std::random_device rd; //Static random seed
std::mt19937 mt(rd()); //Static random number generator engine (mt19937) seeded with std::random_device
const int MOD_INTELLIGENCE = -1;
const int PROFICIENCY = 2;
const int INIT = 3;
int rolls;
DiceRoll attack_rayOfFrost{20,1,MOD_INTELLIGENCE + PROFICIENCY};
DiceRoll damage_rayOfFrost{8,2};
DiceRoll damage_sneak;
DiceRoll d8{8};
std::cout << "This is a test of the DiceRoll struct\n";
std::cout << "The die d8 has " << d8.m_sides << " sides.\n";
std::cout << "The die d8 has " << d8.m_number << " dice.\n";
std::cout << "The die d8 has " << d8.m_modifier << " modifiers.\n";
std::cout << "The initial roll of d8 is " << roll_dice(mt, d8);
std::cout << "\n-----------------------------------------\n";
std::cout << "The die damage_sneak has " << damage_sneak.m_sides << " sides.\n";
std::cout << "The die damage_sneak has " << damage_sneak.m_number << " dice.\n";
std::cout << "The die damage_sneak has " << damage_sneak.m_modifier << " modifiers.\n";
std::cout << "The initial roll of damage_sneak is " << roll_dice(mt, damage_sneak);
std::cout << "\n-----------------------------------------\n";
std::cout << "The die damage_rayOfFrost has " << damage_rayOfFrost.m_sides << " sides.\n";
std::cout << "The die damage_rayOfFrost has " << damage_rayOfFrost.m_number << " dice.\n";
std::cout << "The die damage_rayOfFrost has " << damage_rayOfFrost.m_modifier << " modifiers.\n";
std::cout << "The initial roll of damage_rayOfFrost is " << roll_dice(mt, damage_rayOfFrost);
std::cout << "\n-----------------------------------------\n";
std::cout << "The die attack_rayOfFrost has " << attack_rayOfFrost.m_sides << " sides.\n";
std::cout << "The die attack_rayOfFrost has " << attack_rayOfFrost.m_number << " dice.\n";
std::cout << "The die attack_rayOfFrost has " << attack_rayOfFrost.m_modifier << " modifiers.\n";
std::cout << "The initial roll of attack_rayOfFrost is " << roll_dice(mt, attack_rayOfFrost);
std::cout << "\n-----------------------------------------\n";
std::cout << "How many times would you like to roll a normal 1d6 die?\n";
std::cin >> rolls;
for(int i = 0; i < rolls; i++)
{
std::cout << "Roll #" << i+1 << " = " << roll_die(mt, 6) << std::endl;
}
std::cout << "How many times would you like to roll the damage_rayOfFrost dice?\n";
std::cin >> rolls;
for(int i = 0; i < rolls; i++)
{
std::cout << "Roll #" << i+1 << " = " << roll_dice(mt, damage_rayOfFrost) << std::endl;
}
std::cout << "\n\nSimulating DnD Combat now...\n";
std::cout << "Attemping to attack with Ray of Frost spell\n";
int initiative = roll_dice(mt, attack_rayOfFrost);
while(initiative <= 15)
{
std::cout << "You rolled a " << initiative << " so the attack did not land.\nRerolling...\n";
initiative = roll_dice(mt, attack_rayOfFrost);
}
std::cout << "The attack landed with a roll of " << initiative << "!\n";
std::cout << "Calculating damage...\n";
std::cout << roll_dice(mt, damage_rayOfFrost) << " points of damage were dealt!\n\n";
DiceRoll badSides{-1};
DiceRoll badNum{6,-2};
//std::cout << "Rolling die with -1 sides...\n";
//int bad1 = roll_dice(mt, badSides);
std::cout << "Rolling -2 number of dice...\n";
int bad2 = roll_dice(mt, badNum);
}