protected override bool KiemTraVT(int x0, int y0, int x1, int y1, BanCo mBanCo) { if (x0 == x1) { // Kiểm tra các ô trên đường đi xem có trống hay k int dichY = (y1 - y0 > 0) ? 1 : -1; for (int kiemTraY = y0 + dichY; kiemTraY != y1; kiemTraY = kiemTraY + dichY) { if (mBanCo.banCo[x0, kiemTraY] != null) { return(false); } } return(true); } else if (y1 == y0) { // Kiểm tra các ô trên đường đi xem có trống hay k int dichX = (x1 - x0 > 0) ? 1 : -1; for (int kiemTraX = x0 + dichX; kiemTraX != x1; kiemTraX = kiemTraX + dichX) { if (mBanCo.banCo[kiemTraX, y0] != null) { return(false); } } return(true); } return(false); }
static public BanCo getBanCo() { if (Obj == null) { Obj = new BanCo(); Obj.banCo = new QuanCo[8, 8]; Obj.xepQuanCo(); } return(Obj); }
} //Hàm lấy màu cờ public bool MoveHopLe(int x0, int y0, int x1, int y1, BanCo mBanCo) { QuanCo vtMoi = mBanCo.banCo[x1, y1]; if ((vtMoi == null) || (mauCo != vtMoi.LayMau())) { return(KiemTraVT(x0, y0, x1, y1, mBanCo)); } return(false); }
protected override bool KiemTraVT(int x0, int y0, int x1, int y1, BanCo mBanCo) { int dentaX = x1 - x0; int dentaY = y1 - y0; if (((dentaX >= -1) && (dentaX <= 1)) && ((dentaY >= -1) && (dentaY <= 1))) { return(true); } return(false); }
protected override bool KiemTraVT(int x0, int y0, int x1, int y1, BanCo mBanCo) { if ((y0 == y1 + 1) || (y0 == y1 - 1)) { if ((x0 == x1 + 2) || (x0 == x1 - 2)) { return(true); } } if ((y0 == y1 + 2) || (y0 == y1 - 2)) { if ((x0 == x1 + 1) || (x0 == x1 - 1)) { return(true); } } return(false); }
protected override bool KiemTraVT(int x0, int y0, int x1, int y1, BanCo mBanCo) { if ((y1 - y0 == x1 - x0) || (y1 - y0 == x0 - x1)) { // Kiểm tra các ô trên đường đi xem có trống hay k int dichX = (x1 - x0 > 0) ? 1 : -1; int dichY = (y1 - y0 > 0) ? 1 : -1; int kiemTraX; int kiemTraY; for (kiemTraX = x0 + dichX, kiemTraY = y0 + dichY; kiemTraX != x1; kiemTraX = kiemTraX + dichX, kiemTraY = kiemTraY + dichY) { if (mBanCo.banCo[kiemTraX, kiemTraY] != null) { return(false); } } return(true); } return(false); }
protected virtual bool KiemTraVT(int x0, int y0, int x1, int y1, BanCo mBanCo) { return(false); } //Kiểm tra vị trí di chuyển hợp lệ
protected override bool KiemTraVT(int x0, int y0, int x1, int y1, BanCo mBanCo) { QuanCo vtMoi = mBanCo.banCo[x1, y1]; if (vtMoi == null) //Nếu vị trí mới trống { if (y0 == y1) { if (LayMau() == 'W') { if (x0 == 1) { if (x1 == x0 + 1 || x1 == x0 + 2) { return(true); } } else { if (x1 == x0 + 1) { return(true); } } } else { if (x0 == 6) { if (x1 == x0 - 1 || x1 == x0 - 2) { return(true); } } else if (x1 == x0 - 1) { return(true); } } } } else { //Nếu vị trí mới đã bị chiếm { if ((y0 == y1 + 1) || (y0 == y1 - 1)) { if (LayMau() == 'W') { //Nếu trước mặt là quân đen if (x1 == x0 + 1) { return(true); } } else { //Nếu trước mặt là quân trắng if (x1 == x0 - 1) { return(true); } } } } } return(false); }