private static void HandleEvent(GymDetailInfoEvent ev, ISession session)
        {
            var GymDeployed = new GymDeployResponse();
            var Deployed    = GymDeployed.GymStatusAndDefenders.GymDefender.ToList();

            Logger.Write($"Visited Gym: {ev.Name} | Team: {ev.Team} | Gym Players: {ev.Players} | Free Spots: {6 - Deployed.Count}", LogLevel.Gym,
                         (ev.Team == TeamColor.Red)
                    ? ConsoleColor.Red
                    : (ev.Team == TeamColor.Yellow ? ConsoleColor.Yellow : ConsoleColor.Blue));
        }
        //TODO - move to string translation later.
        private static void HandleEvent(GymDeployEvent ev, ISession session)
        {
            var Info        = new GymDetailInfoEvent();
            var GymDeployed = new GymDeployResponse();
            var Deployed    = GymDeployed.GymStatusAndDefenders.GymDefender.ToList();

            Logger.Write($"Great!!! Your {ev.PokemonId.ToString()} is now defending {ev.Name} GYM. | Free Spots: {6 - Deployed.Count}",
                         LogLevel.Gym, ConsoleColor.Green);

            if (session.LogicSettings.NotificationConfig.EnablePushBulletNotification)
            {
                PushNotificationClient.SendNotification(session, $"Gym Post", $"Great!!! Your {ev.PokemonId.ToString()} is now defending {ev.Name} GYM.\nFree Spots: {6 - Deployed.Count}", true).ConfigureAwait(false);
            }
        }
Esempio n. 3
0
        public static void DeployPokemonInGym(Client client, FortData gym, PokemonData pokemon, IEnumerable <PokemonData> pokemons)
        {
            RandomHelper.RandomSleep(400);

            GymDeployResponse deployResponse = client.Fort.GymDeployPokemon(gym.Id, pokemon.Id);

            if (deployResponse.Result == GymDeployResponse.Types.Result.Success)
            {
                var pokesInGym = pokemons.Count(x => ((!x.IsEgg) && (x.DeployedFortId != ""))) + 1;
                Logger.ColoredConsoleWrite(gymColorLog, "(Gym) " + pokemon.PokemonId + " deployed into Gym (" + pokesInGym + " in total).");
                AddVisited(gym.Id, 3600000);
                return;
            }

            if (deployResponse.Result == GymDeployResponse.Types.Result.ErrorAlreadyHasPokemonOnFort)
            {
                Logger.Warning("(Gym) You already have a pokemon deployed in this Gym");
                AddVisited(gym.Id, 3600000);
                return;
            }

            if (deployResponse.Result == GymDeployResponse.Types.Result.ErrorTooManyOfSameKind && GlobalVars.Gyms.DeployPokemons >= 0)
            {
                Logger.Warning("(Gym) Too many Pokemons of the same kind are already deployed in Gym. Deploying a random Pokemon...");
                var TempDeployPokemonsBackupVar = GlobalVars.Gyms.DeployPokemons;
                GlobalVars.Gyms.DeployPokemons = -1; // -1 indicated we have already tried to do so
                var buddyID = 0UL;
                if (client.Player.PlayerResponse.PlayerData.BuddyPokemon != null)
                {
                    buddyID = client.Player.PlayerResponse.PlayerData.BuddyPokemon.Id;
                }
                DeployPokemonInGym(client, gym, getPokeToPut(client, buddyID, gym.GuardPokemonCp), pokemons);
                GlobalVars.Gyms.DeployPokemons = TempDeployPokemonsBackupVar; // return to original setting
                return;
            }

            if (deployResponse.Result == GymDeployResponse.Types.Result.ErrorRaidActive) // should never happen because we check before
            {
                Logger.Warning("(Gym) A RAID is currently active, we cannot deploy a pokemon now.");
                return;
            }

            Logger.Debug("(Gym) Error: " + deployResponse.Result);
        }