using Shogi.Domain.Pathing; using System.Collections.ObjectModel; namespace Shogi.Domain.ValueObjects; public record class Rook : Piece { public static readonly ReadOnlyCollection Player1Paths = new(new List(4) { new Path(Direction.Up, Distance.MultiStep), new Path(Direction.Left, Distance.MultiStep), new Path(Direction.Right, Distance.MultiStep), new Path(Direction.Down, Distance.MultiStep) }); private static readonly ReadOnlyCollection PromotedPlayer1Paths = new(new List(8) { new Path(Direction.Up, Distance.MultiStep), new Path(Direction.Left, Distance.MultiStep), new Path(Direction.Right, Distance.MultiStep), new Path(Direction.Down, Distance.MultiStep), new Path(Direction.UpLeft), new Path(Direction.UpRight), new Path(Direction.DownLeft), new Path(Direction.DownRight) }); public static readonly ReadOnlyCollection Player2Paths = Player1Paths .Select(m => m.Invert()) .ToList() .AsReadOnly(); public static readonly ReadOnlyCollection Player2PromotedPaths = PromotedPlayer1Paths .Select(m => m.Invert()) .ToList() .AsReadOnly(); public Rook(WhichPlayer owner, bool isPromoted = false) : base(WhichPiece.Rook, owner, isPromoted) { } public override ReadOnlyCollection MoveSet => Owner switch { WhichPlayer.Player1 => IsPromoted ? PromotedPlayer1Paths : Player1Paths, WhichPlayer.Player2 => IsPromoted ? Player2PromotedPaths : Player2Paths, _ => throw new NotImplementedException(), }; }