-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameStatus.cs
77 lines (70 loc) · 1.92 KB
/
GameStatus.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CincCamins
{
public class GameStatus
{
public PawnStatus[,] Pawns = new PawnStatus[5, 5];
public int PlayerBeatings;
public int OpponentBeatings;
public int Value;
public GameStatus(List<Pawn> gameStatus)
{
gameStatus.ForEach(p =>
{
Pawns[p.X, p.Y] = new PawnStatus
{
Number = p.Number,
Player = p.Player,
};
});
}
public GameStatus(GameStatus game)
{
PlayerBeatings = 0;
OpponentBeatings = 0;
Value = 0;
for (int x = 0; x < 5; x++)
{
for (int y = 0; y < 5; y++)
{
var p = game.Pawns[x, y];
if (p == null) continue;
Pawns[x, y] = new PawnStatus
{
Number = p.Number,
Player = p.Player,
};
}
}
}
public override string ToString()
{
var result = "";
for (int y = 0; y < 5; y++)
{
result += "[";
for (int x = 0; x < 5; x++)
{
if (Pawns[x, y] != null)
{
result += Pawns[x, y].Player ?
(x == 4 ? "P" : "P,"):
(x == 4 ? "O" : "O,");
}
else result += (x == 4 ? " " : " ,");
}
result += "]\n";
}
return result;
}
public class PawnStatus
{
public bool Player;
public int Number;
}
}
}