private void button10_Click(object sender, EventArgs e) { if (ochua[10].GetSoLuongDa() != 0) { if (flag == 0) { MessageBox.Show("Bạn chưa chọn hướng đi "); } else if (nguoichoi == false) { buttonclicked = 10; if (nguoichoi == false) { banchoi.RaiQuan(banchoi.GetHoleArray[10], nguoichoi, huongdi, MangBanTay, this, btn_Da); } ChoiGame(); if (KiemTra.KiemTraHetQuan(ochua) == 1) { banchoi.RaiQuanKhiHetDa(ochua, true); } flag = 0; } else { MessageBox.Show("Bạn không được quyền đi từ ô này "); } } else { MessageBox.Show("Ô hiện tại không có đá, không thể đi "); } }
private void KetQua() { KiemTra.KetThucTran(banchoi.GetHoleArray); if (KetThucGame == true) { if (NguoiChienThang == 0) { txt_Display.Text = "Hòa"; txt_Display.Visible = true; } else if (NguoiChienThang == 1) { txt_Display.Text = "Người Chơi 1 Thắng"; txt_Display.Visible = true; } else { txt_Display.Text = "Người Chơi 2 Thắng"; txt_Display.Visible = true; } } }
public void ChoiGame() { if (buttonclicked <= 5) { while (KiemTra.ThemLuotDi(banchoi, banchoi.MangOChua, nguoichoi, huongdi)) { ohientai = banchoi.TraViTriOHienTai(); if (huongdi == true && nguoichoi == false || huongdi == false && nguoichoi == true) { ohientai--; if (ohientai == -1) { ohientai = 11; } } if (huongdi == false && nguoichoi == false || huongdi == true && nguoichoi == true) { ohientai++; if (ohientai == 12) { ohientai = 0; } } txt_Display.Text = ("Lượt tiếp tục"); txt_Display.Visible = true; txt_Display.Refresh(); banchoi.RaiQuan(banchoi.GetHoleArray[(ohientai)], nguoichoi, huongdi, MangBanTay, this, btn_Da); //Thread.Sleep(300); txt_Display.Visible = false; } while ((KiemTra.ThemLuotDi(banchoi, banchoi.MangOChua, nguoichoi, huongdi)) == false) { if (huongdi) // huong di ben phai cua nguoi choi 1 { #region KhaiBaoBien ohientai = banchoi.TraViTriOHienTai(); if (ohientai == 10) { o1 = 11; o2 = 0; } else if (ohientai == 11) { o1 = 0; o2 = 1; } else { o1 = ohientai + 1; o2 = ohientai + 2; } #endregion int kho_a = 12; /*code dang sai*/ if (hamcon(kho_a) == -1) { break; } if (ohientai == 11) { ohientai = 1; } else if (ohientai == 10) { ohientai = 0; } else { ohientai += 2; } banchoi.OHienTai = ohientai; } else if (huongdi == false) // huong di qua ben trai cua nguoi 1 { #region KhaiBaoBien ohientai = banchoi.TraViTriOHienTai(); if (ohientai == 0) { o1 = 11; o2 = 10; } else if (ohientai == 1) { o1 = 0; o2 = 11; } else { o1 = ohientai - 1; o2 = ohientai - 2; } #endregion int kho_a = 12; if (hamcon(kho_a) == -1) { break; } if (ohientai == 0) { ohientai = 10; } else if (ohientai == 1) { ohientai = 11; } else { ohientai -= 2; } banchoi.OHienTai = ohientai; } } nguoichoi = false; } else if (nguoichoi == false) { while (KiemTra.ThemLuotDi(banchoi, banchoi.MangOChua, nguoichoi, huongdi)) { ohientai = banchoi.TraViTriOHienTai(); if (huongdi == true && nguoichoi == false || huongdi == false && nguoichoi == true) { ohientai--; } if (huongdi == false && nguoichoi == false || huongdi == true && nguoichoi == true) { ohientai++; if (ohientai == 12) { ohientai = 0; } } txt_Display.Text = ("Lượt tiếp tục"); txt_Display.Visible = true; txt_Display.Refresh(); banchoi.RaiQuan(banchoi.GetHoleArray[(ohientai)], nguoichoi, huongdi, MangBanTay, this, btn_Da); //Thread.Sleep(300); txt_Display.Visible = false; } while ((KiemTra.ThemLuotDi(banchoi, banchoi.MangOChua, nguoichoi, huongdi)) == false) { if (huongdi) // huong di ben phai cua nguoi choi 2 { #region KhaiBaoBien ohientai = banchoi.TraViTriOHienTai(); if (ohientai == 0) { o1 = 11; o2 = 10; } else if (ohientai == 1) { o1 = 0; o2 = 11; } else { o1 = ohientai - 1; o2 = ohientai - 2; } #endregion int kho_b = 13; if (hamcon(kho_b) == -1) { break; } if (ohientai == 0) { ohientai = 10; } else if (ohientai == 1) { ohientai = 11; } else { ohientai -= 2; } banchoi.OHienTai = ohientai; } else if (huongdi == false) // huong di qua ben trai cua nguoi 2 { #region KhaiBaoBien ohientai = banchoi.TraViTriOHienTai(); if (ohientai == 10) { o1 = 11; o2 = 0; } else if (ohientai == 11) { o1 = 0; o2 = 1; } else { o1 = ohientai + 1; o2 = ohientai + 2; } #endregion int kho_b = 13; if (hamcon(kho_b) == -1) { break; } if (ohientai == 11) { ohientai = 1; } else if (ohientai == 10) { ohientai = 0; } else { ohientai += 2; } banchoi.OHienTai = ohientai; } } nguoichoi = true; } if (nguoichoi == false) { ptb_player2.Visible = true; ptb_player1.Visible = false; } else { ptb_player1.Visible = true; ptb_player2.Visible = false; } }