//유저 돌 위치 선택 public void SelectPosition() { Console.Clear(); int winCheck = 0; int drawCheck = 0; //선공자의 돌 색상과 게임판을 judge 클래스로 넘겨서 승무패 판단 drawCheck = judge.DrawCheck(matrix.GetMatrix(), stone); winCheck = judge.WinCheck(matrix.GetMatrix(), stone); //무승부 && 승패판단 안되었을때 if (drawCheck == 5 && winCheck == 0) { Console.WriteLine("\n\t무승부 입니다!\n\n"); scoreInfo.Set_VsComputerScore("Draw"); AfterMatch(); } //1,4 는 user 승리 / 2,3은 컴퓨터 승리 / 0은 승패판정x switch (winCheck) { case 1: Console.WriteLine("\n\tUser가 이겼습니닷!\n\n"); scoreInfo.Set_VsComputerScore("Player"); AfterMatch(); break; case 2: Console.WriteLine("\n\tComputer가 이겼네요ㅠ.ㅠ\n\n"); scoreInfo.Set_VsComputerScore("Computer"); AfterMatch(); break; case 3: Console.WriteLine("\n\tComputer가 이겼네요ㅠ.ㅠ\n\n"); scoreInfo.Set_VsComputerScore("Computer"); AfterMatch(); break; case 4: Console.WriteLine("\n\tUser가 이겼습니닷!\n\n"); scoreInfo.Set_VsComputerScore("Player"); AfterMatch(); break; case 0: matrix.ShowMatrix(); Console.Write("\t두실 말의 위치를 골라주세요 : "); position = Console.ReadKey(true); errorCheck.PositionInputError_Com(position, stone); break; } }
//플레이어1 돌 위치 갱신 및 승무패 확인 public void SelectPosition_Player1() { Console.Clear(); int winCheck = 0; int drawCheck = 0; drawCheck = judge.DrawCheck(matrix.GetMatrix(), stone_player1); winCheck = judge.WinCheck(matrix.GetMatrix(), stone_player1); if (drawCheck == 5 && winCheck == 0) { Console.WriteLine("\n\t무승부 입니다!\n\n"); scoreInfo.Set_VsPlayerScore(3); AfterMatch(); } switch (winCheck) { case 1: Console.WriteLine("\n\tplayer1이 이겼습니닷!\n\n"); scoreInfo.Set_VsPlayerScore(1); AfterMatch(); break; case 2: Console.WriteLine("\n\tplayer2가 이겼습니닷!\n\n"); scoreInfo.Set_VsPlayerScore(2); AfterMatch(); break; case 3: Console.WriteLine("\n\tplayer2가 이겼습니닷!\n\n"); scoreInfo.Set_VsPlayerScore(2); AfterMatch(); break; case 4: Console.WriteLine("\n\tplayer1이 이겼습니닷!\n\n"); scoreInfo.Set_VsPlayerScore(1); AfterMatch(); break; case 0: matrix.ShowMatrix(); Console.Write("\t플레이어1의 두실 말의 위치를 골라주세요 : "); position = Console.ReadKey(true); errorCheck.PositionInputError_User1(position, stone_player1); break; } }
//컴퓨터 위치 에러 체크 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); }