void StartGame(ChessPieceSide side)
        {
            UpdateBoardeGui(btnPlay, boardGui, side);
            timerCheckEndGame.Start();

            if (modeplay == 2)
            {
                return;
            }
            timerProcessbarPlayer.Start();
        }
Example #2
0
 public Pawn(int position, ChessPieceType type, ChessPieceSide side) : base(position, type, side)
 {
     if (side == ChessPieceSide.BLACK)
     {
         this.vector = 1;
     }
     else
     {
         this.vector = -1;
     }
 }
Example #3
0
        ///<summary>
        /// lấy tổng số điểm còn lại của các quân cờ trên bàn cờ
        ///</summary>
        int ValuePiece(Board board, ChessPieceSide side)
        {
            int sum = 0;

            foreach (Cell cell in board.listCell)
            {
                ChessPieces piece = cell.GetChessPieces();
                if (piece != null)
                {
                    sum += piece.chessPieceType.weight;
                }
            }

            return(sum);
        }
Example #4
0
        public BoardGui(ChessPieceSide sidePlayFirst) : base()
        {
            this.boardLogic = new Board(sidePlayFirst);
            moveHistory     = new MoveHistory();

            this.CellSelectedFirst = this.CellSelectedSecond = null;
            this.ColumnCount       = 8;
            this.RowCount          = 8;


            this.Size            = new Size(538, 538);
            this.Location        = new Point(250, 40);
            this.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single;

            this.listCellGui = new List <CellGui>();
            AddCellGuiAndCell();
        }
Example #5
0
 private void UpdateBoardeGui(Button lb, BoardGui boardGui, ChessPieceSide side)
 {
     if (btnPlay.InvokeRequired)
     {
         // this is worker thread
         updateBoardDelegate del = new updateBoardDelegate(UpdateBoardeGui);
         lvChat.Invoke(del, new object[] { lb, boardGui, side });
     }
     else
     {
         // this is UI thread
         btnPlay.Visible = false;
         boardGui        = new BoardGui(side);
         this.Controls.Add(boardGui);
         this.boardGui = boardGui;
     }
 }
Example #6
0
        public Board CreateCellBoard(ChessPieceSide sidePlayFirst)
        {
            Cell[] cells = new Cell[64];
            for (int i = 0; i < 64; i++)
            {
                cells[i] = Cell.CreateCell(i, this.GetPiece(i));
            }
            if (this.listCell != null)
            {
                this.listCell.Clear();
            }
            this.listCell = cells.ToList();

            this.Blacklayer  = new Player((King)cells[4].GetChessPieces(), ChessPieceSide.BLACK);
            this.Whitelayer  = new Player((King)cells[60].GetChessPieces(), ChessPieceSide.WHITE);
            this.Curentlayer = (sidePlayFirst == ChessPieceSide.BLACK) ? this.Blacklayer : this.Whitelayer;
            return(this);
        }
        private void UpdateBoardeGui(Button lb, BoardGui boardGui, ChessPieceSide side)
        {
            if (btnPlay.InvokeRequired)
            {
                // this is worker thread
                updateBoardDelegate del = new updateBoardDelegate(UpdateBoardeGui);
                btnPlay.Invoke(del, new object[] { lb, boardGui, side });
            }
            else
            {
                // this is UI thread
                btnPlay.Visible = false;
                if (Mode1AndMode2.namePlayer == "Player black")
                {
                    isClient = true;
                }

                boardGui = new BoardGui(side, isClient);
                this.Controls.Add(boardGui);
                this.boardGui = boardGui;
            }
        }
Example #8
0
        public ChessPieces GetChessPiece(ChessPieceSide s)
        {
            if (choosed == 1)
            {
                return(new Rook(1, ChessPieceType.ROOK, s));
            }

            else if (choosed == 2)
            {
                return(new Queen(1, ChessPieceType.QUEEN, s));
            }

            else if (choosed == 3)
            {
                return(new Bishop(1, ChessPieceType.BISHOP, s));
            }

            else
            {
                return(new Knight(1, ChessPieceType.KNIGHT, s));
            }
        }
Example #9
0
        public void SetIconImage(ChessPieceSide s)
        {
            string side      = s == ChessPieceSide.BLACK ? "black" : "white";
            string name      = "Rook";
            string imagePath = Application.StartupPath + "\\ChessPieceIcon\\" + side + name + ".png";

            Rook.BackgroundImage       = Image.FromFile(@imagePath);
            Rook.BackgroundImageLayout = ImageLayout.Center;

            name      = "Knight";
            imagePath = Application.StartupPath + "\\ChessPieceIcon\\" + side + name + ".png";
            Knight.BackgroundImage       = Image.FromFile(@imagePath);
            Knight.BackgroundImageLayout = ImageLayout.Center;

            name                        = "Queen";
            imagePath                   = Application.StartupPath + "\\ChessPieceIcon\\" + side + name + ".png";
            Queen.BackgroundImage       = Image.FromFile(@imagePath);
            Queen.BackgroundImageLayout = ImageLayout.Center;

            name      = "Bishop";
            imagePath = Application.StartupPath + "\\ChessPieceIcon\\" + side + name + ".png";
            Bishop.BackgroundImage       = Image.FromFile(@imagePath);
            Bishop.BackgroundImageLayout = ImageLayout.Center;
        }
Example #10
0
 public Knight(int position, ChessPieceType type, ChessPieceSide side) : base(position, type, side)
 {
 }
Example #11
0
 public Board(ChessPieceSide sidePlayFirst)
 {
     ListChessPiece = new Dictionary <int, ChessPieces>();
     CreateDefaultListPieceBoard();
     CreateCellBoard(sidePlayFirst);
 }
Example #12
0
 public Queen(int position, ChessPieceType type, ChessPieceSide side) : base(position, type, side)
 {
 }
Example #13
0
 public Player(King king, ChessPieceSide c)
 {
     this.king       = king;
     this.sideplayer = c;
 }
Example #14
0
 public ChessPieces(int position, ChessPieceType type, ChessPieceSide side)
 {
     this.chessPiecePosition = position;
     this.chessPieceType     = type;
     this.side = side;
 }
Example #15
0
 public Bishop(int position, ChessPieceType type, ChessPieceSide side) : base(position, type, side)
 {
 }