コード例 #1
0
        // reset internal board to the current game state
        protected void ResetBoard()
        {
            Pieces.Piece CurrentPiece = null;

            // initialize our board
            for (int Position = 0; Position < GameData.g_StartingPositions.Length; Position++)
            {
                // create appropriate class
                switch ((PType)GameData.g_StartingPositions[Position])
                {
                case PType.BlackBishop:
                {
                    CurrentPiece = new Pieces.Bishop(PColor.Black);
                    CurrentPiece.SetPosition(Position);
                    break;
                }

                case PType.BlackKing:
                {
                    CurrentPiece = new Pieces.King(PColor.Black);
                    CurrentPiece.SetPosition(Position);
                    break;
                }

                case PType.BlackKnight:
                {
                    CurrentPiece = new Pieces.Knight(PColor.Black);
                    CurrentPiece.SetPosition(Position);
                    break;
                }

                case PType.BlackPawn:
                {
                    CurrentPiece = new Pieces.Pawn(PColor.Black);
                    CurrentPiece.SetPosition(Position);
                    break;
                }

                case PType.BlackQueen:
                {
                    CurrentPiece = new Pieces.Queen(PColor.Black);
                    CurrentPiece.SetPosition(Position);
                    break;
                }

                case PType.BlackRook:
                {
                    CurrentPiece = new Pieces.Rook(PColor.Black);
                    CurrentPiece.SetPosition(Position);
                    break;
                }

                case PType.WhiteBishop:
                {
                    CurrentPiece = new Pieces.Bishop(PColor.White);
                    CurrentPiece.SetPosition(Position);
                    break;
                }

                case PType.WhiteKing:
                {
                    CurrentPiece = new Pieces.King(PColor.White);
                    CurrentPiece.SetPosition(Position);
                    break;
                }

                case PType.WhiteKnight:
                {
                    CurrentPiece = new Pieces.Knight(PColor.White);
                    CurrentPiece.SetPosition(Position);
                    break;
                }

                case PType.WhitePawn:
                {
                    CurrentPiece = new Pieces.Pawn(PColor.White);
                    CurrentPiece.SetPosition(Position);
                    break;
                }

                case PType.WhiteQueen:
                {
                    CurrentPiece = new Pieces.Queen(PColor.White);
                    CurrentPiece.SetPosition(Position);
                    break;
                }

                case PType.WhiteRook:
                {
                    CurrentPiece = new Pieces.Rook(PColor.White);
                    CurrentPiece.SetPosition(Position);
                    break;
                }

                default:
                {
                    CurrentPiece = null;
                    break;
                }
                }

                // add piece to board
                GameData.g_CurrentGameState[Position] = CurrentPiece;
            }
        }
コード例 #2
0
ファイル: Rules.cs プロジェクト: egyfirst/officechess
        // reset internal board to the current game state
        protected void ResetBoard()
        {
            Pieces.Piece CurrentPiece = null;

            // initialize our board
            for (int Position = 0; Position < GameData.g_StartingPositions.Length; Position++)
            {
                // create appropriate class
                switch ((PType)GameData.g_StartingPositions[Position])
                {
                    case PType.BlackBishop:
                        {
                            CurrentPiece = new Pieces.Bishop(PColor.Black);
                            CurrentPiece.SetPosition(Position);
                            break;
                        }
                    case PType.BlackKing:
                        {
                            CurrentPiece = new Pieces.King(PColor.Black);
                            CurrentPiece.SetPosition(Position);
                            break;
                        }
                    case PType.BlackKnight:
                        {
                            CurrentPiece = new Pieces.Knight(PColor.Black);
                            CurrentPiece.SetPosition(Position);
                            break;
                        }
                    case PType.BlackPawn:
                        {
                            CurrentPiece = new Pieces.Pawn(PColor.Black);
                            CurrentPiece.SetPosition(Position);
                            break;
                        }
                    case PType.BlackQueen:
                        {
                            CurrentPiece = new Pieces.Queen(PColor.Black);
                            CurrentPiece.SetPosition(Position);
                            break;
                        }
                    case PType.BlackRook:
                        {
                            CurrentPiece = new Pieces.Rook(PColor.Black);
                            CurrentPiece.SetPosition(Position);
                            break;
                        }

                    case PType.WhiteBishop:
                        {
                            CurrentPiece = new Pieces.Bishop(PColor.White);
                            CurrentPiece.SetPosition(Position);
                            break;
                        }
                    case PType.WhiteKing:
                        {
                            CurrentPiece = new Pieces.King(PColor.White);
                            CurrentPiece.SetPosition(Position);
                            break;
                        }
                    case PType.WhiteKnight:
                        {
                            CurrentPiece = new Pieces.Knight(PColor.White);
                            CurrentPiece.SetPosition(Position);
                            break;
                        }
                    case PType.WhitePawn:
                        {
                            CurrentPiece = new Pieces.Pawn(PColor.White);
                            CurrentPiece.SetPosition(Position);
                            break;
                        }
                    case PType.WhiteQueen:
                        {
                            CurrentPiece = new Pieces.Queen(PColor.White);
                            CurrentPiece.SetPosition(Position);
                            break;
                        }
                    case PType.WhiteRook:
                        {
                            CurrentPiece = new Pieces.Rook(PColor.White);
                            CurrentPiece.SetPosition(Position);
                            break;
                        }
                    default:
                        {
                            CurrentPiece = null;
                            break;
                        }
                }

                // add piece to board
                GameData.g_CurrentGameState[Position] = CurrentPiece;
            }
        }