Exemple #1
0
 public void BtnMoveBottomCenter_Click(object sender, RoutedEventArgs e)
 {
     hideAllMoves();
     if (wbTurn == "White")
     {
         return;
     }
     if (wbTurn == "Black")
     {
         if (pawnID == "BML")
         {
             blackPwnMiddleLeft.Visibility   = Visibility.Hidden;
             blackPwnBottomCenter.Visibility = Visibility.Visible;
             whitePwnBottomCenter.Visibility = Visibility.Hidden;
             whiteBottomCenter = false; AI2.W8 = false;
             blackBottomCenter = true;
             blackMiddleLeft   = false; AI2.B4 = false;
             wbTurn            = "White"; AI2.turn = "White";
             pawnID            = "None";
             blackWins         = blackWins + 1;
             AI2.pressBox("Black");
             AI2.test();
             MessageBox.Show("Black wins!", "Black won");
             resetGame();
         }
         if (pawnID == "BMC")
         {
             blackPwnMiddleCenter.Visibility = Visibility.Hidden;
             blackPwnBottomCenter.Visibility = Visibility.Visible;
             whiteBottomCenter = true;
             whiteMiddleCenter = false; AI2.W5 = false;
             wbTurn            = "White"; AI2.turn = "White";
             pawnID            = "None";
             blackWins         = blackWins + 1;
             AI2.pressBox("Black");
             AI2.test();
             MessageBox.Show("Black wins!", "Black won");
             resetGame();
         }
         if (pawnID == "BMR")
         {
             blackPwnMiddleRight.Visibility  = Visibility.Hidden;
             blackPwnBottomCenter.Visibility = Visibility.Visible;
             whitePwnBottomCenter.Visibility = Visibility.Hidden;
             whiteBottomCenter = false; AI2.W8 = false;
             blackMiddleRight  = false; AI2.B6 = false;
             blackBottomCenter = true;
             wbTurn            = "White"; AI2.turn = "White";
             pawnID            = "None";
             blackWins         = blackWins + 1;
             AI2.pressBox("Black");
             AI2.test();
             MessageBox.Show("Black wins!", "Black won");
             resetGame();
         }
     }
 }
Exemple #2
0
 public void BtnMoveTopCenter_Click(object sender, RoutedEventArgs e)
 {
     hideAllMoves();
     if (wbTurn == "White")
     {
         if (pawnID == "WML")
         {
             whitePwnTopCenter.Visibility = Visibility.Hidden;
             whitePwnTopCenter.Visibility = Visibility.Visible;
             blackPwnTopCenter.Visibility = Visibility.Hidden;
             blackTopCenter  = false; AI2.B2 = false;
             whiteTopCenter  = true;
             whiteMiddleLeft = false; AI2.W4 = false;
             wbTurn          = "Black"; AI2.turn = "Black";
             pawnID          = "None";
             whiteWins       = whiteWins + 1;
             AI2.pressBox("White");
             AI2.test();
             MessageBox.Show("White wins!", "White won");
             resetGame();
         }
         if (pawnID == "WMC")
         {
             whitePwnTopCenter.Visibility    = Visibility.Visible;
             whitePwnMiddleCenter.Visibility = Visibility.Hidden;
             whiteMiddleCenter = false; AI2.W5 = false;
             whiteTopCenter    = true;
             wbTurn            = "Black"; AI2.turn = "Black";
             pawnID            = "None";
             whiteWins         = whiteWins + 1;
             AI2.pressBox("White");
             AI2.test();
             MessageBox.Show("White wins!", "White won");
             resetGame();
         }
         if (pawnID == "WMR")
         {
             whitePwnMiddleRight.Visibility = Visibility.Hidden;
             blackPwnTopCenter.Visibility   = Visibility.Hidden;
             whitePwnTopCenter.Visibility   = Visibility.Visible;
             whiteTopCenter   = true;
             whiteMiddleRight = false; AI2.W6 = false;
             blackTopCenter   = false; AI2.B2 = false;
             wbTurn           = "Black"; AI2.turn = "Black";
             pawnID           = "None";
             whiteWins        = whiteWins + 1;
             AI2.pressBox("White");
             AI2.test();
             MessageBox.Show("White wins!", "White won");
             resetGame();
         }
     }
     else if (wbTurn == "Black")
     {
         return;
     }
 }
Exemple #3
0
        //hideAllMoves();
        //if (pawnID == "WCURRENT")
        //{
        //    pawnID = "None";
        //}
        //else if (pawnID == "BCURRENT")
        //{
        //    pawnID = "None";
        //}
        //else
        //{
        //    if (wbTurn == "White")
        //    {
        //        pawnID = "WCURRENT";
        //        if (whiteCURRENT == true)
        //        {
        //            if (blackINFRONT == false)
        //            {
        //                moveDotINFRONT.Visibility = Visibility.Visible;
        //                btnMoveINFRONT.Visibility = Visibility.Visible;
        //                moveAvailable = true;
        //            }
        //            if (blackDIAGNALLEFT == true)
        //            {
        //                moveDotDIAGNALLEFT.Visibility = Visibility.Visible;
        //                btnMoveDIAGNALLEFT.Visibility = Visibility.Visible;
        //                moveAvailable = true;
        //            }
        //            if (blackDIAGNALRIGHT == true)
        //            {
        //                moveDotDIAGNALRIGHT.Visibility = Visibility.Visible;
        //                btnMoveDIAGNALRIGHT.Visibility = Visibility.Visible;
        //                moveAvailable = true;
        //            }
        //        }
        //    }
        //    else if (wbTurn == "Black")
        //    {
        //        pawnID = "BCURRENT";
        //        if (blackCURRENT == true)
        //        {
        //            if (whiteINFRONT == false)
        //            {
        //                moveDotINFRONT.Visibility = Visibility.Visible;
        //                btnMoveINFRONT.Visibility = Visibility.Visible;
        //                moveAvailable = true;
        //            }
        //            if (whiteDIAGNALLEFT == true)
        //            {
        //                moveDotDIAGNALLEFT.Visibility = Visibility.Visible;
        //                btnMoveDIAGNALLEFT.Visibility = Visibility.Visible;
        //                moveAvailable = true;
        //            }
        //            if (whiteDIAGNALRIGHT == true)
        //            {
        //                moveDotDIAGNALRIGHT.Visibility = Visibility.Visible;
        //                btnMoveDIAGNALRIGHT.Visibility = Visibility.Visible;
        //                moveAvailable = true;
        //            }
        //        }
        //    }
        //}

        private void moveChecker(RoutedEventArgs e)
        {
            moveAvailable = false;
            BtnBottomRight_Click(btnBottomRight, e);
            BtnBottomCenter_Click(btnBottomCenter, e);
            BtnBottomLeft_Click(btnBottomLeft, e);
            BtnMiddleRight_Click(btnMiddleRight, e);
            BtnMiddleCenter_Click(btnMiddleCenter, e);
            BtnMiddleLeft_Click(btnMiddleRight, e);
            BtnTopRight_Click(btnTopRight, e);
            BtnTopCenter_Click(btnTopCenter, e);
            BtnTopLeft_Click(btnTopLeft, e);
            hideAllMoves();
            pawnID = "None";
            if (moveAvailable == false)
            {
                if (wbTurn == "White")
                {
                    AI2.pressBox("Black");
                    AI2.test();
                    MessageBox.Show("White can't move so black won!", "Black won");
                    blackWins = blackWins + 1;
                    resetGame();
                }
                if (wbTurn == "Black")
                {
                    AI2.pressBox("White");
                    AI2.test();
                    MessageBox.Show("Black can't move so white won!", "White won");
                    whiteWins = whiteWins + 1;
                    resetGame();
                }
            }
            else
            {
            }
        }