Esempio n. 1
0
        private async Task AskRoleForInteractionTarget(ICity city, Role role, IReadOnlyCollection <IPerson> choosers)
        {
            var names = city.Population
                        .Where(p => p.IsAlive && !choosers.Contains(p))
                        .Select(p => p.Name).ToArray();

            await AddCityVoting(city.Name);

            var messageText = CreateMessageText("<b>Who will be your target?</b>\n\n", city.Name, names);

            var cityVotingPool = cityVotingPools[city.Name];

            foreach (var userId in choosers.Select(person => personToChat[person]))
            {
                cityVotingPool.AddChatId(userId);
                cityVotingPool.AddRole(userId, role);
            }

            var roleVoting = new RoleVotingPool(names);

            cityVotingPool.AddRoleVoting(role, roleVoting);

            if (names.Length == 1)
            {
                // bot.SendTextMessageAsync(chatId, $"{role.Name} automatically chosen {targets[0]}").Wait();
                roleVoting.Vote(0, 0); // illegal move
                return;
            }

            await Task.WhenAll(choosers.Select(person => bot.SendTextMessageAsync(personToChat[person], messageText, ParseMode.Html)));
        }
Esempio n. 2
0
        private async Task AskJudgedPerson(ICity city, Role role, IReadOnlyCollection <IPerson> choosers)
        {
            if (choosers.Count < 2)
            {
                return;
            }

            var chatId = cityToChat[city];

            await AddCityVoting(city.Name);

            var names = choosers.Select(p => p.Name).ToArray();

            var messageText = CreateMessageText("<b>Who will you blame?</b>\n\n", city.Name, names);

            var cityVotingPool = cityVotingPools[city.Name];

            cityVotingPool.AddChatId(chatId);
            foreach (var userId in choosers.Select(c => personToChat[c]))
            {
                cityVotingPool.AddRole(userId, role);
            }

            var roleVoting = new RoleVotingPool(names);

            cityVotingPool.AddRoleVoting(role, roleVoting);

            await bot.SendTextMessageAsync(chatId, messageText, ParseMode.Html);
        }
Esempio n. 3
0
 public void AddRoleVoting(Role role, RoleVotingPool votingPool)
 {
     roleVotePools[role] = votingPool;
 }