Exemple #1
0
        public async Task RockPaperScissorsChallengeStart(IUser p2)
        {
            var p1 = Context.User;

            if (p1.Id == p2.Id)
            {
                await Context.Channel.SendMessageAsync($"{p1.Mention} you can't challenge yourself. That's cheating. I'm telling mom!");

                return;
            }

            if (!RpsGameManager.CheckIfPlayerPlaying(p2) && !RpsGameManager.CheckIfPlayerPlaying(p1))
            {
                MessagePlayers(p1, p2);
                var game = new RpsGameManager();
                game.GameRunChallenge(p1, p2, Context.Channel);
            }
            else
            {
                try
                {
                    RpsGameManager.DetermineAndRemoveInactiveGames(p1, p1);
                    RpsGameManager.DetermineAndRemoveInactiveGames(p2, p1);
                }
                catch (GameNotExpiredException e)
                {
                    await Context.Channel.SendMessageAsync(e.Message);
                }
                catch (GameExpiredException e)
                {
                    await Context.Channel.SendMessageAsync(e.Message);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Logic that checks a users message and we determine if the answer is for Rock Paper Scissors. If the message is acceptable, we head into the RPS game(s).
        /// </summary>
        /// <param name="Message"></param>
        /// <param name="Context"></param>
        /// <returns></returns>
        private static async Task FilterRpsReplies(IMessage Message, SocketCommandContext Context)
        {
            var rpsCheck = Message.Content.ToLower().Trim();

            if (rpsCheck == "!rock" || rpsCheck == "!paper" || rpsCheck == "!scissors")
            {
                if (Context.Guild != null)
                {
                    await Message.DeleteAsync();

                    await Context.Channel.SendMessageAsync($"{Context.User.Mention} Please send your play directly to me in the future. I've deleted your message for safety, but your choice has been recorded!");
                }

                if (!CheckGames(Context.User))
                {
                    await Context.Channel.SendMessageAsync(null, false,
                                                           PlayerNoActiveGamesEmbed.RpsNoActiveGameEmbed(Context.User).Build());

                    return;
                }
                var entry         = new RpsGameManager();
                var playerMessage = new DetermineMessageMain();
                var results       = entry.GetPlayerEntry(Context.User, rpsCheck);
                if (results.IsRandom)
                {
                    await playerMessage.SendRandomMessageAsync(results, Context);
                }
                else
                {
                    await playerMessage.SendChallengedMessageAsync(results, Context);
                }
            }
        }