public async Task <string> GetSpRollAsync(IUser user, Globals.SpecialType specialToRoll) { var character = await _charService.GetCharacterAsync(user.Id); if (character == null) { return(String.Format(Messages.ERR_CHAR_NOT_FOUND, user.Mention)); } if (!_specService.IsSpecialSet(character)) { return(String.Format(Messages.ERR_SPECIAL_NOT_FOUND, user.Mention)); } return(GetRollMessage(character.Name, specialToRoll.ToString(), GetRollResult(specialToRoll, character))); }
/// <summary> /// Processes experience to give if channel is an experience /// enabled channel. /// </summary> public async Task ProcessExperienceAsync(SocketCommandContext context) { if (!IsInExperienceEnabledChannel(context.Channel.Id)) { return; } var userInfo = context.User; var character = await _charService.GetCharacterAsync(userInfo.Id); if (character == null || context.Message.ToString().StartsWith("(")) { return; } // filter out messages sent by FRAGS var cache = context.Channel.GetCachedMessages(Math.Max(100, _expOptions.AllowedConsecutiveMessages)) .Where(x => !x.Author.ToString().Equals(context.Client.CurrentUser.ToString())) .OfType <SocketUserMessage>(); // filter out messages trying to send commands int argPos = 0; cache = cache.Where(x => !(x.HasStringPrefix(_genOptions.Prefix, ref argPos) || x.HasMentionPrefix(_client.CurrentUser, ref argPos))); if (cache.Count() > _expOptions.AllowedConsecutiveMessages && cache.Take(_expOptions.AllowedConsecutiveMessages).All(x => x.Author.Equals(context.User))) { return; } var expToGive = GetExperienceFromMessage(character, context.Message.Content.Count(x => !Char.IsWhiteSpace(x))); if (await GiveExperienceAsync(character, expToGive)) { var level = CalculateLevelForExperience(character.Experience); await context.Channel.SendMessageAsync( string.Format(Messages.EXP_LEVEL_UP, userInfo.Mention, level)); } }
/// <summary> /// Processes experience to give if channel is an experience /// enabled channel. /// </summary> public async Task ProcessExperienceAsync(SocketCommandContext context) { if (!IsInExperienceEnabledChannel(context.Channel.Id)) { return; } var userInfo = context.User; var character = await _charService.GetCharacterAsync(userInfo.Id); if (character == null || context.Message.ToString().StartsWith("(")) { return; } var expToGive = GetRandomExperience(); if (await GiveExperienceAsync(character, expToGive)) { var level = CalculateLevelForExperience(character.Experience); await context.Channel.SendMessageAsync( string.Format(Messages.EXP_LEVEL_UP, userInfo.Mention, level)); } }