private void Form1_Load(object sender, EventArgs e) { //SoundPlayer game_music = new SoundPlayer("D:\\Music.wav"); //game_music.Play(); for (int i = 1; i <= 64; i++) { my_button1[i].Visible = false; } for (int i = 1; i <= 8; i++) { promotion_buttons[i].Visible = false; } button65.Visible = false; button66.Visible = false; button67.Visible = true; button68.Visible = true; button69.Visible = true; button70.Visible = false; button79.Visible = false; button80.Visible = false; button81.Visible = false; button82.Visible = false; button83.Visible = false; chessGame c = new chessGame(); }
public void End_game(int player) { int lll = 0; for (int i = 1; i <= 64; i++) { if (chessGame.indxed[i] == player) { if (chessGame.c[i] == "King" && chessGame.indxed[i] == player) { Games1 = new chessGame(new King()); lll += Games1.all_possible_move(i, arr); king_posi = i; continue; } else if (chessGame.c[i] == "Pawn" && chessGame.indxed[i] == player) { Games1 = new chessGame(new Pawn()); variable = "Pawn"; } else if (chessGame.c[i] == "Bishop" && chessGame.indxed[i] == player) { Games1 = new chessGame(new Bishop()); variable = "Bishop"; } else if (chessGame.c[i] == "Knight" && chessGame.indxed[i] == player) { Games1 = new chessGame(new Knight()); variable = "Knight"; } else if (chessGame.c[i] == "Rook" && chessGame.indxed[i] == player) { Games1 = new chessGame(new Rook()); variable = "Rook"; } else if (chessGame.c[i] == "Queen" && chessGame.indxed[i] == player) { Games1 = new chessGame(new Queen()); variable = "Queen"; } x = Games1.all_possible_move(i, arr); Try(i, variable); lll += l; } } if (lll == 0) // so there is no possible move for any piece { if (p6.enemy[king_posi] == 0) { button81.Visible = true; for (int i = 1; i <= 64; i++) { my_button1[i].Visible = false; } } else if (player == 1) { button82.Visible = true; for (int i = 1; i <= 64; i++) { my_button1[i].Visible = false; } button79.BackColor = Color.Green; button80.BackColor = Color.Red; } else { button83.Visible = true; for (int i = 1; i <= 64; i++) { my_button1[i].Visible = false; } button80.BackColor = Color.Green; button79.BackColor = Color.Red; } } }
public void GAME(int button) { if (Start == 0) { return; } if (CHESS == 0 && my_button1[button].BackgroundImage != null) { CHESS = 1; l = 0; flag = 0; BUTTON = button; Check = false; if (chessGame.c[button] == "King") { Games = new chessGame(new King()); x = Games.all_possible_move(button, arr); if (p6.Special_Move(button, arr2) == true) { arr[x] = arr2[0]; x++; if (arr2[1] != 0) { arr[x] = arr2[1]; x++; flag++; } flag++; } for (int i = 0; i < x; i++) { LIGHT[i] = arr[i]; } l = x; light(LIGHT, l); Check = true; } else if (chessGame.c[button] == "Pawn") { variable = "Pawn"; Games = new chessGame(new Pawn()); } else if (chessGame.c[button] == "Knight") { variable = "Knight"; Games = new chessGame(new Knight()); } else if (chessGame.c[button] == "Bishop") { variable = "Bishop"; Games = new chessGame(new Bishop()); } else if (chessGame.c[button] == "Rook") { variable = "Rook"; Games = new chessGame(new Rook()); } else if (chessGame.c[button] == "Queen") { variable = "Queen"; Games = new chessGame(new Queen()); } if (!Check) { x = Games.all_possible_move(button, arr); Try(button, variable); light(LIGHT, l); } } else if (CHESS == 1 && (my_button1[button] == null || chessGame.indxed[button] != chessGame.indxed[BUTTON])) { if (chessGame.c[BUTTON] == "King") { if (Games.move_OR_kill(BUTTON, button, l, LIGHT)) { my_button1[button].BackgroundImage = my_button1[BUTTON].BackgroundImage; my_button1[BUTTON].BackgroundImage = null; number_of_moves++; // السطور دي كلها عشان التحصين او التبيت if ((arr2[0] == button || arr2[1] == button) && (King.king1 == 1 || King.king2 == 1)) { if ((button == 7 && BUTTON == 5) || (button == 63 && BUTTON == 61)) { my_button1[BUTTON + 1].BackgroundImage = my_button1[BUTTON + 3].BackgroundImage; my_button1[BUTTON + 3].BackgroundImage = null; chessGame.c[BUTTON + 3] = null; chessGame.c[BUTTON + 1] = "Rook"; chessGame.indxed[BUTTON + 3] = 0; if (BUTTON == 5) { chessGame.indxed[BUTTON + 1] = 2; } else { chessGame.indxed[BUTTON + 1] = 1; } } else if ((button == 3 && BUTTON == 5) || (button == 59 && BUTTON == 61)) { my_button1[BUTTON - 1].BackgroundImage = my_button1[BUTTON - 4].BackgroundImage; my_button1[BUTTON - 4].BackgroundImage = null; chessGame.c[BUTTON - 4] = null; chessGame.c[BUTTON - 1] = "Rook"; chessGame.indxed[BUTTON - 4] = 0; if (BUTTON == 5) { chessGame.indxed[BUTTON - 1] = 2; } else { chessGame.indxed[BUTTON - 1] = 1; } } } } BackColor_HandlePlayer(LIGHT, l); } else { int warn_red = 0; if (Games.move_OR_kill(BUTTON, button, l, LIGHT)) { warn_red = 1; my_button1[button].BackgroundImage = my_button1[BUTTON].BackgroundImage; my_button1[BUTTON].BackgroundImage = null; number_of_moves++; postion = button; } if (warn_red == 1) { BackColor_HandlePlayer(LIGHT, l); convert(button, BUTTON); warn_red = 0; } else { BackColor_HandlePlayer(LIGHT, l); } } if (number_of_moves % 2 == 1) { End_game(1); } else if (number_of_moves % 2 == 0) { End_game(2); } Draw(); BUTTON = button; CHESS = 0; } else if (CHESS == 1) { BackColor_HandlePlayer(LIGHT, l); BUTTON = button; CHESS = 0; } }