-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConsoleGame.cs
625 lines (537 loc) · 27.7 KB
/
ConsoleGame.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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Windows.Forms;
using System.Security.Cryptography.X509Certificates;
using MainGuiNamespace;
namespace Game
{
using MainGuiNamespace;
static class blackjack
{
public static void MainGame()
{
for (string newGame = "ja"; newGame == "ja";)
{
Random draw_Card = new Random();
Random first_Card = new Random();
int Hand_Value = 0;
int Ace_Count = 4;
int King_Count = 4;
int Queen_Count = 4;
int Jack_Count = 4;
int Ten_count = 4;
int Nine_Count = 4;
int Eight_Count = 4;
int Seven_Count = 4;
int Six_Count = 4;
int Five_Count = 4;
int Four_Count = 4;
int Three_Count = 4;
int Two_Count = 4;
int[] Card_Deck_Quantity = { -1, -1, Two_Count, Three_Count, Four_Count, Five_Count, Six_Count, Seven_Count, Eight_Count, Nine_Count, Ten_count, Jack_Count, Queen_Count, King_Count, Ace_Count };
string[] Card_Deck_Names = { "", "", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "jack", "queen", "king", "ace" };
Console.Clear();
//Console.WriteLine("Quantitiy of Card two is:" + Two_Count);
//Console.WriteLine(Card_Deck_Names[Card_Deck_Names.Length-1]);
Hand_Value = firstCard(Card_Deck_Names, Card_Deck_Quantity, first_Card, Hand_Value);
/*int test = 0;
while (test != 22) {
test = 0;
Hand_Value = 0;
for (int i = 2; i < Card_Deck_Quantity.Length;i++)
{
//ProgramWL(i + "", "Blue");
Card_Deck_Quantity[i] = 4;
}
test = firstCard(Card_Deck_Names, Card_Deck_Quantity, first_Card, Hand_Value);
if(test > 21) { ProgramWL(test+" über 21!","Red"); }
Console.WriteLine(test);
Thread.Sleep(20);
}*/
if (Hand_Value == 21) { Console.WriteLine(" Blackjack!","Green"); continue; }
for (string newCard = "ja"; newCard == "ja" && Hand_Value <= 21;)
{
Program.WL("\n Du hast " + Hand_Value + " auf der Hand.");
Program.WL(" Möchtest du eine weitere Karte ziehen?"); Program.WL(" <Ja> / <Nein>", "DarkCyan"); Program.W(" ");//Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine(" <Ja> / <Nein>"); Console.Write(" ");
newCard = Console.ReadLine().Trim().ToLower();
while (newCard != "ja" && newCard != "nein")
{
Program.WL("\n Ungültige Antwort! Bitte antworte mit <Ja> oder <Nein> !", "Red");
Program.W(" Möchtest du eine weitere Karte ziehen? ");
//Program.W(" ");
newCard = Console.ReadLine().Trim().ToLower();
Program.ClearLines(3);
}
if (newCard == "ja")
{
int DrawnCard = drawCard(Card_Deck_Names, Card_Deck_Quantity, first_Card, Hand_Value);
Program.WL(" Du hast eine " + DrawnCard + " gezogen!", "Green");
Hand_Value += DrawnCard;
}
}
if (Hand_Value > 21)
{
Program.WL(" Du hast Überzogen! Du hattest " + Hand_Value + " auf der Hand. Du verlierst!", "Red");
}
else if (Hand_Value <= 21)
{
Program.WL(" Du willst keine Karte mehr ziehen. Der Dealer zeigt dir jetzt sein Blatt.");
int dealer_Hand_Value = dealerDraw(Card_Deck_Names, Card_Deck_Quantity, first_Card, draw_Card, Hand_Value);
if (dealer_Hand_Value > 21) Program.WL(" Der Dealer hat mit " + dealer_Hand_Value + " überzogen! Du gewinnst!","Green");
else if (dealer_Hand_Value < Hand_Value) Program.WL(" Du hast eine höhere Hand als der Dealer! Der Dealer hat nur " + dealer_Hand_Value + " auf der Hand. Du gewinnst!","Green");
else if (dealer_Hand_Value == Hand_Value) Program.WL(" Deine Hand hat den gleichen Wert wie die des Dealers. Ihr hattet beide " + dealer_Hand_Value + " auf der Hand. Es ist unentschieden!","Yellow");
else Program.WL(" Der Dealer hat mit " + dealer_Hand_Value + " eine höhere Hand als du mit " + Hand_Value + ". Du verlierst!","Red");
}
Thread.Sleep(700);
Program.WL("\n Möchtest du erneut spielen?"); Program.W(" ");
newGame = Console.ReadLine().Trim().ToLower(); // ".Trim()" removes spaces before and afer the input, ".ToLower()" puts the input into lowercase letters.
while (newGame != "ja" && newGame != "nein")
{
Program.WL("\n Ungültige Antwort! Bitte antworte mit <Ja> oder <Nein> !", "Red");
Program.W(" Möchtest du erneut spielen? ");
newGame = Console.ReadLine().Trim().ToLower();
Program.ClearLines(3);
}
//Console.ReadKey();
//ResetArrays and Variables here
//Hand_Return_Value = 0;
}
}
static int firstCard(string[] Card_Deck_Names, int[] Card_Deck_Quantity, Random first_Card, int Hand_Value)
{
int Hand_Return_Value = 0;
//Hand_Value = 0;
for (int i = 0; i < 2; i++)
{
int Card_Index = first_Card.Next(2, Card_Deck_Names.Length);
while (Card_Deck_Quantity[Card_Index] <= 0)
{
Card_Index = first_Card.Next(2, Card_Deck_Names.Length);
//Console.WriteLine("Redraw:" + Card_Index + " with Quantity of:" + Card_Deck_Quantity[Card_Index]);
}
string Card_Name = Card_Deck_Names[Card_Index];
//ProgramWL("" + Hand_Value, "Green");
if (Card_Index == 11 || Card_Index == 12 || Card_Index == 13) { Hand_Return_Value += 10; Hand_Value += 10; }
else if (Card_Index == 14 && Hand_Value < 11) { Hand_Return_Value += 11; Hand_Value += 11; }
else if (Card_Index == 14 && Hand_Value >= 11) { Hand_Return_Value += 1; Hand_Value += 1; }
else Hand_Return_Value += Card_Index; Hand_Value += Card_Index;
Card_Deck_Quantity[Card_Index]--;
//Hand_Value = 0;
}
return Hand_Return_Value;
}
static int drawCard(string[] Card_Deck_Names, int[] Card_Deck_Quantity, Random draw_Card, int Hand_Value)
{
int Hand_Return_Value = 0;
int Card_Index = draw_Card.Next(2, Card_Deck_Names.Length);
while (Card_Deck_Quantity[Card_Index] <= 0)
{
Card_Index = draw_Card.Next(2, Card_Deck_Names.Length);
//Console.WriteLine("drawCard Redraw");
}
string Card_Name = Card_Deck_Names[Card_Index];
//ProgramWL("" + Hand_Value, "Green");
if (Card_Index == 11 || Card_Index == 12 || Card_Index == 13) { Hand_Return_Value += 10; Hand_Value += 10; } //{ Hand_Return_Value += 10; Console.WriteLine("+10"); }
else if (Card_Index == 14 && Hand_Value >= 11) { Hand_Return_Value += 1; Hand_Value += 1; }//{ Hand_Return_Value += 1; Console.WriteLine("+1"); }
else if (Card_Index == 14 && Hand_Value < 11) { Hand_Return_Value += 11; Hand_Value += 11; } //{ Hand_Return_Value += 11; Console.WriteLine("+11"); }
//ProgramWL("" + Card_Index, "Green");
else Hand_Return_Value += Card_Index; Hand_Value += Card_Index; //Console.WriteLine("hey");
Card_Deck_Quantity[Card_Index]--;
/*Console.ForegroundColor = ConsoleColor.Red;
ProgramWL("" + Hand_Return_Value, "Red");
Console.ForegroundColor = ConsoleColor.White;
//Console.WriteLine(Card_Deck_Quantity[Card_Index]);*/
return Hand_Return_Value;
}
static int dealerDraw(string[] Card_Deck_Names, int[] Card_Deck_Quantity, Random first_Card, Random draw_Card, int Hand_Value)
{
int dealer_Hand_Value = firstCard(Card_Deck_Names, Card_Deck_Quantity, first_Card, Hand_Value);
//Console.WriteLine(dealer_Hand_Value);
while (dealer_Hand_Value < 17)
{
//Console.WriteLine("dealerDraw");
dealer_Hand_Value += drawCard(Card_Deck_Names, Card_Deck_Quantity, draw_Card, Hand_Value);
//Console.WriteLine(dealer_Hand_Value);
}
return dealer_Hand_Value;
}
/*static void ProgramWL(string WriteLineText, string TextColor = null, string SpaceAfterPrinting = null, string TypeOfPrinting = null, string NewTextColor = null)
{
ConsoleColor OriginalColor = Console.ForegroundColor;
ConsoleColor TestColor;
if (TextColor != null && Enum.TryParse(TextColor, out TestColor))
{
Console.ForegroundColor = TestColor;
}
if (TypeOfPrinting == null || TypeOfPrinting == "WriteLine") Console.WriteLine(WriteLineText);
else Console.Write(WriteLineText);
if (NewTextColor != null && Enum.TryParse(NewTextColor, out TestColor))
{
Console.ForegroundColor = TestColor;
}
else Console.ForegroundColor = OriginalColor;
if (SpaceAfterPrinting != null) Console.Write(SpaceAfterPrinting);
}*/
public static void InitializeCards()
{
}
}
static class guessnumbers
{
public static void MainGame()
{
Console.Clear();
for (string newGame = "ja"; newGame == "ja";)
{
Program.WL("\n Das Spiel funktioniert so: Du bestimmst den Abstand der Zahlen und rätst dann eine Zahl dazwischen.");
Program.W(" Niedrigste Zahl: ");
string firstNumberString = Console.ReadLine();
float firstNumberFloat = Program.WhileNotNumber(firstNumberString);
Program.W(" Höchste Zahl: ");
string secondNumberString = Console.ReadLine();
float secondNumberFloat = Program.WhileNotNumber(secondNumberString);
Program.W(" Rate nun eine Zahl zwischen der höchsten und der niedrigsten Zahl:");
string guessedNumberString = Console.ReadLine();
float guessedNumberFloat = Program.WhileNotNumber(guessedNumberString);
//int guessedNumberFloat = Convert.ToInt32(Program.WhileNotNumber(guessedNumberString));
while (firstNumberFloat > secondNumberFloat || firstNumberFloat < 0 || secondNumberFloat < 0 || guessedNumberFloat < firstNumberFloat || guessedNumberFloat > secondNumberFloat)
{
Console.Clear();
Program.WL(" Deine erste Zahl muss kleiner sein als die Zweite!\n Denke daran, dass beide Zahlen nicht kleiner als null sein dürfen!");
Program.W(" Gib deine erste Zahl erneut ein: ");
firstNumberString = Console.ReadLine();
firstNumberFloat = Program.WhileNotNumber(firstNumberString);
Program.W(" Gib deine zweite Zahl erneut ein: ");
secondNumberString = Console.ReadLine();
secondNumberFloat = Program.WhileNotNumber(secondNumberString);
Program.W(" Wähle deine Zahl zwischen der höchsten und der niedrigsten Zahl erneut: ");
guessedNumberString = Console.ReadLine();
guessedNumberFloat = Program.WhileNotNumber(guessedNumberString);
}
Random randomOne = new Random();
double randomNumber = randomOne.NextDouble(firstNumberFloat, secondNumberFloat);
randomNumber = Math.Round(randomNumber, 0);
double probability = 100 / (secondNumberFloat - firstNumberFloat + 1);
probability = Math.Round(probability, 1);
if (guessedNumberFloat == randomNumber)
{
Program.WL("\n Super! Die zufällige Zahl war " + randomNumber + " und du hast sie erraten!\n Deine Change lag bei " + probability + " %!", "DarkCyan");
}
else
{
Program.WL("\n Schade! Die zufällige Zahl war " + randomNumber + " aber du hast auf " + guessedNumberFloat + " getippt...\n Nächstes mal liegst du bestimmt richtig!\n Deine Change lag bei " + probability + " %!", "Red");
}
Thread.Sleep(700);
Program.WL(" Möchtest du erneut spielen?");
newGame = Console.ReadLine().Trim().ToLower(); // ".Trim()" removes spaces before and afer the input, ".ToLower()" puts the input into lowercase letters.
while (newGame != "ja" && newGame != "nein")
{
Program.WL("\n Ungültige Antwort! Bitte antworte mit <Ja> oder <Nein> !", "Red");
Program.W(" Möchtest du erneut spielen? ");
newGame = Console.ReadLine().Trim().ToLower();
Program.ClearLines(3);
}
Console.Clear();
}
}
}
static class rolldice
{
public static void MainGame()
{
//int StreakRolldice = 0;
for (string newGame = "ja"; newGame == "ja";)
{
Console.Clear();
Program.WL("\n Zwei Würfel werden auf einmal gewürfelt.\n Wenn du zwei gleiche Zahlen würfelst, gewinnst du!");
Program.WL(" Drücke <Enter> um zu würfeln!\n ");
Random randomOne = new Random();
int diceOne = 0;
int diceTwo = 1;
int attempts = 0;
for (; diceOne != diceTwo; attempts++)
{
while (Console.ReadKey().Key != ConsoleKey.Enter)
{
//Program.ClearLines(0);
}
Program.ClearLines(0);
//Console.ReadKey();
diceOne = randomOne.Next(1, 7);
diceTwo = randomOne.Next(1, 7);
/*ProgramWL(" Du hast eine ", "", "", "Write");
ProgramWL("" + diceOne, "Red", "", "Write");
ProgramWL(" und eine ", "", "", "Write");
ProgramWL("" + diceTwo, "Red", "", "Write");
ProgramWL(" gewürfelt!", "", "", "Write");
Program.W(diceOne + "§Red", "Blue");*/
Program.ColorParts(" Du hast eine ", diceOne + "§Red", " und eine ", diceTwo + "§Red", " gewürfelt!");
}
if (attempts != 1)
{
/*ProgramWL("\n Du hast zwei ", "", "", "Write");
ProgramWL(diceOne + "en", "DarkCyan", "", "Write");
ProgramWL(" gewürfelt!", "", "", "Write");
ProgramWL(" Du hast ", "", "", "Write");
ProgramWL("" + attempts, "DarkCyan", "", "Write");
ProgramWL(" Würfe gebraucht!\n\n", "", "", "Write");
ProgramWL(" Deine Chance lag bei ungefähr ", "", "", "Write");
ProgramWL("16,667%", "DarkCyan", "", "Write");
ProgramWL("!\n", "", "", "Write");*/
Program.ColorParts(" Du hast zwei ", diceOne + "en§DarkCyan", " gewürfelt! ", "Du hast ", attempts + "§DarkCyan", " Würfe gebraucht!\n");
Program.ColorParts(" Deine Chance lag bei ungefähr ", "16,667%§DarkCyan", "!\n");
}
else
{
/*ProgramWL("\n Du hast zwei ", "", "", "Write");
ProgramWL("" + diceOne, "DarkCyan", "", "Write");
ProgramWL(" gewürfelt! Du hast ", "", "", "Write");
ProgramWL("einen", "DarkCyan", "", "Write");
ProgramWL(" Wurf gebraucht!\n", "", "", "Write");*/
Program.ColorParts(" Du hast zwei ", diceOne + "en§DarkCyan", " gewürfelt! ", "Du hast ", "einen§DarkCyan", " Wurf gebraucht!\n");
Program.ColorParts(" Deine Chance lag bei ungefähr ", "16,667%§DarkCyan", "!\n");
}
Thread.Sleep(700);
Program.WL(" Möchtest du erneut spielen?");
Program.W(" ");
newGame = Console.ReadLine().Trim().ToLower(); // ".Trim()" removes spaces before and afer the input, ".ToLower()" puts the input into lowercase letters.
while (newGame != "ja" && newGame != "nein")
{
Program.WL("\n Ungültige Antwort! Bitte antworte mit <Ja> oder <Nein> !", "Red");
Program.W(" Möchtest du erneut spielen? ");
newGame = Console.ReadLine().Trim().ToLower();
Program.ClearLines(3);
}
Console.Clear();
}
}
}
public static class RandomExtensions
{
public static double NextDouble(this Random random, double minValue, double maxValue)
{
return random.NextDouble() * (maxValue - minValue) + minValue;
}
}
}
namespace MainGuiNamespace
{
public static class Program
{
public static void WL(string WriteLineText, string TextColor = null, string NewTextColor = null)
{
ConsoleColor OriginalColor = Console.ForegroundColor;
ConsoleColor TestColor;
if (TextColor != null && Enum.TryParse(TextColor, out TestColor))
{
Console.ForegroundColor = TestColor;
}
Console.WriteLine(WriteLineText);
if (NewTextColor != null && Enum.TryParse(NewTextColor, out TestColor))
{
Console.ForegroundColor = TestColor;
}
else Console.ForegroundColor = OriginalColor;
}
public static void W(string WriteLineText, string TextColor = null, string SpaceAfterPrinting = null, string TypeOfPrinting = null, string NewTextColor = null)
{
ConsoleColor OriginalColor = Console.ForegroundColor;
ConsoleColor TestColor;
if (TextColor != null && Enum.TryParse(TextColor, out TestColor))
{
Console.ForegroundColor = TestColor;
}
Console.Write(WriteLineText);
if (NewTextColor != null && Enum.TryParse(NewTextColor, out TestColor))
{
Console.ForegroundColor = TestColor;
}
else Console.ForegroundColor = OriginalColor;
}
public static void ColorParts(params string[] Texts)
{
foreach (string SingleText in Texts)
{
char ch = '§';
int freq = SingleText.Split(ch).Length - 1;
if (freq == 0)
{
Program.W(SingleText);
}
else
{
string[] OutText =
{
SingleText.Substring(0,SingleText.LastIndexOf(ch)),
SingleText.Substring(SingleText.LastIndexOf(ch))
};
//OutText[1] = Regex.Replace("He\"ll,o Wo'r.ld", "[@,\\.\";'\\\\]", string.Empty);
OutText[1] = OutText[1].Replace(Convert.ToString(ch), "");
Program.W(OutText[0] + "", "" + OutText[1]);
OutText[0] = "";
OutText[1] = "";
}
//Console.WriteLine("[0]:" + OutText[0] + "\n[1]:" + OutText[1]);
}
}
public static void UserInput()//string Text = null)
{
ConsoleColor OriginalColor = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Yellow;
//Program.W(" "); //puts tab in front of user input
while (Console.Read() != (int)ConsoleKey.Enter)
{
//nothing
}
//if(Text != null) Program.WL(Text);
Console.ForegroundColor = OriginalColor;
//Console.ReadLine();
}
public static string WhileInputInvalid(string Input)
{
while (Input.Trim().ToLower() != "ja" && Input.Trim().ToLower() != "nein")
{
Program.WL("Ungültige Eingabe! Bitte antworte mit " + "Ja" + " oder" + " Nein!:", "Red");
//Program.UserInput();
Input = Convert.ToString(Console.ReadLine());
}
return Input;
}
public static bool IsAllDigits(string s)
{
if (s == "") return false;
foreach (char c in s)
{
if (!char.IsDigit(c))
return false;
}
return true;
}
public static float WhileNotNumber(string Input)
{
while (Program.IsAllDigits(Input) == false)
{
//float firstNumberFloat = Convert.ToSingle(firstNumberString);
Program.WL(" Bitte gib eine gültige, ganze Zahl ein!");
Input = Console.ReadLine();
}
return Convert.ToSingle(Input);
}
public static void ClearLines(int NumberOfLines)
{
int currentLineCursorStart = Console.CursorTop;
if (Console.CursorTop >= NumberOfLines)
{
for (int LineNumber = 0; LineNumber <= NumberOfLines; LineNumber++)
{
int currentLineCursor = Console.CursorTop;
Console.SetCursorPosition(0, Console.CursorTop - LineNumber);
Console.Write(new string(' ', Console.WindowWidth));
Console.SetCursorPosition(0, currentLineCursor);
}
Console.SetCursorPosition(0, currentLineCursorStart - NumberOfLines);
}
else throw new ApplicationException("Can't clear more lines than available!");
}
}
class MainUi
{
static int ChooseGame(string[] GameNames)
{
Program.WL("\n Es gibt " + (GameNames.Length-1) + " verschiedene Spiele für dich zur Auswahl.\n Was möchtest du spielen?");
for (int loopVar = 1; loopVar < GameNames.Length; loopVar++)
{
Program.WL(" " + loopVar + ". " + GameNames[loopVar], "Yellow");
}
Program.W(" Antworte mit der Zahl oder dem Namen des gewünschten Spiels: ");
//Program.UserInput();
int tempVar = 0;
for (bool ValidGame = true; ValidGame == true;)
{
string TempChosenGame = Console.ReadLine();
if(tempVar == 0)
{
tempVar = 1;
}
else
{
Program.ClearLines(2);
}
if (Program.IsAllDigits(TempChosenGame) == true)
{
int ChosenGameInt = Convert.ToInt32(TempChosenGame);
if (ChosenGameInt > 0 && ChosenGameInt < GameNames.Length)
{
ValidGame = true;
return ChosenGameInt;
}
}
else if (Program.IsAllDigits(TempChosenGame) == false)
{
string ChosenGameString = TempChosenGame;
int i = 0;
for (string Game = GameNames[0]; Game.Trim().ToLower() != ChosenGameString.ToLower().Trim() && i < GameNames.Length; i++)
{
if (ChosenGameString.Trim().ToLower() == GameNames[i].Trim().ToLower())
{
ValidGame = true;
return i;
}
}
}
Program.W("\n Ungültige Eingabe! Bitte gib erneut ein: ", "Red");
}
return -1;
}
public static void Main()
{
/*Program.WL("Was ist dein Name?");
Program.UserInput();
string name = Convert.ToString(Console.ReadLine());
Program.WL("Wie alt bist du?");
string age = Convert.ToString(Console.ReadLine());
Program.WL("Du heißt also " + name + " und bist " + age + " Jahre alt?");
string ageAndNameCorrect = Console.ReadLine();
Console.ForegroundColor = ConsoleColor.Green;
ageAndNameCorrect = Program.WhileInputInvalid(ageAndNameCorrect);
while (ageAndNameCorrect.Trim().ToLower() == "nein")
{
Console.Clear();
Program.WL("\nGib deinen Namen erneut ein: ", "", "ConsoleWrite");
name = Convert.ToString(Console.ReadLine());
Program.WL("Gib dein Alter erneut ein: ", "", "ConsoleWrite");
age = Convert.ToString(Console.ReadLine());
Program.WL("Du heißt also " + name + " und bist " + age + " Jahre alt?");
ageAndNameCorrect = Console.ReadLine();
}
*/
string[] GameNames = { "", "Blackjack", "Zahlen raten", "Pasch würfeln" };
Action[] MainGames = { Game.blackjack.MainGame, Game.guessnumbers.MainGame, Game.rolldice.MainGame };
Thread.Sleep(100);
Program.W("\n Willkommen!");
Thread.Sleep(100);
for (string newGame = "ja"; newGame == "ja";)
{
MainGames[MainUi.ChooseGame(GameNames) - 1]();
Console.Clear();
Program.WL("\n Möchtest du etwas Anderes spielen?");
Program.WL(" Ja / Nein", "DarkCyan");
Program.W(" ");
newGame = Console.ReadLine().Trim().ToLower();
while (newGame != "ja" && newGame != "nein")
{
Program.WL("\n Ungültige Antwort! Bitte antworte mit <Ja> oder <Nein> !", "Red");
Program.W(" Möchtest du etwas Anderes spielen? ");
newGame = Console.ReadLine().Trim().ToLower();
Program.ClearLines(3);
}
Console.Clear();
}
//Console.ReadLine();
}
}
}