Code smells
This commit is contained in:
@@ -20,7 +20,7 @@ namespace Gameboard.ShogiUI.BoardState
|
||||
private Vector2 player1King;
|
||||
private Vector2 player2King;
|
||||
public IReadOnlyDictionary<WhichPlayer, List<Piece>> Hands { get; }
|
||||
public Array2D<Piece> Board { get; }
|
||||
public PlanarCollection<Piece> Board { get; }
|
||||
public List<Move> MoveHistory { get; }
|
||||
public WhichPlayer WhoseTurn => MoveHistory.Count % 2 == 0 ? WhichPlayer.Player1 : WhichPlayer.Player2;
|
||||
public WhichPlayer? InCheck { get; private set; }
|
||||
@@ -28,7 +28,7 @@ namespace Gameboard.ShogiUI.BoardState
|
||||
|
||||
public ShogiBoard()
|
||||
{
|
||||
Board = new Array2D<Piece>(9, 9);
|
||||
Board = new PlanarCollection<Piece>(9, 9);
|
||||
MoveHistory = new List<Move>(20);
|
||||
Hands = new Dictionary<WhichPlayer, List<Piece>> {
|
||||
{ WhichPlayer.Player1, new List<Piece>()},
|
||||
@@ -54,7 +54,7 @@ namespace Gameboard.ShogiUI.BoardState
|
||||
|
||||
private ShogiBoard(ShogiBoard toCopy)
|
||||
{
|
||||
Board = new Array2D<Piece>(9, 9);
|
||||
Board = new PlanarCollection<Piece>(9, 9);
|
||||
for (var x = 0; x < 9; x++)
|
||||
for (var y = 0; y < 9; y++)
|
||||
Board[x, y] = toCopy.Board[x, y]?.DeepClone();
|
||||
@@ -213,40 +213,6 @@ namespace Gameboard.ShogiUI.BoardState
|
||||
return !isObstructed && isPathable;
|
||||
}
|
||||
|
||||
public void PrintStateAsAscii()
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
builder.Append(" Player 2");
|
||||
builder.AppendLine();
|
||||
for (var y = 8; y > -1; y--)
|
||||
{
|
||||
builder.Append("- ");
|
||||
for (var x = 0; x < 8; x++) builder.Append("- - ");
|
||||
builder.Append("- -");
|
||||
builder.AppendLine();
|
||||
builder.Append('|');
|
||||
for (var x = 0; x < 9; x++)
|
||||
{
|
||||
var piece = Board[x, y];
|
||||
if (piece == null)
|
||||
{
|
||||
builder.Append(" ");
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.AppendFormat("{0}", piece.ShortName);
|
||||
}
|
||||
builder.Append('|');
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
builder.Append("- ");
|
||||
for (var x = 0; x < 8; x++) builder.Append("- - ");
|
||||
builder.Append("- -");
|
||||
builder.AppendLine();
|
||||
builder.Append(" Player 1");
|
||||
Console.WriteLine(builder.ToString());
|
||||
}
|
||||
#region Rules Validation
|
||||
private bool EvaluateCheckAfterMove(Move move, WhichPlayer whichPlayer)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user