Beispiel #1
0
        public async Task Raid([Summary("Tier of the raid.")] string tier,
                               [Summary("Time the raid will start.")] string time,
                               [Summary("Where the raid will be.")][Remainder] string location)
        {
            short calcTier = Global.RAID_TIER_STRING.ContainsKey(tier) ? Global.RAID_TIER_STRING[tier] : Global.INVALID_RAID_TIER;
            Dictionary <int, List <string> > allBosses = Connections.Instance().GetFullBossList();
            List <string> potentials = calcTier == Global.INVALID_RAID_TIER || !allBosses.ContainsKey(calcTier) ? new List <string>() : allBosses[calcTier];
            Raid          raid;
            string        fileName;

            if (potentials.Count > 1)
            {
                fileName = $"Egg{calcTier}.png";
                raid     = new Raid(calcTier, time, location)
                {
                    AllBosses = allBosses
                };

                Connections.CopyFile(fileName);
                RestUserMessage selectMsg = await Context.Channel.SendFileAsync(fileName, embed : BuildBossSelectEmbed(potentials, fileName));

                raidMessages.Add(selectMsg.Id, raid);
                Connections.DeleteFile(fileName);
                selectMsg.AddReactionsAsync(Global.SELECTION_EMOJIS.Take(potentials.Count).ToArray());
            }
            else if (potentials.Count == 1)
            {
                string boss = potentials.First();
                raid = new Raid(calcTier, time, location, boss)
                {
                    AllBosses = allBosses
                };
                fileName = Connections.GetPokemonPicture(raid.GetCurrentBoss());

                Connections.CopyFile(fileName);
                RestUserMessage raidMsg = await Context.Channel.SendFileAsync(fileName, embed : BuildRaidEmbed(raid, fileName));

                raidMessages.Add(raidMsg.Id, raid);
                Connections.DeleteFile(fileName);
                SetEmojis(raidMsg, raidEmojis);
            }
            else if (Global.USE_EMPTY_RAID)
            {
                string boss = Global.DEFAULT_RAID_BOSS_NAME;
                raid = new Raid(calcTier, time, location, boss)
                {
                    AllBosses = allBosses
                };
                fileName = Connections.GetPokemonPicture(raid.GetCurrentBoss());

                Connections.CopyFile(fileName);
                RestUserMessage raidMsg = await Context.Channel.SendFileAsync(fileName, embed : BuildRaidEmbed(raid, fileName));

                raidMessages.Add(raidMsg.Id, raid);
                Connections.DeleteFile(fileName);
                SetEmojis(raidMsg, raidEmojis);
            }
            else
            {
                await ResponseMessage.SendErrorMessage(Context.Channel, "raid", $"No raid bosses found for tier {tier}");
            }
            RemoveOldRaids();
        }