-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
58 lines (50 loc) · 1.83 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
using System;
using KingsTableConsoleEdition.Interfaces;
namespace KingsTableConsoleEdition
{
class MainClass
{
static IOutput output;
static IInput input;
static Board board;
static IRules rules;
static IPlayer[] players;
public static void Main(string[] args)
{
output = new ConsoleOutput();
input = new ConsoleInput();
board = new Board();
rules = new MainRules();
board.MakeBoard(11);
players = GetPlayers();
bool preparedToStart = rules.PrepareNewGame(board, players);
if(preparedToStart)
{
output.PrintString(rules.GetIntro());
output.ShowBoard(board.GetBoard());
//main loop
while(rules.GameContinues())
{
int[][] move = input.GetMoveFromPlayer();
rules.ApplyMove(move);
output.ShowBoard(board.GetBoard());
}
}else{
output.PrintString("Program unable to prepare game, aborting.");
}
}
static IPlayer[] GetPlayers(){
IPlayer attacker = new HumanPlayer();
string prompt = "Please type the name of the Attacking player:";
attacker.SetName(input.GetStringFromPlayer(prompt));
IPlayer defender = new HumanPlayer();
prompt = "Please type the name of the Defending player:";
defender.SetName(input.GetStringFromPlayer(prompt));
//TODO: remove
Console.WriteLine("Attacker: " + attacker.GetName());
Console.WriteLine("Defender: " + defender.GetName());
IPlayer[] temp = { attacker, defender };
return temp;
}
}
}