public static void checkJumpingNotPlayed(Client isPlaying, int myX, int myY, bool noPawn = false) { int IndexClient = ClientManager.byPseudo(isPlaying.info_main.pseudo); if (IndexClient == -1) { return; } bool playerTop = isPlaying.info_main.playerTop; for (int y1 = 0; y1 < ClientManager.ListClient[IndexClient].info_game.plateauCases.Length; y1++) { for (int x1 = 0; x1 < ClientManager.ListClient[IndexClient].info_game.plateauCases[y1].Length; x1++) { if (ClientManager.ListClient[IndexClient].info_game.plateauCases[y1][x1].pawnTop == playerTop && ClientManager.ListClient[IndexClient].info_game.plateauCases[y1][x1].pawnExist && (ClientManager.ListClient[IndexClient].info_game.plateauCases[y1][x1].Rec != ClientManager.ListClient[IndexClient].info_game.plateauCases[myY][myX].Rec) || noPawn) { for (int y2 = 0; y2 < ClientManager.ListClient[IndexClient].info_game.plateauCases.Length; y2++) { for (int x2 = 0; x2 < ClientManager.ListClient[IndexClient].info_game.plateauCases[y2].Length; x2++) { if (ClientManager.ListClient[IndexClient].info_game.plateauCases[y2][x2].pawnTop != playerTop && ClientManager.ListClient[IndexClient].info_game.plateauCases[y2][x2].pawnExist) { if (!ClientManager.ListClient[IndexClient].info_game.plateauCases[y1][x1].king) // Pion normal { if (Attack.detectCanAtk(isPlaying, x1, y1)) { ClientManager.ListClient[IndexClient].info_game.plateauCases[y1][x1].isnotcareful = true; } } else // Reine { if (Attack.detectCanAtkForKing(isPlaying, x1, y1)) { ClientManager.ListClient[IndexClient].info_game.plateauCases[y1][x1].isnotcareful = true; } } } } } } } } Match.SynchroWithOpponents(isPlaying); }
public static bool pawnMoving(Client isPlaying, int x, int y, int xSelected, int ySelected) { if (isPlaying.info_game.asked) { isPlaying.SendMsg("En attente de la réponse ..."); return(false); } if (isPlaying.info_main.playerTop != isPlaying.info_game.plateauCases[ySelected][xSelected].pawnTop) { Careful.isNotCareful(isPlaying, ySelected, xSelected); return(false); } if (!isPlaying.info_game.tour) { isPlaying.SendMsg("Ce n'est pas votre tour !"); return(false); } if (isPlaying.info_game.iscombo) { if (!isPlaying.info_game.plateauCases[ySelected][xSelected].mainCombo) { isPlaying.SendMsg("Vous ne pouvez jouer que le pion 'combo'"); return(false); } } int IndexClient = ClientManager.byPseudo(isPlaying.info_main.pseudo); Client Player = playerManager.WhosNext(isPlaying); Client Opponent = playerManager.GetOpponent(Player); bool playerTop = Player.info_main.playerTop; if (ClientManager.ListClient[IndexClient].info_game.plateauCases[y][x].pawnExist) { return(false); } if (x == xSelected && y == ySelected) { isPlaying.SendMsg("Choix annulé"); return(false); } else if (!ClientManager.ListClient[IndexClient].info_game.plateauCases[y][x].pawnExist) { int ruleDistance = Distance.distanceStatus(isPlaying, y, x, ySelected, xSelected, playerTop); if (ruleDistance == 0 || (ruleDistance != 2 && ClientManager.ListClient[IndexClient].info_game.plateauCases[ySelected][xSelected].mainCombo && Player.info_game.iscombo) || !Distance.sameDiagonal(y, x, ySelected, xSelected)) { isPlaying.SendMsg("Vous ne pouvez pas faire cela"); return(false); } //sendAnimation(isPlaying, (int)BunifuAnimatorNS.AnimationType.Transparent, x, y); Careful.resetNotCarefulOpponent(Opponent); Careful.checkJumpingNotPlayed(Player, x, y); ClientManager.ListClient[IndexClient].info_game.plateauCases[y][x].king = ClientManager.ListClient[IndexClient].info_game.plateauCases[ySelected][xSelected].king; ClientManager.ListClient[IndexClient].info_game.plateauCases[ySelected][xSelected].king = false; Match.SynchroWithOpponents(isPlaying); setCase(isPlaying, x, y, imageManager.getPawnImgByPlayer(playerTop, ClientManager.ListClient[IndexClient].info_game.plateauCases[y][x].king), true, playerTop); setCase(isPlaying, xSelected, ySelected); imageManager.pawnToKing(isPlaying, playerTop, x, y); if (ruleDistance == 2) { bool isKing = ClientManager.ListClient[IndexClient].info_game.plateauCases[y][x].king; int xPawn = Distance.xPawn; int yPawn = Distance.yPawn; //sendAnimation(isPlaying, (int)BunifuAnimatorNS.AnimationType.Particles, xPawn, yPawn); setCase(isPlaying, xPawn, yPawn); Opponent.info_game.pawnAlive--; if (!isKing) { if (Attack.detectCanAtk(Player, x, y)) { Player.info_game.iscombo = true; ClientManager.ListClient[IndexClient].info_game.plateauCases[y][x].mainCombo = true; Match.SynchroWithOpponents(isPlaying); return(true); } } else { if (Attack.detectCanAtkForKing(Player, x, y)) { Player.info_game.iscombo = true; ClientManager.ListClient[IndexClient].info_game.plateauCases[y][x].mainCombo = true; Match.SynchroWithOpponents(isPlaying); return(true); } } Player.info_game.iscombo = false; ClientManager.ListClient[IndexClient].info_game.plateauCases[y][x].mainCombo = false; Match.SynchroWithOpponents(isPlaying); if (EndGame.OpponentIsDead(Opponent)) { return(true); } } playerManager.ChangeGameTurn(Player); xSelected = -1; ySelected = -1; } return(true); }
public static bool canMakeAnAction(Client isPlaying) { int IndexClient = ClientManager.byPseudo(isPlaying.info_main.pseudo); if (IndexClient == -1) { return(false); } bool playerTop = isPlaying.info_main.playerTop; for (int y = 0; y < ClientManager.ListClient[IndexClient].info_game.plateauCases.Length; y++) { for (int x = 0; x < ClientManager.ListClient[IndexClient].info_game.plateauCases[y].Length; x++) { if (ClientManager.ListClient[IndexClient].info_game.plateauCases[y][x].pawnTop == playerTop && ClientManager.ListClient[IndexClient].info_game.plateauCases[y][x].pawnExist) { bool isKing = ClientManager.ListClient[IndexClient].info_game.plateauCases[y][x].king; if (!isKing) { if (Attack.detectCanAtk(isPlaying, x, y)) { return(true); } } if (isKing) { if (Attack.detectCanAtkForKing(isPlaying, x, y)) { return(true); } } if (!isKing) { int addX = 1; int addY = 1; if (playerTop) { if (y + addY <= 9 && x + addX <= 9) { if (!ClientManager.ListClient[IndexClient].info_game.plateauCases[y + addY][x + addX].pawnExist) { return(true); } } if (y + addY <= 9 && x + (addX * -1) >= 0) { if (!ClientManager.ListClient[IndexClient].info_game.plateauCases[y + addY][x + addX * -1].pawnExist) { return(true); } } } else { addX = -1; addY = -1; if (y + addY >= 0 && x + addX >= 0) { if (!ClientManager.ListClient[IndexClient].info_game.plateauCases[y + addY][x + addX].pawnExist) { return(true); } } if (y + addY >= 0 && x + (addX * -1) <= 9) { if (!ClientManager.ListClient[IndexClient].info_game.plateauCases[y + addY][x + addX * -1].pawnExist) { return(true); } } } } } } } return(false); }