예제 #1
0
        private void JudgeCallback(Judge judge)
        {
            switch (judge.Result)
            {
            case Judge.JudgeResult.OWins:
                JudgeShowWin(judge);
                break;

            case Judge.JudgeResult.XWins:
                JudgeShowWin(judge);
                break;

            case Judge.JudgeResult.Draw:
                JudgeShowDraw();
                break;
            }
        }
예제 #2
0
        //컴퓨터 위치 에러 체크
        public int ComPositionInputError(string stone)
        {
            Judge  judge  = new Judge();
            Random random = new Random();

            int comPosition = random.Next(1, 10); //랜덤 라이브러리로 1부터 10까지 정수 난수 생성

            int winCheck  = 0;
            int drawCheck = 0;

            drawCheck = judge.DrawCheck(gameMatrix, stone); //무승부 판정 (무승부면 drawCheck에 5 반환)
            winCheck  = judge.WinCheck(gameMatrix, stone);  //승부 판정(선공자의 승리시 1,4 반환 / 후공자의 승리지 2,3 반환 / 승부가 나지 않았을 때 0 반환)

            if (drawCheck == 5 && winCheck == 0)
            {
                Console.Clear();
                Console.WriteLine("\n\t무승부 입니다!\n\n");
                scoreinfo.Set_VsComputerScore("Draw");
                vsComputer.AfterMatch();
            }

            //같은 자리 번호를 생성하였을 때 중복이 되지 않는 번호를 생성할때까지 반복하는 반복문
            while (true)
            {
                if (gameMatrix[comPosition - 1] == "●" || gameMatrix[comPosition - 1] == "○")
                {
                    comPosition = random.Next(1, 10);
                }

                else
                {
                    break;
                }
            }

            return(comPosition);
        }
예제 #3
0
        private void JudgeShowWin(Judge judge)
        {
            foreach (var label in Controls.OfType <Label>())
            {
                label.Enabled = false;
            }
            foreach (
                var reasonLabel in
                judge.ReasonLine.Members.Select(
                    reasonElement => "Board" + reasonElement.Row + "_" + reasonElement.Column))
            {
                Controls.Find(reasonLabel, false).First().BackColor = Color.FromArgb(255, 193, 7);
            }
            switch (_currentGame.Mode)
            {
            case GameCore.GameMode.AI:
                if ((judge.Result == Judge.JudgeResult.OWins && _aiContent == "X") ||
                    (judge.Result == Judge.JudgeResult.XWins && _aiContent == "O"))
                {
                    var victoryForm = new Victory(_currentGame.Mode, _currentGame.HistoryHands);
                    victoryForm.Show();
                }
                else
                {
                    MessageBox.Show("胜败乃兵家常事,大侠请重新来过。", "TicTacToe", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                break;

            case GameCore.GameMode.Manual:
                if (judge.Result == Judge.JudgeResult.OWins || judge.Result == Judge.JudgeResult.XWins)
                {
                    var victoryForm = new Victory(_currentGame.Mode, _currentGame.HistoryHands);
                    victoryForm.Show();
                }
                break;
            }
        }