48 lines
1.5 KiB
C#
48 lines
1.5 KiB
C#
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();
|
|
}
|
|
}
|
|
}
|