示例#1
0
        private void JoinHeist(ChatMessage message, Player player, IApplicationContext context)
        {
            if (!OngoingHeists.TryGetValue(message.Channel, out IHeist heist))
            {
                Client.SpoolMessageAsMe(message.Channel, player, Messages.NoHeistExists);
                return;
            }

            String strippedCommand = message.Message.GetNextWord(out _).GetNextWord(out _);

            if (String.IsNullOrWhiteSpace(strippedCommand))
            {
                Client.SpoolMessageAsMe(message.Channel, player, Messages.HowToJoin);
                return;
            }

            strippedCommand.GetNextWord(out String proposedWager);

            if (proposedWager.TryGetWager(out var wager))
            {
                heist.UpdateWager(context, player, wager);
                return;
            }

            Client.SpoolMessageAsMe(message.Channel, player, Messages.InvalidWager.Format(proposedWager));
        }
示例#2
0
        public void Heist(ChatMessage message)
        {
            using var context = ContextFactory.GetContext();

            var player = context.GetPlayer(Client, message);

            // Find if there's another ongoing heist in this channel to join.
            if (OngoingHeists.TryGetValue(message.Channel, out IHeist currentHeist))
            {
                JoinHeist(message, player, context);
                return;
            }

            // Run in a separate thread as it involves sleeping to wait for joiners.
            Task.Run(() => InitiateNewHeist(message));
        }