コード例 #1
0
        private void CompleteSession(TowerBanSession session)
        {
            _ = responseService.SendToChannelAsync(session.InitiateChannel,
                                                   $"The banned tower(s) between {session.Users.Select(x => x.User.Mention).JoinLines(" and ")} will be " +
                                                   $"{session.Users.Select(x => x.Choice.Value).Distinct().Select(x => x.ToString("f")).JoinLines(" and ")}");

            sessions.Remove(session);
        }
コード例 #2
0
 private void ExpireSession(TowerBanSession session)
 {
     foreach (var user in session.Users)
     {
         if (!user.Choice.HasValue)
         {
             _ = responseService.SendToChannelAsync(session.InitiateChannel, $"{user.User.Mention} has failed to respond in time for a tower banning session.");
         }
     }
     sessions.Remove(session);
 }
コード例 #3
0
        public bool StartSession(IUser userA, IUser userB, ITextChannel textChannel, out TowerBanSession outSession)
        {
            if (IsInSession(userA, userB))
            {
                outSession = null;
                return(false);
            }

            var session = new TowerBanSession();

            session.Users[0] = new TowerBanUser {
                User = userA
            };
            session.Users[1] = new TowerBanUser {
                User = userB
            };
            session.InitiateChannel = textChannel;

            sessions.Add(session);

            outSession = session;

            return(true);
        }
コード例 #4
0
 public void CancelSession(TowerBanSession session)
 {
     sessions.Remove(session);
 }