-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
executable file
·85 lines (83 loc) · 2.77 KB
/
Program.cs
File metadata and controls
executable file
·85 lines (83 loc) · 2.77 KB
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
using System;
using System.Linq;
namespace CandyLand
{
class Program
{
static void Main(string[] args)
{
Game game = new Game();
DisplayOptions(game);
char input = 'B';
while (input != 'Q')
{
input = Console.ReadLine().ToUpper().First();
if (input == 'R')
{
game = new Game();
}
if (input == 'A' && !game.IsStarted)
{
Console.WriteLine("Enter player name:");
var name = Console.ReadLine();
game.AddPlayer(name);
Console.WriteLine(game.Players.Count + " players ready!");
if (game.Players.Count >= 2 && game.Players.Count <= 4)
{
Console.WriteLine("Game can be started!");
}
}
if (input == 'S' && !game.IsStarted)
{
game.StartGame();
}
if (input == 'N' && game.IsStarted)
{
Console.WriteLine(game.NextMove());
}
if (input == 'K' && game.IsStarted)
{
Console.Write("How many turns would you like to skip?");
string numberTurns = Console.ReadLine();
int turns;
bool isInteger = int.TryParse(numberTurns, out turns);
if (isInteger)
{
while (turns > 0)
{
Console.WriteLine(game.NextMove());
turns--;
}
}
else
{
Console.WriteLine("Not an integer!");
}
}
if (input == 'C' && game.IsStarted)
{
while (!game.Players.Any(x => x.IsWinner))
{
Console.WriteLine(game.NextMove());
}
}
DisplayOptions(game);
}
}
static void DisplayOptions(Game game)
{
if (!game.IsStarted)
{
Console.WriteLine("A - Add Player");
Console.WriteLine("S - Start Game");
}
else if (!game.Players.Any(x => x.IsWinner))
{
Console.WriteLine("N - Next Turn");
Console.WriteLine("K - Skip Turns");
Console.WriteLine("C - Complete Game");
}
Console.WriteLine("R - Reset Game and Remove Players");
}
}
}