Esempio n. 1
0
        private void ParseRaid(dynamic message)
        {
            try
            {
                //| Field | Details | Example | | ———— | —————————————————————– | ———— |
                //gym_id | The gym’s unique ID | "NGY2ZjBjY2Y3OTUyNGQyZWFlMjc3ODkzODM2YmI1Y2YuMTY=" |
                //latitude | The gym’s latitude | 43.599321 |
                //longitude | The gym’s longitude | 5.181415 |
                //spawn | The time at which the raid spawned | 1500992342 |
                //start | The time at which the raid starts | 1501005600 |
                //end | The time at which the raid ends | 1501007400 |
                //level | The raid’s level | 5 |
                //pokemon_id | The raid boss’s ID | 249 |
                //cp | The raid boss’s CP | 42753 |
                //move_1 | The raid boss’s quick move | 274 |
                //move_2 | The raid boss’s charge move | 275 |

                if (message["pokemon_id"] == null)
                {
                    Console.WriteLine("Raid Egg found, skipping...");
                    return;
                }

                var gymId     = Convert.ToString(message["gym_id"]);
                var teamId    = Convert.ToInt32(Convert.ToString(message["team_id"] ?? "0"));
                var latitude  = Convert.ToDouble(Convert.ToString(message["latitude"]));
                var longitude = Convert.ToDouble(Convert.ToString(message["longitude"]));
                var spawn     = Convert.ToInt64(Convert.ToString(message["spawn"]));
                var start     = Convert.ToInt64(Convert.ToString(message["start"])); //"raid_begin"]));
                var end       = Convert.ToInt64(Convert.ToString(message["end"]));   //"raid_end"]));
                var level     = Convert.ToString(message["level"] ?? "?");
                var pokemonId = Convert.ToInt32(Convert.ToString(message["pokemon_id"] ?? 0));
                var cp        = Convert.ToString(message["cp"] ?? "?");
                var move1     = Convert.ToString(message["move_1"] ?? "?");
                var move2     = Convert.ToString(message["move_2"] ?? "?");

                if (pokemonId == 0)
                {
                    _logger.Debug($"Level {level} Egg, skipping...");
                    return;
                }

                var raid = new RaidData
                           (
                    pokemonId,
                    (PokemonTeam)teamId,
                    level,
                    cp,
                    move1,
                    move2,
                    latitude,
                    longitude,
                    Utils.FromUnix(start),
                    Utils.FromUnix(end)
                           );
                OnRaidReceived(raid);
            }
            catch (Exception ex)
            {
                Utils.LogError(ex);

                _logger.Error(ex.StackTrace);
                _logger.Info("{0}", Convert.ToString(message));
            }
        }
Esempio n. 2
0
 public RaidReceivedEventArgs(RaidData raid)
 {
     Raid = raid;
 }
Esempio n. 3
0
 private void OnRaidReceived(RaidData raid) => RaidReceived?.Invoke(this, new RaidReceivedEventArgs(raid));