checkpoint
This commit is contained in:
@@ -32,3 +32,9 @@ public enum WhichPiece
|
||||
Pawn,
|
||||
//PromotedPawn,
|
||||
}
|
||||
|
||||
public enum WhichPlayer
|
||||
{
|
||||
Player1,
|
||||
Player2
|
||||
}
|
||||
|
||||
15
Shogi.Domain/ValueObjects/Movement/Direction.cs
Normal file
15
Shogi.Domain/ValueObjects/Movement/Direction.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace Shogi.Domain.ValueObjects;
|
||||
|
||||
public static class Direction
|
||||
{
|
||||
public static readonly Vector2 Forward = new(0, 1);
|
||||
public static readonly Vector2 Backward = new(0, -1);
|
||||
public static readonly Vector2 Left = new(-1, 0);
|
||||
public static readonly Vector2 Right = new(1, 0);
|
||||
public static readonly Vector2 ForwardLeft = new(-1, 1);
|
||||
public static readonly Vector2 ForwardRight = new(1, 1);
|
||||
public static readonly Vector2 BackwardLeft = new(-1, -1);
|
||||
public static readonly Vector2 BackwardRight = new(1, -1);
|
||||
public static readonly Vector2 KnightLeft = new(-1, 2);
|
||||
public static readonly Vector2 KnightRight = new(1, 2);
|
||||
}
|
||||
13
Shogi.Domain/ValueObjects/Movement/Distance.cs
Normal file
13
Shogi.Domain/ValueObjects/Movement/Distance.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace Shogi.Domain.ValueObjects;
|
||||
|
||||
public enum Distance
|
||||
{
|
||||
/// <summary>
|
||||
/// Signifies that a piece can move one tile/position per move.
|
||||
/// </summary>
|
||||
OneStep,
|
||||
/// <summary>
|
||||
/// Signifies that a piece can move multiple tiles/positions in a single move.
|
||||
/// </summary>
|
||||
MultiStep
|
||||
}
|
||||
24
Shogi.Domain/ValueObjects/Movement/Path.cs
Normal file
24
Shogi.Domain/ValueObjects/Movement/Path.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Shogi.Domain.ValueObjects.Movement;
|
||||
|
||||
[DebuggerDisplay("{Step} - {Distance}")]
|
||||
public record Path
|
||||
{
|
||||
public Vector2 Step { get; }
|
||||
public Vector2 NormalizedStep => Vector2.Normalize(Step);
|
||||
public Distance Distance { get; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="step">The smallest distance that can occur during a move.</param>
|
||||
/// <param name="distance"></param>
|
||||
public Path(Vector2 step, Distance distance = Distance.OneStep)
|
||||
{
|
||||
Step = step;
|
||||
Distance = distance;
|
||||
}
|
||||
|
||||
public Path Invert() => new(Vector2.Negate(Step), Distance);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using Shogi.Domain.YetToBeAssimilatedIntoDDD.Pathing;
|
||||
using Shogi.Domain.ValueObjects.Movement;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Shogi.Domain.ValueObjects
|
||||
@@ -1,4 +1,4 @@
|
||||
using Shogi.Domain.YetToBeAssimilatedIntoDDD.Pathing;
|
||||
using Shogi.Domain.ValueObjects.Movement;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Shogi.Domain.ValueObjects;
|
||||
@@ -1,4 +1,4 @@
|
||||
using Shogi.Domain.YetToBeAssimilatedIntoDDD.Pathing;
|
||||
using Shogi.Domain.ValueObjects.Movement;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Shogi.Domain.ValueObjects;
|
||||
@@ -1,4 +1,4 @@
|
||||
using Shogi.Domain.YetToBeAssimilatedIntoDDD.Pathing;
|
||||
using Shogi.Domain.ValueObjects.Movement;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Shogi.Domain.ValueObjects
|
||||
@@ -1,4 +1,4 @@
|
||||
using Shogi.Domain.YetToBeAssimilatedIntoDDD.Pathing;
|
||||
using Shogi.Domain.ValueObjects.Movement;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Shogi.Domain.ValueObjects
|
||||
@@ -1,4 +1,4 @@
|
||||
using Shogi.Domain.YetToBeAssimilatedIntoDDD.Pathing;
|
||||
using Shogi.Domain.ValueObjects.Movement;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Shogi.Domain.ValueObjects
|
||||
@@ -1,4 +1,4 @@
|
||||
using Shogi.Domain.YetToBeAssimilatedIntoDDD.Pathing;
|
||||
using Shogi.Domain.ValueObjects.Movement;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Shogi.Domain.ValueObjects
|
||||
@@ -1,4 +1,4 @@
|
||||
using Shogi.Domain.YetToBeAssimilatedIntoDDD.Pathing;
|
||||
using Shogi.Domain.ValueObjects.Movement;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Shogi.Domain.ValueObjects;
|
||||
@@ -1,4 +1,4 @@
|
||||
using Shogi.Domain.YetToBeAssimilatedIntoDDD.Pathing;
|
||||
using Shogi.Domain.ValueObjects.Movement;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Shogi.Domain.ValueObjects
|
||||
@@ -1,4 +1,5 @@
|
||||
using Shogi.Domain.YetToBeAssimilatedIntoDDD;
|
||||
using Shogi.Domain.ValueObjects.Movement;
|
||||
using Shogi.Domain.YetToBeAssimilatedIntoDDD;
|
||||
namespace Shogi.Domain.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
@@ -247,7 +248,7 @@ public sealed class ShogiBoard(BoardState initialState)
|
||||
{
|
||||
var list = new List<Vector2>(10);
|
||||
var position = path.Step + piecePosition;
|
||||
if (path.Distance == YetToBeAssimilatedIntoDDD.Pathing.Distance.MultiStep)
|
||||
if (path.Distance == Distance.MultiStep)
|
||||
{
|
||||
|
||||
while (position.IsInsideBoardBoundary())
|
||||
@@ -340,7 +341,7 @@ public sealed class ShogiBoard(BoardState initialState)
|
||||
else
|
||||
{
|
||||
var multiStepPaths = matchingPaths
|
||||
.Where(path => path.Distance == YetToBeAssimilatedIntoDDD.Pathing.Distance.MultiStep)
|
||||
.Where(path => path.Distance == Distance.MultiStep)
|
||||
.ToArray();
|
||||
if (multiStepPaths.Length == 0)
|
||||
{
|
||||
@@ -371,7 +372,7 @@ public sealed class ShogiBoard(BoardState initialState)
|
||||
return new MoveResult(true);
|
||||
}
|
||||
|
||||
private static IEnumerable<Vector2> GetPositionsAlongPath(Vector2 from, Vector2 to, YetToBeAssimilatedIntoDDD.Pathing.Path path)
|
||||
private static IEnumerable<Vector2> GetPositionsAlongPath(Vector2 from, Vector2 to, Path path)
|
||||
{
|
||||
var next = from;
|
||||
while (next != to && next.X >= 0 && next.X < 9 && next.Y >= 0 && next.Y < 9)
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace Shogi.Domain.ValueObjects
|
||||
{
|
||||
public enum WhichPlayer
|
||||
{
|
||||
Player1,
|
||||
Player2
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user