internal override ArrayList CalculatePositions(Block block, bool SupportPosition) { base.CalculatePositions(block, SupportPosition); if (SupportPosition) { return(this.CalculateKillingPositions(block, SupportPosition)); } else { if (player.GetPlayerType() == PlayerType.PLAYER1) { if (OrigBlock.GetChessPosition().Y == 1) { GoDown(block.GetChessPosition(), 2); } else { GoDown(block.GetChessPosition(), 1); } GoLeftDown(block.GetChessPosition(), false); GoRightDown(block.GetChessPosition(), false); } else if (player.GetPlayerType() == PlayerType.PLAYER2) { if (OrigBlock.GetChessPosition().Y == 6) { GoUp(block.GetChessPosition(), 2); } else { GoUp(block.GetChessPosition(), 1); } GoLeftUp(block.GetChessPosition(), false); GoRightUp(block.GetChessPosition(), false); } return(ValidBlocks); } }
private void CastlePositions() { if (OrigBlock == null) { return; } Piece piece = OrigBlock.GetPiece(); if (piece == null) { return; } // It must be KING if (piece.GetPieceType() != PieceType.KING) { return; } // Must be able to castle if (!piece.GetCanCastle()) { return; } Point point = OrigBlock.GetChessPosition(); bool GotPiece = false; if (CanCastle(new Point(0, point.Y))) { for (int i = point.X - 1; i > 0; i--) { Block b = cb.GetBlockByChessPosition(new Point(i, point.Y)); if (b.GetPiece() != null) { GotPiece = true; } } if (!GotPiece) { ValidBlocks.Add(cb.GetBlockByChessPosition(new Point(point.X - 2, point.Y))); } } GotPiece = false; if (CanCastle(new Point(7, point.Y))) { for (int i = point.X + 1; i < 7; i++) { Block b = cb.GetBlockByChessPosition(new Point(i, point.Y)); if (b.GetPiece() != null) { GotPiece = true; } } if (!GotPiece) { ValidBlocks.Add(cb.GetBlockByChessPosition(new Point(point.X + 2, point.Y))); } } }