Esempio n. 1
0
        private async Task HandleChatAsync(ChatHandler handler)
        {
            try
            {
                MessageCollector collector = new MessageCollector(Context.Client);

                SessionOptions options = new SessionOptions
                {
                    ResetTimeoutOnAttempt = true,
                    Timeout = TimeSpan.FromSeconds(20),
                    Session = handler
                };

                bool Filter(SocketMessage message, int index)
                {
                    return((message.Author.Id == Context.User.Id) && (message.Channel.Id == Context.Channel.Id));
                }

                await collector.MatchAsync(Filter, options);

                Context.Brain.AddOrUpdateAffinity(handler.Affinity);
            }
            catch (Exception e)
            {
                await Context.Channel.CatchAsync(e);
            }
        }
Esempio n. 2
0
        private async Task HandleShopAsync(ShopHandler shop)
        {
            try
            {
                var collector = new MessageCollector(Context.Client);

                var options = new SessionOptions
                {
                    ResetTimeoutOnAttempt = true,
                    Timeout = TimeSpan.FromSeconds(30),
                    Session = shop
                };

                bool Filter(SocketMessage message, int index)
                {
                    return((message.Author.Id == Context.User.Id) && (message.Channel.Id == Context.Channel.Id));
                }

                await collector.MatchAsync(Filter, options);
            }
            catch (Exception e)
            {
                await Context.Channel.CatchAsync(e);
            }
        }
Esempio n. 3
0
        public async Task ChatTestAsync()
        {
            try
            {
                MessageCollector collector = new MessageCollector(Context.Client);
                SpriteBank       bank      = SpriteBank.FromDirectory("../assets/npcs/noname/");
                Character        test      = new Character
                {
                    Id          = "npc0",
                    Name        = "No-Name",
                    Personality = new Personality
                    {
                        Mind     = MindType.Extravert,
                        Energy   = EnergyType.Intuitive,
                        Nature   = NatureType.Thinking,
                        Tactics  = TacticType.Judging,
                        Identity = IdentityType.Assertive
                    },
                    Affinity = new List <AffinityData>
                    {
                        new AffinityData("npc1", 0.2f)
                    },
                    Model = new CharacterModel
                    {
                        Body = new AppearanceNode(bank.GetSprite("noname_body"), 20, 16),
                        Head = new AppearanceNode(bank.GetSprite("noname_head"), 28, 5),
                        DefaultFaceOffset = new Point(28, 5),
                        Expressions       = new Dictionary <DialogTone, AppearanceNode>
                        {
                            [DialogTone.Neutral]  = new AppearanceNode(bank.GetSprite("noname_neutral")),
                            [DialogTone.Happy]    = new AppearanceNode(bank.GetSprite("noname_happy")),
                            [DialogTone.Sad]      = new AppearanceNode(bank.GetSprite("noname_sad")),
                            [DialogTone.Confused] = new AppearanceNode(bank.GetSprite("noname_confused")),
                            [DialogTone.Shocked]  = new AppearanceNode(bank.GetSprite("noname_shocked"))
                        }
                    }
                };

                var action = new ChatHandler(Context, test, Engine.GetTree("test"));

                var options = new SessionOptions
                {
                    ResetTimeoutOnAttempt = true,
                    Timeout = TimeSpan.FromSeconds(20),
                    Session = action
                };

                bool Filter(SocketMessage message, int index)
                {
                    return((message.Author.Id == Context.User.Id) && (message.Channel.Id == Context.Channel.Id));
                }

                await collector.MatchAsync(Filter, options);
            }
            catch (Exception e)
            {
                await Context.Channel.CatchAsync(e);
            }
        }
Esempio n. 4
0
        public async Task RunBlackJackAsync(ArcadeUser invoker, ISocketMessageChannel channel, Wager wager)
        {
            if (!invoker.CanGamble)
            {
                return;
            }

            if (wager.Value < 0)
            {
                await channel.SendMessageAsync($"> 👁️ You can't specify a **negative** value.\n> *\"I know what you were trying to do.\"*");

                return;
            }

            if (wager.Value == 0)
            {
                await channel.SendMessageAsync($"> ⚠️ You need to specify a positive amount of **Chips** to bet.");

                return;
            }

            if (wager.Value > invoker.ChipBalance)
            {
                await channel.SendMessageAsync($"> ⚠️ You don't have enough **Chips** to bet with.");

                return;
            }

            invoker.CanGamble = false;
            var session = new BlackJackSession(invoker, channel, wager.Value);

            try
            {
                var options = new SessionOptions
                {
                    ResetTimeoutOnAttempt = true,
                    Timeout = TimeSpan.FromSeconds(15),
                    Session = session
                };

                bool Filter(SocketMessage message, int index)
                {
                    return(message.Author.Id == invoker.Id && message.Channel.Id == channel.Id);
                }

                await _collector.MatchAsync(Filter, options);
            }
            catch (Exception e)
            {
                await channel.CatchAsync(e);
            }

            invoker.CanGamble = true;
        }