예제 #1
0
 /// <summary>
 /// Creates a new instance of the Pawn class.
 /// </summary>
 /// <param name="tile">The location of the Pawn on the chess board.</param>
 /// <param name="team">The team that the Pawn is on.</param>
 /// <param name="parent">The chess board to allow referencing other Piece objects.</param>
 public Pawn(string tile, Team team, Board parent) : base(tile, team, parent)
 {
     IsFirstMove = true;
     MovementRules.Add(STANDARD_RULE, r => r.Horizonal == 0 && r.Vertical == 1 && r.Direction == (team == Team.Black ? CardinalDirection.South : CardinalDirection.North));
     MovementRules.Add(FIRST_MOVE_RULE, r => r.Horizonal == 0 && r.Vertical.IsBetween(1, 2) && r.Direction == (team == Team.Black ? CardinalDirection.South : CardinalDirection.North));
     MovementRules.Add(TAKE_PIECE_RULE, r => r.Horizonal == r.Vertical && r.Vertical == 1 && r.Direction == (team == Team.Black ? CardinalDirection.SouthWest : CardinalDirection.NorthWest) || r.Direction == (team == Team.Black ? CardinalDirection.SouthEast : CardinalDirection.NorthEast));
     MovementRules.Add(QUEENS_RULE, r => (r.Vertical == r.Horizonal) || (r.Horizonal > 0 && r.Vertical == 0) || (r.Horizonal == 0 && r.Vertical > 0));
 }
예제 #2
0
 /// <summary>
 /// Creates a new instance of the King class.
 /// </summary>
 /// <param name="tile">The location of the King on the chess board.</param>
 /// <param name="team">The team that the King is on.</param>
 /// <param name="parent">The chess board to allow referencing other Piece objects.</param>
 public King(string tile, Team team, Board parent) : base(tile, team, parent)
 {
     MovementRules.Add(STANDARD_RULE, r => r.Vertical == 1 || r.Horizonal == 1);
 }
예제 #3
0
 /// <summary>
 /// Creates a new instance of the Queen class.
 /// </summary>
 /// <param name="tile">The location of the Queen on the chess board.</param>
 /// <param name="team">The team that the Queen is on.</param>
 /// <param name="parent">The chess board to allow referencing other Piece objects.</param>
 public Queen(string tile, Team team, Board parent) : base(tile, team, parent)
 {
     MovementRules.Add(STANDARD_RULE, r => (r.Vertical == r.Horizonal) || (r.Horizonal > 0 && r.Vertical == 0) || (r.Horizonal == 0 && r.Vertical > 0));
 }
예제 #4
0
 /// <summary>
 /// Creates a new instance of the Knight class.
 /// </summary>
 /// <param name="tile">The location of the Knight on the chess board.</param>
 /// <param name="team">The team that the Knight is on.</param>
 /// <param name="parent">The chess board to allow referencing other Piece objects.</param>
 public Knight(string tile, Team team, Board parent) : base(tile, team, parent)
 {
     MovementRules.Add(STANDARD_RULE, r => (r.Horizonal == 1 && (r.Vertical == r.Horizonal * 2)) || (r.Vertical == 1 && (r.Horizonal == r.Vertical * 2)));
 }