Code smells
This commit is contained in:
@@ -1,32 +1,32 @@
|
||||
using PathFinding;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
|
||||
namespace Gameboard.ShogiUI.BoardState.Pieces
|
||||
{
|
||||
public class Rook : Piece
|
||||
{
|
||||
private static readonly List<Path> MoveSet = new List<Path>(4)
|
||||
private static readonly List<PathFinding.Move> Moves = new(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)
|
||||
new PathFinding.Move(Direction.Up, Distance.MultiStep),
|
||||
new PathFinding.Move(Direction.Left, Distance.MultiStep),
|
||||
new PathFinding.Move(Direction.Right, Distance.MultiStep),
|
||||
new PathFinding.Move(Direction.Down, Distance.MultiStep)
|
||||
};
|
||||
private static readonly List<Path> PromotedMoveSet = new List<Path>(8)
|
||||
private static readonly List<PathFinding.Move> PromotedMoves = new(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)
|
||||
new PathFinding.Move(Direction.Up, Distance.MultiStep),
|
||||
new PathFinding.Move(Direction.Left, Distance.MultiStep),
|
||||
new PathFinding.Move(Direction.Right, Distance.MultiStep),
|
||||
new PathFinding.Move(Direction.Down, Distance.MultiStep),
|
||||
new PathFinding.Move(Direction.UpLeft),
|
||||
new PathFinding.Move(Direction.UpRight),
|
||||
new PathFinding.Move(Direction.DownLeft),
|
||||
new PathFinding.Move(Direction.DownRight)
|
||||
};
|
||||
public Rook(WhichPlayer owner) : base(WhichPiece.Rook, owner)
|
||||
{
|
||||
moveSet = new MoveSet(this, Moves);
|
||||
promotedMoveSet = new MoveSet(this, PromotedMoves);
|
||||
}
|
||||
|
||||
public override Piece DeepClone()
|
||||
@@ -35,10 +35,5 @@ namespace Gameboard.ShogiUI.BoardState.Pieces
|
||||
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