// اذا القطعه كانت مهدده وعند انتقالها للمكان الجديد تكون غير مهدد تعيد حسب اهميتها مثلا جندي 60 القلعه 65 وغير ذلك 0 public int not_threatened()//good { int[,] help = new int[8, 8]; int p1, p2; if (playernum == -1) { p1 = kingsplace[0].X; p2 = kingsplace[0].Y; } else { p1 = kingsplace[1].X; p2 = kingsplace[1].Y; } king k = new king(new Point(p1, p2), mat, picbox, playernum, kings, rooks); if (k.toking(befor.X, befor.Y, mat, picbox, playernum * -1) != new Point(-1, -1)) { for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { help[i, j] = mat[i, j]; } } help[after.X, after.Y] = help[befor.X, befor.Y]; help[befor.X, befor.Y] = 0; if (k.toking(after.X, after.Y, help, picbox, playernum * -1) == new Point(-1, -1)) { switch (help[after.X, after.Y]) { case 1: case -1: return(60); case 2: case -2: return(65); case 3: case -3: return(70); case 4: case -4: return(75); case 5: case -5: return(80); case 6: case -6: return(85); default: break; } } else { return(0); } } return(0); }
public List <Point> helping(int kk, int[,] mat4, int x11, int y11, PictureBox[] picbox3, int[] kings3, int[] rooks3) { int[,] help = new int[8, 8]; Point pos11 = new Point(x11, y11); king k13 = new king(pos11, mat4, picbox3, kk, kings3, rooks3); Point poo = new Point(); Point po = k13.toking(x11, y11, mat4, picbox3, kk); List <Point> lst5 = new List <Point>(); Node <Point> nd5 = lst5.GetFirst(); for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { help[i, j] = mat4[i, j]; } } help[x11, y11] = kk; if (k13.toking(po.X, po.Y, help, picbox3, kk * -1) == new Point(-1, -1)) { return(lst5); } else { poo = k13.toking(po.X, po.Y, help, picbox3, kk * -1); nd5 = lst5.Insert(nd5, poo); help[poo.X, poo.Y] = kk; while (k13.toking(po.X, po.Y, help, picbox3, kk * -1) != new Point(-1, -1)) { Point pt = k13.toking(po.X, po.Y, help, picbox3, kk * -1); nd5 = lst5.Insert(nd5, pt); help[pt.X, pt.Y] = kk; } } Node <Point> pos = lst5.GetFirst(); while (pos != null) { picbox3[pos.GetInfo().X * 10 + pos.GetInfo().Y - 2 * pos.GetInfo().X].Enabled = true; pos = pos.GetNext(); } return(lst5); }
//عند انتقال القطعه للمكان الجديد هل تكن مهدده من قطع اخرى اذا كانت نعم مهدده تعيد-50وغير ذلك تعيد 50 public int after_click_threatened() // good { int x1, y1; int[,] help = new int[8, 8]; if (playernum == -1) { x1 = kingsplace[0].X; y1 = kingsplace[0].Y; } else { x1 = kingsplace[1].X; y1 = kingsplace[1].Y; } king k = new king(new Point(x1, y1), mat, picbox, playernum, kings, rooks); for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { help[i, j] = mat[i, j]; } } help[after.X, after.Y] = help[befor.X, befor.Y]; help[befor.X, befor.Y] = 0; if (k.toking(after.X, after.Y, help, picbox, playernum * -1) != new Point(-1, -1)) { return(-50); } else { return(50); } }
//اذا حركنا القطعه للمكان الجديد هل يكون ملك العدو مهدد تعيد 70 وغير ذلك 0 public int enemyking_threatened() // good { int x1, y1; int[,] help = new int[8, 8]; if (playernum == -1) { x1 = kingsplace[1].X; y1 = kingsplace[1].Y; } else { x1 = kingsplace[0].X; y1 = kingsplace[0].Y; } king k = new king(new Point(x1, y1), mat, picbox, playernum, kings, rooks); for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { help[i, j] = mat[i, j]; } } if (k.toking(x1, y1, help, picbox, playernum * -1) != new Point(-1, -1)) // king enemy are threated before { return(0); } else // king enemy not threated before { help[after.X, after.Y] = help[befor.X, befor.Y]; help[befor.X, befor.Y] = 0; if (k.toking(after.X, after.Y, help, picbox, playernum * -1) != new Point(-1, -1)) // king enemy is threted after { return(70); } else { return(0); } } }
public bool deathofking(int i1, int j1, int[,] mat2, PictureBox[] picbox2, int[] kings2, int[] rooks2, int k11) { Node <Point> np1 = null; Point pos1 = new Point(i1, j1); List <Point> lst3 = new List <Point>(); king k12 = new king(pos1, mat2, picbox2, k11 * -1, kings2, rooks2); if (k12.toking(i1, j1, mat2, picbox2, k11) == new Point(-1, -1)) { return(false); } try { lst3 = k12.placestomove(); Point pp1 = lst3.GetFirst().GetInfo(); np1 = lst3.GetFirst(); } catch (Exception) { } while (np1 != null) { if (k12.toking(np1.GetInfo().X, np1.GetInfo().Y, mat2, picbox2, k11) != new Point(-1, -1)) { np1 = lst3.Remove(np1); } else { break; } } if (lst3.IsEmpty() == true) { return(true); } else { return(false); } }
//להציג מקומות האפשריות בצבע ירוק public void showGreenplaces(int i, int j, PictureBox[] pics) { Node <Point> np = null; Point pos = new Point(i, j); List <Point> lst2 = new List <Point>(); king k1 = new king(pos, mat, pics, playernum, kings, rooks); try { lst2 = k1.placestomove(); Point pp = lst2.GetFirst().GetInfo(); np = lst2.GetFirst(); } catch (Exception) { } while (np != null) { int x = np.GetInfo().X; int y = np.GetInfo().Y; int n = x * 10 + y - 2 * x; if (k1.toking(x, y, mat, picbox, playernum * -1) == new Point(-1, -1)) { pics[n].BackColor = Color.Green; pics[n].Enabled = true; } else { pics[n].BackColor = Color.Red; } pics[n].Enabled = true; pics[n].Visible = true; np = np.GetNext(); } }
public void showGreenplaces(int i, int j, PictureBox[] pics) { Node <Point> np = null; Point pos = new Point(i, j); List <Point> lst2 = new List <Point>(); Point pt = new Point(); knight r1 = new knight(pos, mat, pics, playernum, kingplaces, kings, rooks); if (playernum == -1) { pt = kingplaces[0]; } else { pt = kingplaces[1]; } king k = new king(pt, mat, picbox, playernum, kings, rooks); bool t = k.deathofking(pt.X, pt.Y, mat, picbox, kings, rooks, playernum * -1); try { lst2 = r1.placestomove(); Point pp = lst2.GetFirst().GetInfo(); np = lst2.GetFirst(); } catch (Exception) { } int[,] help = new int[8, 8]; for (int ii = 0; ii < 8; ii++) { for (int jj = 0; jj < 8; jj++) { help[ii, jj] = mat[ii, jj]; } } while (np != null) { int x = np.GetInfo().X; int y = np.GetInfo().Y; int n = x * 10 + y - 2 * x; int v = help[x, y]; help[x, y] = playernum; if (k.toking(pt.X, pt.Y, help, picbox, playernum * -1) == new Point(-1, -1)) { pics[n].BackColor = Color.Green; pics[n].Enabled = true; pics[n].Visible = true; } else { pics[n].BackColor = Color.Red; pics[n].Enabled = false; pics[n].Visible = true; } help[x, y] = v; np = np.GetNext(); } }
void gooo(int x, int y) { game_main.loss = 0; if (playernum == 1) { timer1.Start(); } else { timer2.Start(); } if (flage == true) { canx = x; cany = y; flage = false; } if (steps == 40) { for (int i = 0; i < 64; i++) { picbox[i].Enabled = false; } MessageBox.Show("equality "); result = "drow"; winer = 3; } game_main pppp = new game_main(); computerplayer comp = new computerplayer(); if (picbox[x * 10 + y - 2 * x].BackColor == Color.Green || picbox[x * 10 + y - 2 * x].BackColor == Color.Yellow) { pppp.IFgreenmovelastItem(lastclick, picbox, mat, x, y, pppp.chessimage(mat[lastclick.X, lastclick.Y]), kings, rooks, kingsplace); setlosser(); if (game_main.loss > 0) { lossb += game_main.loss + ","; } else if (game_main.loss != 0) { lossw += game_main.loss + ","; } history(x, y, canx, cany); flage = true; pppp.refreshcolors(picbox, playernum, mat); if (Form2.justkings(mat) == true) { steps++; } playernum = playernum * -1; pppp.playerrole(playernum, picbox, mat); } else { pppp.refreshcolors(picbox, playernum, mat); Wathitem(x, y); } if (playernum == 1) { timer1.Stop(); timer2.Start(); } else { timer2.Stop(); timer1.Start(); } int x1 = kingsplace[0].X; int y1 = kingsplace[0].Y; int x2 = kingsplace[1].X; int y2 = kingsplace[1].Y; Point kp = new Point(-1, -1); king k1 = new king(new Point(x1, y1), mat, picbox, playernum, kings, rooks); king k2 = new king(new Point(x2, y2), mat, picbox, playernum, kings, rooks); if (k1.toking(x1, y1, mat, picbox, 1) != new Point(-1, -1)) { k1.redtoging(new Point(x1, y1), picbox, -1); } if (k2.toking(x2, y2, mat, picbox, -1) != new Point(-1, -1)) { k2.redtoging(new Point(x2, y2), picbox, 1); } if (k1.toking(x1, y1, mat, picbox, 1) != new Point(-1, -1) && playernum == -1) { k1.shah(x1, y1, picbox, mat, -1); } if (k2.toking(x2, y2, mat, picbox, -1) != new Point(-1, -1) && playernum == 1) { k2.shah(x2, y2, picbox, mat, 1); } if (k1.deathofking(x1, y1, mat, picbox, kings, rooks, 1) == true) { if (k1.helping(1, mat, x1, y1, picbox, kings, rooks).IsEmpty() == true) { timer1.Stop(); timer2.Stop(); k1.shahmeet("wihte lose!"); result = "1"; winer = 1; } } if (k2.deathofking(x2, y2, mat, picbox, kings, rooks, -1) == true) { if (k2.helping(-1, mat, x2, y2, picbox, kings, rooks).IsEmpty() == true) { timer1.Stop(); timer2.Stop(); k2.shahmeet("blcak lose!"); result = "-1"; winer = -1; } } lastclick = new Point(x, y); }
// اذا كانت القطعه ملك وهو مهددتعيد90 واذا كانت قطعه اخرى وتستطيع مساعده الملك في المكان الجديد تعيد 100 ,والا تعيد -50 وغير ذلك تعيد 0 public int my_king_is_threated() // good { List <Point> lst = new List <Point>(); int x, y; int[,] help = new int[8, 8]; if (playernum == -1) // that the king point { x = kingsplace[0].X; y = kingsplace[0].Y; } else { x = kingsplace[1].X; y = kingsplace[1].Y; } king k = new king(new Point(x, y), mat, picbox, playernum, kings, rooks); for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { help[i, j] = mat[i, j]; } } if (help[befor.X, befor.Y] == 6 * playernum) // if this item king { if (k.toking(befor.X, befor.Y, help, picbox, playernum * -1) == new Point(-1, -1)) //no threated king { return(0); } else //threated king { help[after.X, after.Y] = help[befor.X, befor.Y]; help[befor.X, befor.Y] = 0; if (k.toking(after.X, after.Y, help, picbox, playernum * -1) == new Point(-1, -1)) { return(90); } else { return(-50); } } } else // the item not king { if (k.toking(x, y, help, picbox, playernum * -1) != new Point(-1, -1))// the king is threated { help[after.X, after.Y] = help[befor.X, befor.Y]; help[befor.X, befor.Y] = 0; if (k.toking(x, y, help, picbox, playernum * -1) == new Point(-1, -1))// after move item king not threted { return(100); } else { return(-50); // the king is threated & item can't help } } } return(0); // no threteds }