Example #1
0
        private async void BtnTeamClick(object sender, EventArgs e)
        {
            var teamSelect = new TeamSelect();

            if (teamSelect.ShowDialog() == DialogResult.OK)
            {
                // Simulate to enter in a gym before select a team.
                var client     = Logic.Logic.Client;
                var mapObjects = await client.Map.GetMapObjects();

                var mapCells = mapObjects.Item1.MapCells;

                var pokeGyms = mapCells.SelectMany(i => i.Forts)
                               .Where(i => i.Type == FortType.Gym);
                if (pokeGyms.Any())
                {
                    var pokegym = pokeGyms.First();

                    var resp = await GetGym(pokegym.Id, pokegym.Latitude, pokegym.Longitude);

                    if (resp.Status)
                    {
                        var team = teamSelect.selected;
                        await Task.Delay(1000); // Pause to simulate human speed.

                        var resp2 = await SelectTeam(team);

                        if (resp2.Status)
                        {
                            Logger.ColoredConsoleWrite(ConsoleColor.Green, "Selected Team: " + team.ToString());
                            Execute();
                        }
                        else
                        {
                            MessageBox.Show(resp.Message + "Set Team failed!", "Set Team Status", MessageBoxButtons.OK);
                        }
                    }
                    else
                    {
                        MessageBox.Show(resp.Message + "Set Team failed!", "Set Team Status", MessageBoxButtons.OK);
                    }
                }
                else
                {
                    MessageBox.Show("Set Team failed!\n non nearby Gym ", "Set Team Status", MessageBoxButtons.OK);
                }
            }
            else
            {
                MessageBox.Show("Set Team canceled!", "Set Team Status", MessageBoxButtons.OK);
            }
        }
Example #2
0
        private void BtnTeamClick(object sender, EventArgs e)
        {
            var teamSelect = new TeamSelect();

            if (teamSelect.ShowDialog() == DialogResult.OK)
            {
                // Simulate to enter in a gym before select a team.
                var client     = Logic.Logic.objClient;
                var mapObjects = client.Map.GetMapObjects().Result;
                var mapCells   = mapObjects.Item1.MapCells;

                var pokeGyms = mapCells.SelectMany(i => i.Forts)
                               .Where(i => i.Type == FortType.Gym);
                if (pokeGyms.Any())
                {
                    var pokegym = pokeGyms.First();

                    var resp = GetGym(pokegym.Id, pokegym.Latitude, pokegym.Longitude).Result;
                    if (resp.Status)
                    {
                        var team = teamSelect.selected;
                        RandomHelper.RandomSleep(1000, 1100);
                        var resp2 = SelectTeam(team).Result;
                        if (resp2.Status)
                        {
                            Logger.ColoredConsoleWrite(ConsoleColor.Green, "Selected Team: " + team.ToString());
                            Execute();
                        }
                        else
                        {
                            MessageBox.Show(resp.Message + th.TS("Set Team failed!"), th.TS("Set Team Status"), MessageBoxButtons.OK);
                        }
                    }
                    else
                    {
                        MessageBox.Show(resp.Message + th.TS("Set Team failed!"), th.TS("Set Team Status"), MessageBoxButtons.OK);
                    }
                }
                else
                {
                    MessageBox.Show(th.TS("Set Team failed!\n non nearby Gym "), th.TS("Set Team Status"), MessageBoxButtons.OK);
                }
            }
            else
            {
                MessageBox.Show(th.TS("Set Team canceled!"), th.TS("Set Team Status"), MessageBoxButtons.OK);
            }
        }