コード例 #1
0
ファイル: Logic.cs プロジェクト: xxxx0107/Pokemont
        private async Task StatsLog(Client client)
        {
            dontspam++;
            var profil = await _client.GetCachedProfile();

            var stats = await _inventory.GetPlayerStats();

            var c = stats.FirstOrDefault();

            int l = c.Level;

            var expneeded       = ((c.NextLevelXp - c.PrevLevelXp) - StringUtils.getExpDiff(c.Level));
            var curexp          = ((c.Experience - c.PrevLevelXp) - StringUtils.getExpDiff(c.Level));
            var curexppercent   = (Convert.ToDouble(curexp) / Convert.ToDouble(expneeded)) * 100;
            var pokemonToEvolve = (await _inventory.GetPokemonToEvolve(null)).Count();

            Logger.ColoredConsoleWrite(ConsoleColor.Cyan, "_____________________________");
            Logger.ColoredConsoleWrite(ConsoleColor.Cyan, "Level: " + c.Level);
            Logger.ColoredConsoleWrite(ConsoleColor.Cyan, "EXP Needed: " + expneeded);
            Logger.ColoredConsoleWrite(ConsoleColor.Cyan, $"Current EXP: {curexp} ({Math.Round(curexppercent)}%)");
            Logger.ColoredConsoleWrite(ConsoleColor.Cyan, "EXP to Level up: " + ((c.NextLevelXp) - (c.Experience)));
            Logger.ColoredConsoleWrite(ConsoleColor.Cyan, "KM Walked: " + c.KmWalked);
            Logger.ColoredConsoleWrite(ConsoleColor.Cyan, "PokeStops visited: " + c.PokeStopVisits);
            Logger.ColoredConsoleWrite(ConsoleColor.Cyan, "Stardust: " + profil.Profile.Currency.ToArray()[1].Amount);
            Logger.ColoredConsoleWrite(ConsoleColor.Cyan, "Pokemon to evolve: " + pokemonToEvolve);
            Logger.ColoredConsoleWrite(ConsoleColor.Cyan, "Pokemons: " + await _inventory.getPokemonCount() + "/" + profil.Profile.PokeStorage);
            Logger.ColoredConsoleWrite(ConsoleColor.Cyan, "Items: " + await _inventory.getInventoryCount() + "/" + profil.Profile.ItemStorage);
            if (dontspam >= 3)
            {
                dontspam = 0;
                PokeService data = null;
                try
                {
                    var clientx = new WebClient();
                    clientx.Headers.Add("user-agent", "PokegoBot-Ar1i-Github");
                    var jsonString = clientx.DownloadString("https://go.jooas.com/status");
                    data = new JavaScriptSerializer().Deserialize <PokeService>(jsonString);
                }
                catch (Exception)
                {
                }

                if (data != null)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.White, "");
                    Logger.ColoredConsoleWrite(ConsoleColor.Cyan, "PokemonGO Server Status:");
                    if (data.go_online)
                    {
                        if (data.go_idle > 60)
                        {
                            int gohour = Convert.ToInt32(data.go_idle / 60);

                            if (gohour > 24)
                            {
                                int goday = gohour / 24;

                                Logger.ColoredConsoleWrite(ConsoleColor.Green, "Online since ~" + goday + " day(s).");
                            }
                            else
                            {
                                Logger.ColoredConsoleWrite(ConsoleColor.Green, "Online since ~" + gohour + "h.");
                            }
                        }
                        else
                        {
                            Logger.ColoredConsoleWrite(ConsoleColor.Green, "Online since ~" + data.go_idle + " min.");
                        }

                        Logger.ColoredConsoleWrite(ConsoleColor.Green, "Server anwsers in ~" + data.go_response + " seconds.");
                    }
                    else
                    {
                        Logger.ColoredConsoleWrite(ConsoleColor.Red, "Pokemon GO Servers: Offline.");
                    }
                    Logger.ColoredConsoleWrite(ConsoleColor.Cyan, "Pokemon Trainer Club Server Status:");
                    if (data.ptc_online)
                    {
                        if (data.ptc_idle > 60)
                        {
                            int ptchour = Convert.ToInt32(data.ptc_idle / 60);

                            if (ptchour > 24)
                            {
                                int ptcday = ptchour / 24;
                                Logger.ColoredConsoleWrite(ConsoleColor.Green, "Online since ~" + ptcday + " day(s).");
                            }
                            else
                            {
                                Logger.ColoredConsoleWrite(ConsoleColor.Green, "Online since ~" + ptchour + "h.");
                            }
                        }
                        else
                        {
                            Logger.ColoredConsoleWrite(ConsoleColor.Green, "Online since ~" + data.ptc_idle + " min.");
                        }

                        Logger.ColoredConsoleWrite(ConsoleColor.Green, "Server anwsers in ~" + data.ptc_response + " seconds.");
                    }
                    else
                    {
                        Logger.ColoredConsoleWrite(ConsoleColor.Red, "Pokemon Trainer Club: Offline.");
                    }
                }
                else
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Cant get Server Status from https://go.jooas.com/status");
                }
            }
            Logger.ColoredConsoleWrite(ConsoleColor.Cyan, "_____________________________");


            System.Console.Title = "PokeBot3 | User: "******" | Level " + c.Level + " - (" + ((c.Experience - c.PrevLevelXp) -
                                                                                                                     StringUtils.getExpDiff(c.Level)) + " / " + ((c.NextLevelXp - c.PrevLevelXp) - StringUtils.getExpDiff(c.Level)) + " | " + Math.Round(curexppercent) + "%) | Stardust: " + profil.Profile.Currency.ToArray()[1].Amount + " | " + _botStats.ToString();
            Vars.username    = profil.Profile.Username;
            Vars.xprate      = _botStats.xprate();
            Vars.catchrate   = _botStats.catchrate();
            Vars.stardust    = profil.Profile.Currency.ToArray()[1].Amount.ToString();
            Vars.evolvecount = pokemonToEvolve.ToString();
            Vars.pokemon     = await _inventory.getPokemonCount() + "/" + profil.Profile.PokeStorage;

            Vars.level      = "Level " + c.Level + " - (" + ((c.Experience - c.PrevLevelXp) - StringUtils.getExpDiff(c.Level)) + " / " + ((c.NextLevelXp - c.PrevLevelXp) - StringUtils.getExpDiff(c.Level)) + " | " + Math.Round(curexppercent) + "%)";
            Vars.percentage = Math.Round(curexppercent).ToString();
            Vars.items      = await _inventory.getInventoryCount() + "/" + profil.Profile.ItemStorage;
        }