diff --git a/Shogi.Domain/Pieces/Piece.cs b/Shogi.Domain/Pieces/Piece.cs index 6a54cfe..f2e8076 100644 --- a/Shogi.Domain/Pieces/Piece.cs +++ b/Shogi.Domain/Pieces/Piece.cs @@ -81,5 +81,15 @@ namespace Shogi.Domain.Pieces return Array.Empty(); } + + /// + /// Get all positions this piece could move to from the currentPosition, respecting the move-set of this piece. + /// + /// + /// A list of positions the piece could move to. + public IEnumerable GetPossiblePositions(Vector2 currentPosition) + { + throw new NotImplementedException(); + } } } diff --git a/Shogi.Domain/StandardRules.cs b/Shogi.Domain/StandardRules.cs index 3352424..51d9bf8 100644 --- a/Shogi.Domain/StandardRules.cs +++ b/Shogi.Domain/StandardRules.cs @@ -1,4 +1,5 @@ -using BoardTile = System.Collections.Generic.KeyValuePair; +using Shogi.Domain.Pathing; +using BoardTile = System.Collections.Generic.KeyValuePair; namespace Shogi.Domain { @@ -206,27 +207,34 @@ namespace Shogi.Domain .Where(tile => PieceHasLineOfSight(tile, threatBlockingPosition)) .ToList(); - if (tilesThatCouldBlockTheThreat.Any()) + if (tilesThatDoBlockThreat.Any()) { return false; // Cannot be check-mate if a piece can intercept the threat. } } - //var line = Vector2.Subtract(kingPosition, threat.Position); - //var slope = line.Y / line.X; - //foreach (var tile in tilesThatCouldBlockTheThreat) - //{ - // // y = mx + b; slope intercept - // // b = -mx + y; - // var b = -slope * tile.Position.X + tile.Position.Y; - // //if (tile.Position.Y = slope * tile.Position.X + ) - //} + } + else + { + /* + * If no ability to block the check, maybe the king can evade check by moving. + */ + + + // TODO: Implement this in the Piece class instead. + var possibleSafePositions = new[] + { + Direction.Up, Direction.Down, Direction.Left, Direction.Right, Direction.UpLeft, Direction.UpRight, Direction.DownLeft, Direction.DownRight + } + .Select(direction => kingPosition + direction); + + foreach (var maybeSafePosition in possibleSafePositions) + { + + } + } - /* If no ability to block the check, maybe the king can evade check by moving. - * - * Foreach position the king can reach - * Foreach piece owned by "other player", check if piece threatens king position. - */ + return false; }