예제 #1
0
파일: program.cs 프로젝트: jimguyer/D1Chess
 static eGameover GetGameover(eLoc pELoc)
 {
     if (CheckForWin(pELoc))
     {
         return(X_Turn ? eGameover.X_Won : eGameover.O_Won);
     }
     if (MoveNum == 9)
     {
         return(eGameover.Tie);
     }
     return(eGameover.No);
 }
예제 #2
0
파일: program.cs 프로젝트: jimguyer/D1Chess
        static void Move(eLoc pLoc)
        {
            MoveNum++;
            switch (pLoc)
            {
            case eLoc.UpperLeft: UL = X_Turn ? "X" : "O"; break;

            case eLoc.UpperCenter: UC = X_Turn ? "X" : "O"; break;

            case eLoc.UpperRight: UR = X_Turn ? "X" : "O"; break;

            case eLoc.MiddleLeft: ML = X_Turn ? "X" : "O"; break;

            case eLoc.Center: C = X_Turn ? "X" : "O"; break;

            case eLoc.MiddleRight: MR = X_Turn ? "X" : "O"; break;

            case eLoc.LowerLeft: LL = X_Turn ? "X" : "O"; break;

            case eLoc.LowerCenter: LC = X_Turn ? "X" : "O"; break;

            case eLoc.LowerRight: LR = X_Turn ? "X" : "O"; break;
            }
        }
예제 #3
0
파일: program.cs 프로젝트: jimguyer/D1Chess
        static eError CheckForError(eLoc pLoc)
        {
            switch (pLoc)
            {
            case eLoc.UpperLeft: return(UL == " "? eError.None: eError.UL_Taken);

            case eLoc.UpperCenter: return(UC == " " ? eError.None : eError.UC_Taken);

            case eLoc.UpperRight: return(UR == " " ? eError.None : eError.UR_Taken);

            case eLoc.MiddleLeft: return(ML == " " ? eError.None : eError.ML_Taken);

            case eLoc.Center: return(C == " " ? eError.None : eError.C_Taken);

            case eLoc.MiddleRight: return(MR == " " ? eError.None : eError.MR_Taken);

            case eLoc.LowerLeft: return(LL == " " ? eError.None : eError.LL_Taken);

            case eLoc.LowerCenter: return(LC == " " ? eError.None : eError.LC_Taken);

            case eLoc.LowerRight: return(LR == " " ? eError.None : eError.LR_Taken);
            }
            return(eError.None);
        }
예제 #4
0
파일: program.cs 프로젝트: jimguyer/D1Chess
        static bool CheckForWin(eLoc pELoc)
        {
            switch (pELoc)
            {
            case eLoc.UpperLeft:
                if (UL == UC && UL == UR)
                {
                    return(true);                           // Upper
                }
                if (UL == C && UL == LR)
                {
                    return(true);                           // Downward Slash
                }
                if (UL == ML && UL == LL)
                {
                    return(true);                           // Left
                }
                return(false);

            case eLoc.UpperCenter:
            case eLoc.LowerCenter:
                if (UC == C && UC == LC)
                {
                    return(true);                           // Center
                }
                return(false);

            case eLoc.UpperRight:
                if (UL == UC && UL == UR)
                {
                    return(true);                           // Upper
                }
                if (LL == C && LL == UR)
                {
                    return(true);                           // Upward Slash
                }
                if (UL == ML && UL == LL)
                {
                    return(true);                           // Right
                }
                return(false);

            case eLoc.MiddleLeft:
            case eLoc.MiddleRight:
                if (ML == C && ML == MR)
                {
                    return(true);                           // Middle
                }
                return(false);

            case eLoc.Center:
                if (UL == C && UL == LR)
                {
                    return(true);                           // Downward Slash
                }
                if (UC == C && UC == LC)
                {
                    return(true);                           // Center
                }
                if (LL == C && LL == UR)
                {
                    return(true);                           // Upward Slash
                }
                if (ML == C && ML == MR)
                {
                    return(true);                           // Middle
                }
                return(false);

            case eLoc.LowerLeft:
                if (LL == C && LL == UR)
                {
                    return(true);                           // Upward Slash
                }
                if (UL == ML && UL == LL)
                {
                    return(true);                           // Left
                }
                if (LL == LC && LL == LR)
                {
                    return(true);                           // Lower
                }
                return(false);

            case eLoc.LowerRight:
                if (LL == C && LL == UR)
                {
                    return(true);                           // Upward Slash
                }
                if (UL == ML && UL == LL)
                {
                    return(true);                           // Left
                }
                if (LL == LC && LL == LR)
                {
                    return(true);                           // Lower
                }
                return(false);
            }
            return(false);
        }