-
Notifications
You must be signed in to change notification settings - Fork 1
/
Game.cs
46 lines (42 loc) · 1.48 KB
/
Game.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
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using ReversiLab.AI;
using ReversiLab.Play;
namespace ReversiSharpClient
{
public class Game
{
//Singleton; there must be only one game at a time!
private static Game _game;
public string AuthCode { get; private set; }
public string BaseUrl { get; private set; }
public int Player { get; private set; }
public GameStatus Status { get; set; }
//The strategy which chooses our next move by some AI method
private readonly ReversiPlayer _reversiPlayer;
private Game()
{
_reversiPlayer = GameUtils.Player; //AI
Player = GameUtils.PlayerColor; //Color: Black or White
AuthCode = GameUtils.AuthCode; //Authentication code
BaseUrl = GameUtils.BaseUrl; //URL of the server
}
//~ ----------------------------------------------------------------------------------------------------------------
public static Game GetInstance()
{
if (_game != null)
{
return _game;
}
_game = new Game();
return _game;
}
//~ ----------------------------------------------------------------------------------------------------------------
public string GetNextMove()
{
return _reversiPlayer.GetNextMove(Status.ToGame());
}
}
}