Exemple #1
0
        private bool DownStone(StonePoint point)
        {
            #region 人机对弈,下子

            if (point.Type == StoneType.未落子)
            {
                return(false);
            }

            var arr = Chessboard.StonesArray;
            arr[(int)point.PointX, (int)point.PointY] = (int)point.Type;
            var jingShou = Rule.IsJinShou(arr, point.PointX, point.PointY);
            if (point.Type == StoneType.黑子 && jingShou == JinShou.双三禁手)
            {
                MessageBox.Show("黑子双三禁手!", "温馨提示", MessageBoxButtons.OK);
            }
            else if (point.Type == StoneType.黑子 && jingShou == JinShou.双四禁手)
            {
                MessageBox.Show("黑子双四禁手!", "温馨提示", MessageBoxButtons.OK);
            }
            else if (point.Type == StoneType.黑子 && jingShou == JinShou.长联禁手)
            {
                MessageBox.Show("黑子长联禁手!", "温馨提示", MessageBoxButtons.OK);
            }
            else
            {
                Chessboard.UpdateStones(point); //更新Stones
                stone.DrawStone(point);
                Common.MakeStoneSound();

                var txt = point.StepNum.ToString() + " " + point.Type.ToString() + " 横:" + point.PointXValue + " - " + "纵:" + point.PointYValue.Replace("No", "");
                ChessRecord.StackHistory.Push(txt); //StackHistory为了保存棋谱
                shower.DataSource = ChessRecord.StackHistory.ToArray();
                shower.Update();

                if (Rule.IsPing() && MessageBox.Show("平局!", "重新开始", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    Chessboard.Clear();
                    ChessRecord.StackHistory.Clear();
                    Draw();                                      //重绘清除落子
                    Start();                                     //开新一局
                }
                else if (Rule.IsWin(point.PointX, point.PointY)) //在该位置落子胜
                {
                    string txtStone = point.Type == StoneType.黑子 ? "黑子胜利" : "白子胜利";
                    if (MessageBox.Show(txtStone, "是否保存棋谱", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        ChessRecord.SaveQP();
                    }

                    Chessboard.Clear();
                    ChessRecord.StackHistory.Clear();
                    Draw();  //重绘清除落子
                    Start(); //开新一局
                }
                else
                {
                    return(true); //可以走下一步
                }
            }

            #endregion

            return(false);
        }