-
Notifications
You must be signed in to change notification settings - Fork 1
/
Program.cs
193 lines (155 loc) · 6.31 KB
/
Program.cs
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
using System;
using System.Collections.Generic;
namespace Heist
{
class Program
{
static void Main()
{
bool replayHeist = true;
while (replayHeist)
{
Console.WriteLine("Plan your heist!");
bool isAddingMembers = true;
List<Member> AllMembers = new List<Member>();
Console.Write("Set the bank's difficulty level: ");
int DifficultyInput = 100;
try
{
DifficultyInput = int.Parse(Console.ReadLine());
}
catch (FormatException)
{
Console.WriteLine("Invalid input, the difficulty level default value will be 100.");
}
while (isAddingMembers)
{
Console.Write("Enter a team member's name: ");
string MemberName = Console.ReadLine();
if (string.IsNullOrWhiteSpace(MemberName))
{
isAddingMembers = false;
break;
}
Console.Write("What is the team member's skill level? ");
int Skill = 10;
try
{
Skill = int.Parse(Console.ReadLine());
}
catch (FormatException)
{
Console.WriteLine("Invalid input, the skill level default value will be 10.");
}
Console.Write("What is the team member's courage level? ");
double Courage = 5.0;
try
{
Courage = double.Parse(Console.ReadLine());
}
catch (FormatException)
{
Console.WriteLine("Invalid input, the courage level default value will be 5.0");
}
Member varMember = new Member(MemberName, Skill, Courage);
AllMembers.Add(varMember);
}
Console.WriteLine("How many trial runs? ");
int trialRuns = 5;
try
{
trialRuns = int.Parse(Console.ReadLine());
}
catch (FormatException)
{
Console.WriteLine("Invalid input, the default number of trial runs will be 5.");
}
int BankDiffLevel = DifficultyInput;
int WholeTeamSkillLevel = 0;
int SuccessfulTrials = 0;
int FailedTrials = 0;
for (int x = trialRuns; x > 0; x--)
{
WholeTeamSkillLevel = 0;
BankDiffLevel = DifficultyInput;
foreach (var member in AllMembers)
{
WholeTeamSkillLevel += member.SkillLevel;
}
int luck = new Random().Next(-10, 11);
Console.WriteLine();
BankDiffLevel += luck;
Console.WriteLine($"The team's combined skill level is {WholeTeamSkillLevel}");
Console.WriteLine($"The team's bank difficulty level is {BankDiffLevel}");
foreach (var member in AllMembers)
{
if (member.Courage < 5.0)
{
Console.WriteLine($"{member.Name} doesn't seem courageous enough for this job.");
}
}
if (WholeTeamSkillLevel >= BankDiffLevel)
{
Console.WriteLine("Trial succeeded");
SuccessfulTrials++;
}
else
{
Console.WriteLine("Trial failed");
FailedTrials++;
}
}
Console.WriteLine();
Console.WriteLine($"You had {SuccessfulTrials} successes, and {FailedTrials} failures.");
Console.WriteLine($"Your chances of success are {SuccessfulTrials * 100 / (SuccessfulTrials + FailedTrials)}% as long as no one gets caught.");
Console.WriteLine();
Console.WriteLine("You have seen the trial runs. Would you like to try the real thing? (Y/N)");
string doRealHeist = Console.ReadLine().ToLower();
if (doRealHeist == "y")
{
WholeTeamSkillLevel = 0;
BankDiffLevel = DifficultyInput;
foreach (var member in AllMembers)
{
if (member.Courage < 5.0)
{
Console.WriteLine($"{member.Name} was caught.");
member.SkillLevel = 0;
}
}
foreach (var member in AllMembers)
{
WholeTeamSkillLevel += member.SkillLevel;
}
int luck = new Random().Next(-10, 11);
Console.WriteLine();
BankDiffLevel += luck;
if (WholeTeamSkillLevel >= BankDiffLevel)
{
Console.WriteLine("Your Heist Was A Success!");
}
else
{
Console.WriteLine("You're going to prison");
}
}
else
{
Console.WriteLine("You backed out of the heist...");
}
Console.WriteLine("Would you like to play again? (Y/N): ");
string replayAnswer = Console.ReadLine().ToLower();
if (replayAnswer == "y")
{
Console.Clear();
Console.WriteLine("Restarting");
}
else
{
Console.WriteLine("Thanks for playing!");
Environment.Exit(0);
}
}
}
}
}