This commit is contained in:
2024-10-11 11:10:38 -05:00
parent 81dd267290
commit f75553a0ad
14 changed files with 616 additions and 514 deletions

View File

@@ -1,27 +1,30 @@
using Shogi.Domain.YetToBeAssimilatedIntoDDD.Pathing;
using System.Collections.ObjectModel;
namespace Shogi.Domain.ValueObjects
namespace Shogi.Domain.ValueObjects;
internal record class King : Piece
{
internal record class King : Piece
{
internal static readonly ReadOnlyCollection<Path> KingPaths = new(new List<Path>(8)
{
new Path(Direction.Forward),
new Path(Direction.Left),
new Path(Direction.Right),
new Path(Direction.Backward),
new Path(Direction.ForwardLeft),
new Path(Direction.ForwardRight),
new Path(Direction.BackwardLeft),
new Path(Direction.BackwardRight)
});
private static readonly ReadOnlyCollection<Path> Player1Paths = new(
[
new Path(Direction.Forward),
new Path(Direction.Left),
new Path(Direction.Right),
new Path(Direction.Backward),
new Path(Direction.ForwardLeft),
new Path(Direction.ForwardRight),
new Path(Direction.BackwardLeft),
new Path(Direction.BackwardRight)
]);
private static readonly ReadOnlyCollection<Path> Player2Paths = Player1Paths.Select(p => p.Invert()).ToList().AsReadOnly();
public King(WhichPlayer owner, bool isPromoted = false)
: base(WhichPiece.King, owner, isPromoted)
{
}
public override IEnumerable<Path> MoveSet => Owner == WhichPlayer.Player1 ? Player1Paths : Player2Paths;
public King(WhichPlayer owner, bool isPromoted = false)
: base(WhichPiece.King, owner, isPromoted)
{
}
public override IEnumerable<Path> MoveSet => KingPaths;
}
}