-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMoveTurn.cs
53 lines (50 loc) · 1.65 KB
/
MoveTurn.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
using System;
namespace ShogiClient
{
/// <summary>
/// Contains data about a turn where the player moved their piece.
/// </summary>
public class MoveTurn : ITurn
{
public PieceData Piece { get; set; }
public bool DidPromote { get; set; }
public bool DidCheck { get; set; }
public int XFrom { get; set; }
public int YFrom { get; set; }
public int XTarget { get; set; }
public int YTarget { get; set; }
public PieceData Captured { get; set; }
public MoveTurn(PieceData piece, bool didCheck, bool didPromote, int xFrom, int yFrom, int xTarget, int yTarget, PieceData captured)
{
Piece = piece;
DidCheck = didCheck;
DidPromote = didPromote;
XFrom = xFrom;
YFrom = yFrom;
XTarget = xTarget;
YTarget = yTarget;
Captured = captured;
}
public string ToNotation()
=> $@"
{Utils.PieceToNotationChar(Piece)}
{(char)('A' + XFrom)}
{YFrom}
x
{(char)('A' + XTarget)}
{YTarget}
{(Captured != null
? $"*{Utils.PieceToNotationChar(Captured)}"
: string.Empty
)}
{(DidPromote
? "+"
: string.Empty
)}
{(DidCheck
? "#"
: string.Empty
)}
".Replace("\r", string.Empty).Replace("\n", string.Empty).Replace(" ", string.Empty).Replace("\t", string.Empty);
}
}