コード例 #1
0
        private async Task TakeBetAsync(OnChatCommandReceivedArgs e, decimal amount, SlothyBetType type)
        {
            var msgBegin = $"@{e.Command.ChatMessage.DisplayName}:";

            if (!_isBettingOpen)
            {
                _client.SendMessage(e, $"{msgBegin} Betting is currently closed.");
                return;
            }

            if (amount <= 0)
            {
                _client.SendMessage(e, $"{msgBegin} You must bet a positive number of slothies.");
                return;
            }

            if (amount > 100)
            {
                _client.SendMessage(e, $"{msgBegin} You cannot bet more than 100 slothies at a time.");
                return;
            }

            var curCount = _slothySvc.GetSlothyCount(e.Command.ChatMessage.UserId);

            if (curCount <= -1000)
            {
                _client.SendMessage(e, $"{msgBegin} You must have more than -1,000 slothies to place bets.");
                return;
            }

            var hadExistingBet = _betSvc.GetCurrentBet(e.Command.ChatMessage.UserId) != null;

            await _betSvc.AddOrUpdateBetAsync(new SlothyBetRecord
            {
                UserId  = e.Command.ChatMessage.UserId,
                Amount  = amount,
                BetType = type
            });

            if (!hadExistingBet)
            {
                _client.SendMessage(e, $"{msgBegin} Bet placed.");
            }
            else
            {
                _client.SendMessage(e, $"{msgBegin} Bet updated.");
            }
        }
コード例 #2
0
        private void GetSlothies(OnChatCommandReceivedArgs e)
        {
            var count = _slothySvc.GetSlothyCount(e.Command.ChatMessage.UserId);

            _client.SendMessage(e, $"{e.Command.ChatMessage.DisplayName} has {GetSlothyDisplayString(count, e.Command.ChatMessage.UserId)}.");
        }