Exemplo n.º 1
0
        /// <summary>
        /// Runs updates to the system read from the Silph road.
        /// </summary>
        /// <param name="guilds">List of guilds the bot is currently in.</param>
        /// <returns>Completed Task.</returns>
        public async Task RunSilphUpdate(List <SocketGuild> guilds)
        {
            UpdatePokemonNameList();
            UpdateMoveNameList();
            UpdateEggList();
            UpdateRocketList();

            Dictionary <int, List <string> > newBosses = SilphData.GetRaidBosses();

            bool bossesChanged = RaidBosses.Keys.Count != newBosses.Keys.Count || !RaidBosses.Keys.All(newBosses.Keys.Contains);

            foreach (int tier in RaidBosses.Keys)
            {
                bossesChanged = bossesChanged || RaidBosses[tier].Count != newBosses[tier].Count || !RaidBosses[tier].All(newBosses[tier].Contains);
            }

            if (bossesChanged)
            {
                if (SilphData.GetRaidBossesConfirmed())
                {
                    UpdateRaidBossList();
                    SocketGuild  emoteServer    = guilds.FirstOrDefault(x => x.Name.Equals(Global.EMOTE_SERVER, StringComparison.OrdinalIgnoreCase));
                    GuildEmote[] previousEmotes = emoteServer.Emotes.ToArray();

                    foreach (GuildEmote emote in emoteServer.Emotes)
                    {
                        await emoteServer.DeleteEmoteAsync(emote);
                    }

                    foreach (KeyValuePair <int, List <string> > tier in RaidBosses)
                    {
                        foreach (string boss in tier.Value)
                        {
                            string fileName = GetPokemonPicture(boss);
                            CopyFile(fileName);
                            Image img = new Image(fileName);
                            await emoteServer.CreateEmoteAsync(fileName.Remove(fileName.Length - 4), img);

                            img.Dispose();
                            DeleteFile(fileName);
                        }
                    }

                    Dictionary <ulong, ulong> channels = Instance().GetNotificationChannels();

                    foreach (KeyValuePair <ulong, ulong> chan in channels)
                    {
                        SocketGuild           guild   = guilds.FirstOrDefault(x => x.Id == chan.Key);
                        ISocketMessageChannel channel = (ISocketMessageChannel)guild.Channels.FirstOrDefault(x => x.Id == chan.Value);
                        await ClearNotifyMessage(guild, channel.Id, previousEmotes.ToArray());
                        await SetNotifyMessage(guild, channel, emoteServer.Emotes.ToArray());
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets needed information for a raid boss.
        /// </summary>
        /// <param name="pokemon">Reference to a Pokémon.</param>
        public void GetRaidBoss(ref Pokemon pokemon)
        {
            GetPokemonStats(ref pokemon);
            GetPokemonCP(ref pokemon);
            GetPokemonCounter(ref pokemon);
            Dictionary <string, int>    difficulty = SilphData.GetRaidBossDifficulty(pokemon.Name);
            Dictionary <string, string> definition = SilphData.GetRaidBossDifficultyTable();

            pokemon.Difficulty = new Dictionary <string, string>();

            foreach (KeyValuePair <string, int> party in difficulty)
            {
                pokemon.Difficulty.Add(party.Key, definition.ElementAt(party.Value).Key);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Gets raid difficulty table.
 /// </summary>
 /// <returns>List of difficulties and definitions.</returns>
 public static Dictionary <string, string> GetRaidDifficultyTable()
 {
     return(SilphData.GetRaidBossDifficultyTable());
 }
Exemplo n.º 4
0
 /// <summary>
 /// Updates the list of current Team Rockets.
 /// </summary>
 public void UpdateRocketList()
 {
     Rockets = SilphData.GetRockets().Union(SilphData.GetRocketLeaders()).ToDictionary(k => k.Key, v => v.Value, StringComparer.OrdinalIgnoreCase);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Updates the list of eggs.
 /// </summary>
 public void UpdateEggList()
 {
     Eggs = SilphData.GetEggs();
 }
Exemplo n.º 6
0
 /// <summary>
 /// Updates the list of raidbosses.
 /// </summary>
 public void UpdateRaidBossList()
 {
     RaidBosses = SilphData.GetRaidBosses();
 }