Пример #1
0
        public static void ChangeGameTurn(Client IsPlaying)
        {
            int IndexOpponent = ClientManager.byPseudo(IsPlaying.info_game.opponent);
            int IndexClient   = ClientManager.byPseudo(IsPlaying.info_main.pseudo);

            if (IndexClient == -1 || IndexOpponent == -1)
            {
                return;
            }

            ClientManager.ListClient[IndexClient].info_game.timeTourCount   = Environment.TickCount;
            ClientManager.ListClient[IndexOpponent].info_game.timeTourCount = Environment.TickCount;

            ClientManager.ListClient[IndexClient].info_game.timeExist   = 0;
            ClientManager.ListClient[IndexOpponent].info_game.timeExist = 0;

            if (IsPlaying.info_game.tour)
            {
                ClientManager.ListClient[IndexClient].info_game.tour   = !ClientManager.ListClient[IndexClient].info_game.tour;
                ClientManager.ListClient[IndexOpponent].info_game.tour = !ClientManager.ListClient[IndexOpponent].info_game.tour;
            }

            if (!EndGame.canMakeAnAction(WhosNext(IsPlaying)))
            {
                ClientManager.ListClient[IndexClient].SendMsg("Partie terminée");
                ClientManager.ListClient[IndexOpponent].SendMsg("Partie terminée");
                ClientManager.RedirectEnding(WhosNext(IsPlaying), false);
            }
        }
Пример #2
0
        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);
        }