Exemple #1
0
        public void Move(int acol, int arow, int bcol, int brow, bool intern = false)
        {
            Piece pc = GetPiece(acol, arow);

            if (!intern)
            {
                if (OnMove != null)
                {
                    OnMove(acol, arow, bcol, brow, pc.Color);
                }
                Board.whites = !Board.whites;
            }

            pieces[acol, arow] = '\0';
            Register(bcol, brow, pc);

            if (!Game.GameOver && (brow == 0 || brow == 7) &&
                pc.Type == PieceType.PAWN && (!Game.IsConnected || Game.MainColor == pc.Color))
            {
                Promote promote = new Promote(pc);
                promote.Closed += delegate(object s, System.EventArgs e)
                {
                    Game game = GetTopParent() as Game;
                    this.Dispatcher.BeginInvoke(new PromoteDelegate(game.OnPromote), new object[] { ((Promote)s).Piece });
                };
                promote.ShowDialog();
            }

            if (OnMoveComplete != null)
            {
                OnMoveComplete(acol, arow, bcol, brow, pc.Color);
            }
        }
Exemple #2
0
        public void Move(int acol, int arow, int bcol, int brow, bool intern = false)
        {
            Piece pc = GetPiece(acol, arow);
            if (!intern)
            {
                if (OnMove != null)
                    OnMove(acol, arow, bcol, brow, pc.Color);
                Board.whites = !Board.whites;
            }

            pieces[acol, arow] = '\0';
            Register(bcol, brow, pc);

            if (!Game.GameOver && (brow == 0 || brow == 7) &&
                pc.Type == PieceType.PAWN && (!Game.IsConnected || Game.MainColor == pc.Color))
            {
                Promote promote = new Promote(pc);
                promote.Closed += delegate(object s, System.EventArgs e)
                {
                    Game game = GetTopParent() as Game;
                    this.Dispatcher.BeginInvoke(new PromoteDelegate(game.OnPromote), new object[] { ((Promote)s).Piece });
                };
                promote.ShowDialog();
            }

            if (OnMoveComplete != null)
                OnMoveComplete(acol, arow, bcol, brow, pc.Color);
        }