Пример #1
0
        public async Task AddTeam(string teamName, int teamSize = 6)
        {
            if (SignupsData.Missions.Any(x => x.Editing == Mission.EditEnum.New && x.Owner == Context.User.Id))
            {
                var mission = SignupsData.Missions.Single(x => x.Editing == Mission.EditEnum.New && x.Owner == Context.User.Id);
                // SL
                var team = new Mission.Team();
                team.Name = teamName + " SL | <:wsciekly_zulu:426139721001992193> [1] | 🚑 [1]";
                var slot = new Mission.Team.Slot(
                    "Dowódca",
                    "<:wsciekly_zulu:426139721001992193>",
                    1);
                team.Slots.Add(slot);

                slot = new Mission.Team.Slot(
                    "Medyk",
                    "🚑",
                    1);
                team.Slots.Add(slot);
                team.Pattern = "<:wsciekly_zulu:426139721001992193> [1] | 🚑 [1]";
                mission.Teams.Add(team);

                // team 1
                team      = new Mission.Team();
                team.Name = teamName + " 1 | <:wsciekly_zulu:426139721001992193> [1] | 🚑 [1] | <:beton:437603383373987853> [" + (teamSize - 2) + "]";
                slot      = new Mission.Team.Slot(
                    "Dowódca",
                    "<:wsciekly_zulu:426139721001992193>",
                    1);
                team.Slots.Add(slot);

                slot = new Mission.Team.Slot(
                    "Medyk",
                    "🚑",
                    1);
                team.Slots.Add(slot);

                slot = new Mission.Team.Slot(
                    "BPP",
                    "<:beton:437603383373987853>",
                    teamSize - 2);
                team.Slots.Add(slot);
                team.Pattern = "<:wsciekly_zulu:426139721001992193> [1] | 🚑 [1] | <:beton:437603383373987853> [" + (teamSize - 2) + "]";
                mission.Teams.Add(team);

                // team 2
                team      = new Mission.Team();
                team.Name = teamName + " 2 | <:wsciekly_zulu:426139721001992193> [1] | 🚑 [1] | <:beton:437603383373987853> [" + (teamSize - 2) + "]";
                slot      = new Mission.Team.Slot(
                    "Dowódca",
                    "<:wsciekly_zulu:426139721001992193>",
                    1);
                team.Slots.Add(slot);

                slot = new Mission.Team.Slot(
                    "Medyk",
                    "🚑",
                    1);
                team.Slots.Add(slot);

                slot = new Mission.Team.Slot(
                    "BPP",
                    "<:beton:437603383373987853>",
                    teamSize - 2);
                team.Slots.Add(slot);
                team.Pattern = "<:wsciekly_zulu:426139721001992193> [1] | 🚑 [1] | <:beton:437603383373987853> [" + (teamSize - 2) + "]";
                mission.Teams.Add(team);

                await ReplyAsync("Jeszcze coś?");
            }
            else
            {
                await ReplyAsync("A może byś mi najpierw powiedział do jakiej misji chcesz dodać ten zespół?");
            }
        }
Пример #2
0
        public async Task AddTeam([Remainder] string teamText)
        {
            if (SignupsData.Missions.Any(x => x.Editing == Mission.EditEnum.New && x.Owner == Context.User.Id))
            {
                var mission = SignupsData.Missions.Single(x => x.Editing == Mission.EditEnum.New && x.Owner == Context.User.Id);

                var slotTexts = teamText.Split("|");

                if (slotTexts.Length > 1)
                {
                    var team = new Mission.Team();
                    team.Name    = slotTexts[0];
                    team.Pattern = "";

                    foreach (var slotText in slotTexts)
                    {
                        MatchCollection matches = MiscHelper.GetSlotMatchesFromText(slotText);
                        if (matches.Count == 0)
                        {
                            continue;
                        }

                        Match match = matches.First();

                        if (match.Success)
                        {
                            var slot = new Mission.Team.Slot(match.Groups[1].Value, int.Parse(match.Groups[2].Value.Substring(1, match.Groups[2].Value.Length - 2)));
                            if (match.Groups.Count == 4)
                            {
                                slot.Name = match.Groups[3].Value;
                                foreach (var user in Context.Message.MentionedUsers)
                                {
                                    if (slot.Name.Contains(user.Mention))
                                    {
                                        slot.Name = slot.Name.Replace(user.Mention, "");
                                        slot.Signed.Add(user.Id);
                                    }
                                }
                            }
                            team.Slots.Add(slot);

                            if (team.Pattern.Length > 0)
                            {
                                team.Pattern += "| ";
                            }
                            team.Pattern += $"{slot.Emoji} [{slot.Count}] {slot.Name} ";
                        }
                    }

                    if (team.Slots
                        .GroupBy(x => x.Emoji)
                        .Any(x => x.Count() > 1))
                    {
                        await ReplyAsync("Zdublowałeś reakcje. Poprawiaj to!");

                        return;
                    }

                    var embed = new EmbedBuilder()
                                .WithColor(Color.Green)
                                .WithTitle(team.Name)
                                .WithDescription(_miscHelper.BuildTeamSlots(team)[0])
                                .WithFooter(team.Pattern);

                    _miscHelper.CreateConfirmationDialog(
                        _dialogs,
                        Context,
                        embed.Build(),
                        dialog =>
                    {
                        Context.Channel.DeleteMessageAsync(dialog.DialogID);
                        _dialogs.Dialogs.Remove(dialog);
                        mission.Teams.Add(team);
                        foreach (var slot in team.Slots)
                        {
                            foreach (var signed in slot.Signed)
                            {
                                mission.SignedUsers.Add(signed);
                            }
                        }
                        ReplyAsync("OK!");
                    },
                        dialog =>
                    {
                        Context.Channel.DeleteMessageAsync(dialog.DialogID);
                        _dialogs.Dialogs.Remove(dialog);
                        ReplyAsync("OK Boomer");
                    });
                }
            }
            else
            {
                await ReplyAsync("A może byś mi najpierw powiedział do jakiej misji chcesz dodać ten zespół?");
            }
        }