UTests pass with Pathfinder2D
This commit is contained in:
47
Gameboard.ShogiUI.BoardState/Pieces/Bishop.cs
Normal file
47
Gameboard.ShogiUI.BoardState/Pieces/Bishop.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using PathFinding;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
|
||||
namespace Gameboard.ShogiUI.BoardState.Pieces
|
||||
{
|
||||
public class Bishop : Piece
|
||||
{
|
||||
private static readonly List<Path> MoveSet = new List<Path>(4)
|
||||
{
|
||||
new Path(Direction.UpLeft, Distance.MultiStep),
|
||||
new Path(Direction.UpRight, Distance.MultiStep),
|
||||
new Path(Direction.DownLeft, Distance.MultiStep),
|
||||
new Path(Direction.DownRight, Distance.MultiStep)
|
||||
};
|
||||
private static readonly List<Path> PromotedMoveSet = new List<Path>(8)
|
||||
{
|
||||
new Path(Direction.Up),
|
||||
new Path(Direction.Left),
|
||||
new Path(Direction.Right),
|
||||
new Path(Direction.Down),
|
||||
new Path(Direction.UpLeft, Distance.MultiStep),
|
||||
new Path(Direction.UpRight, Distance.MultiStep),
|
||||
new Path(Direction.DownLeft, Distance.MultiStep),
|
||||
new Path(Direction.DownRight, Distance.MultiStep)
|
||||
};
|
||||
public Bishop(WhichPlayer owner) : base(WhichPiece.Bishop, owner)
|
||||
{
|
||||
// TODO: If this strat works out, we can do away with the Direction class entirely.
|
||||
PromotedMoveSet.AddRange(MoveSet);
|
||||
}
|
||||
|
||||
public override Piece DeepClone()
|
||||
{
|
||||
var clone = new Bishop(Owner);
|
||||
if (IsPromoted) clone.Promote();
|
||||
return clone;
|
||||
}
|
||||
|
||||
public override ICollection<Path> GetPaths()
|
||||
{
|
||||
var moveSet = IsPromoted ? PromotedMoveSet : MoveSet;
|
||||
return Owner == WhichPlayer.Player1 ? moveSet : moveSet.Select(_ => new Path(Vector2.Negate(_.Direction), _.Distance)).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user