public async Task <RuntimeResult> RemoveEffectAsync(string npcName, [Remainder] string name) { var character = _npcService.FindNpc(npcName); if (character == null) { return(CharacterResult.NpcNotFound()); } var effect = await _effectsService.GetEffectAsync(name); if (effect == null) { return(GenericResult.FromError(Messages.ERR_EFFECT_NOT_FOUND)); } //if (character.Effects == null) character.Effects = new List<Effect>(); if (character.EffectCharacters == null) { character.EffectCharacters = new List <EffectCharacter>(); } character.EffectCharacters.Remove(character.EffectCharacters.Where(x => x.Effect.Equals(effect)).FirstOrDefault()); return(GenericResult.FromSuccess(String.Format(Messages.EFFECT_REMOVE_SUCCESS, effect.Name, character.Name))); }
public async Task <RuntimeResult> TagSkillsAsync(Skill tag1, Skill tag2, Skill tag3) { if (!_progOptions.UseOldProgression || !_progOptions.OldProgression.UseNewVegasRules) { return(StatisticResult.NotUsingNewVegasRules()); } var userInfo = Context.User; var character = await _charService.GetCharacterAsync(userInfo.Id); if (character == null) { return(CharacterResult.CharacterNotFound()); } if (_skillsService.AreSkillsSet(character)) { return(StatisticResult.SkillsAlreadyTagged()); } try { await _skillsService.TagSkills(character, tag1, tag2, tag3); return(GenericResult.FromSuccess(Messages.SKILLS_SET_SUCCESS)); } catch (Exception e) { return(GenericResult.FromError($"{Messages.FAILURE_EMOJI} {e.Message}")); } }
public async Task <RuntimeResult> ApplyEffectAsync(string npcName, [Remainder] string name) { var character = _npcService.FindNpc(npcName); if (character == null) { return(CharacterResult.NpcNotFound()); } var effect = await _effectsService.GetEffectAsync(name); if (effect == null) { return(GenericResult.FromError(Messages.ERR_EFFECT_NOT_FOUND)); } if (character.EffectCharacters == null) { character.EffectCharacters = new List <EffectCharacter>(); } if (character.EffectCharacters.Any(x => x.Effect.Equals(effect))) { return(GenericResult.FromError(Messages.ERR_EFFECT_ALREADY_APPLIED)); } character.EffectCharacters.Add(new EffectCharacter { Character = character, Effect = effect }); return(GenericResult.FromSuccess(String.Format(Messages.EFFECT_APPLY_SUCCESS, effect.Name, character.Name))); }
public async Task <RuntimeResult> ActivateCharacterAsync([Remainder] string name) { var chars = await _charService.GetAllCharactersAsync(Context.User.Id); if (chars == null) { return(CharacterResult.CharacterNotFound()); } //var charMatch = chars.Find(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase)); var charMatch = chars.Find(x => x.Name.Contains(name, StringComparison.OrdinalIgnoreCase)); if (charMatch == null) { return(CharacterResult.CharacterNotFound()); } if (charMatch.Active) { return(GenericResult.FromError(String.Format(Messages.ERR_CHAR_ALREADY_ACTIVE, charMatch.Name))); } foreach (var character in chars.FindAll(x => x.Active)) { character.Active = false; await _charService.SaveCharacterAsync(character); } charMatch.Active = true; await _charService.SaveCharacterAsync(charMatch); return(GenericResult.FromSuccess(String.Format(Messages.CHAR_ACTIVATED, charMatch.Name))); }
public async Task <RuntimeResult> EditEffectAsync(string name, Statistic stat, int value) { var effect = (await _effectsService.GetAllOwnedEffectsAsync(Context.User.Id)).Find(x => x.Name.Equals(name)); if (effect == null) { return(GenericResult.FromError(Messages.ERR_EFFECT_NOT_FOUND)); } var match = effect.StatisticEffects.FirstOrDefault(x => x.Statistic.Equals(stat)); if (match != null) { if (value == 0) { effect.StatisticEffects.Remove(match); } else { match.Value = value; } } else { effect.StatisticEffects.Add(new StatisticValue { Statistic = stat, Value = value }); } await _effectsService.SaveEffectAsync(effect); return(GenericResult.FromSuccess(Messages.EFFECT_EDIT_SUCCESS)); }
public async Task <RuntimeResult> CreateEffectAsync([Remainder] string name) { if (!StringHelper.IsOnlyLetters(name)) { return(GenericResult.FromError(Messages.ERR_EFFECT_NOT_ALPHABETICAL)); } if (name.Length > 24) { return(GenericResult.FromError(Messages.ERR_EFFECT_NAME_TOO_LONG)); } if (await _effectsService.CountEffectsAsync(Context.User.Id) >= MAX_EFFECTS) { return(GenericResult.FromError(Messages.ERR_EFFECT_TOO_MANY)); } if (await _effectsService.IsDuplicateName(name)) { return(GenericResult.FromError(Messages.ERR_EFFECT_NAME_DUPLICATE)); } await _effectsService.CreateEffectAsync(name, Context.User.Id); return(GenericResult.FromSuccess(Messages.EFFECT_CREATE_SUCCESS)); }
public async Task <RuntimeResult> RollDiceAsync(int dieCount, int sides, int bonus = 0) { if (dieCount > 20) { return(GenericResult.FromError(Messages.ROLL_DICE_TOO_MANY)); } if (sides > 100) { return(GenericResult.FromError(Messages.ROLL_DICE_TOO_MANY_SIDES)); } int[] dice = new int[dieCount]; int sum = 0; for (int die = 0; die < dieCount; die++) { int dieResult = _random.Next(1, sides + 1); dice[die] = dieResult; sum += dieResult; } StringBuilder sb = new StringBuilder(); for (int die = 0; die < dice.Length; die++) { sb.Append($"[{dice[die]}] + "); } sb.Append($"{bonus} = {dice.Sum() + bonus}"); return(await Task.FromResult(GenericResult.FromSuccess(String.Format(Messages.ROLL_DICE, sb.ToString())))); }
public async Task <RuntimeResult> ChangeCharacterNameAsync([Remainder] string name) { var character = await _charService.GetCharacterAsync(Context.User.Id); if (character == null) { return(CharacterResult.CharacterNotFound()); } if (!StringHelper.IsOnlyLetters(name)) { return(GenericResult.FromError("Name contained non-alphabetic characters.")); } if (name.Length > 24 || name.Length < 2) { return(GenericResult.FromError("Name was too long or short.")); } var fixedName = StringHelper.ToTitleCase(name); if (await _charService.HasDuplicateName(Context.User.Id, fixedName)) { return(GenericResult.FromError("Name is a duplicate.")); } character.Name = fixedName; await _charService.SaveCharacterAsync(character); return(GenericResult.FromSuccess(Messages.CHAR_CHANGED_NAME)); }
public async Task <RuntimeResult> SetSkillsAsync(Skill tag, int points) { if (ExperienceService.UseOldProgression) { return(StatisticResult.UsingOldProgression()); } var userInfo = Context.User; var character = await _charService.GetCharacterAsync(userInfo.Id); if (character == null) { return(CharacterResult.CharacterNotFound()); } if (_skillsService.AreSkillsSet(character)) { return(StatisticResult.SkillsAlreadyTagged()); } try { await _skillsService.TagSkill(character, tag, points); return(GenericResult.FromSuccess(Messages.SKILLS_SET_SUCCESS)); } catch (Exception e) { return(GenericResult.FromError($"{Messages.FAILURE_EMOJI} {e.Message}")); } }
public async Task <RuntimeResult> ShowCharacterStoryAsync(IUser targetUser = null) { var userInfo = Context.User; var character = targetUser == null ? await _charService.GetCharacterAsync(userInfo.Id) : await _charService.GetCharacterAsync(targetUser.Id); if (character == null) { return(CharacterResult.CharacterNotFound()); } if (character.Story == null || character.Story.Equals("")) { return(GenericResult.FromError(Messages.ERR_STORY_NOT_FOUND)); } var embed = EmbedHelper.BuildBasicEmbed("Command: $character story", $"**Name:** {character.Name}\n" + $"**Story:** {character.Story}"); await ReplyAsync(userInfo.Mention, embed : embed); return(GenericResult.FromSilentSuccess()); }
public async Task <RuntimeResult> ViewEffectAsync([Remainder] string name) { var effect = await _effectsService.GetEffectAsync(name); if (effect == null) { return(GenericResult.FromError(Messages.ERR_EFFECT_NOT_FOUND)); } await ReplyAsync(message : Context.User.Mention, embed : EmbedHelper.BuildBasicEmbed(null, _effectsService.GetEffectInfo(effect))); return(GenericResult.FromSilentSuccess()); }
public async Task <RuntimeResult> DeleteEffectAsync([Remainder] string name) { var effect = (await _effectsService.GetAllOwnedEffectsAsync(Context.User.Id)).Find(x => x.Name.Equals(name)); if (effect == null) { return(GenericResult.FromError(Messages.ERR_EFFECT_NOT_FOUND)); } await _effectsService.DeleteEffectAsync(effect); return(GenericResult.FromSuccess(Messages.EFFECT_DELETE_SUCCESS)); }
public async Task <RuntimeResult> EditPresetStatisticAsync(string name, Statistic stat, int newValue) { var preset = await _presetService.GetNpcPreset(name); if (preset == null) { return(GenericResult.FromError(String.Format(Messages.ERR_NPC_PRESET_NOT_FOUND))); } _statsService.SetStatistic(preset.Statistics, stat, newValue); await _presetService.SaveNpcPreset(preset); return(GenericResult.FromSuccess(String.Format(Messages.NPC_PRESET_EDIT_SPECIAL, preset.Name))); }
public async Task <RuntimeResult> TogglePresetAsync(string name) { var preset = await _presetService.GetNpcPreset(name); if (preset == null) { return(GenericResult.FromError(String.Format(Messages.ERR_NPC_PRESET_NOT_FOUND))); } preset.Enabled = !preset.Enabled; await _presetService.SaveNpcPreset(preset); return(GenericResult.FromSuccess(String.Format(Messages.NPC_PRESET_TOGGLE, preset.Name, preset.Enabled))); }
public async Task <RuntimeResult> CreateCharacterAsync([Remainder] string name) { var userInfo = Context.User; try { await _charService.CreateCharacterAsync(userInfo.Id, name); return(GenericResult.FromSuccess(Messages.CHAR_CREATED_SUCCESS)); } catch (Exception e) { return(GenericResult.FromError(e.Message)); } }
public async Task <RuntimeResult> CreatePresetAsync(string name) { try { await _presetService.CreateNpcPresetAsync(name); return(GenericResult.FromSuccess(String.Format(Messages.NPC_PRESET_CREATE, name))); } catch (Exception e) { return(GenericResult.FromError(e.Message)); throw; } }
public async Task <RuntimeResult> RollManualAsync(Statistic stat, int value) { if (value > 5000) { return(GenericResult.FromError("Too high.")); } var mockCharacter = new Character { Name = Context.User.Username }; mockCharacter.Statistics = new List <StatisticValue> { new StatisticValue { Statistic = stat, Value = value } }; return(await Task.FromResult(_rollService.RollStatistic(mockCharacter, stat))); }
public async Task <RuntimeResult> SpendSkillPointsAsync(Skill skill, int points) { if (!ExperienceService.UseOldProgression) { return(StatisticResult.NotUsingOldProgression()); } var userInfo = Context.User; var character = await _charService.GetCharacterAsync(userInfo.Id); if (character == null) { return(CharacterResult.CharacterNotFound()); } if (!_skillsService.AreSkillsSet(character)) { return(StatisticResult.SkillsNotSet()); } if (points < 1) { return(GenericResult.FromError(Messages.ERR_SKILLS_POINTS_BELOW_ONE)); } if (points > character.ExperiencePoints) { return(GenericResult.FromError(Exceptions.CHAR_NOT_ENOUGH_SKILL_POINTS)); } var skillVal = _statsService.GetStatistic(character, skill); if ((skillVal + points) > _roleplayOptions.SkillMax) { return(GenericResult.FromError(Exceptions.CHAR_SKILL_POINTS_GOES_OVER_MAX)); } _statsService.SetStatistic(character, skill, skillVal + points); character.ExperiencePoints -= points; await _charService.SaveCharacterAsync(character); return(GenericResult.FromSuccess(Messages.SKILLS_SPEND_POINTS_SUCCESS)); }
public async Task <RuntimeResult> CreateNewNpcAsync(string name, string type) { try { var preset = await _presetService.GetNpcPreset(type); if (preset == null) { return(GenericResult.FromError(Messages.ERR_NPC_PRESET_NOT_FOUND)); } _npcService.CreateNpc(name, preset); return(GenericResult.FromSuccess(String.Format(Messages.NPC_CREATED_SUCCESS, type, name))); } catch (Exception e) { return(GenericResult.FromError(e.Message)); } }
public async Task <RuntimeResult> ClaimSkillPointsAsync() { if (!ExperienceService.UseOldProgression) { return(StatisticResult.NotUsingOldProgression()); } var userInfo = Context.User; var character = await _charService.GetCharacterAsync(userInfo.Id); if (character == null) { return(CharacterResult.CharacterNotFound()); } if (!character.IsReset) { return(GenericResult.FromError(Messages.ERR_SKILLS_NONE_TO_CLAIM)); } if (!_specService.IsSpecialSet(character)) { return(StatisticResult.SpecialNotSet()); } if (!_skillsService.AreSkillsSet(character)) { return(StatisticResult.SkillsNotSet()); } _statsService.InitializeStatistics(character.Statistics); character.ExperiencePoints = 0; var intelligence = _statsService.GetStatistic(character, Globals.StatisticFlag.Intelligence); for (int level = 1; level <= character.Level; level++) { character.ExperiencePoints += _expService.CalculateSkillPoints(level, intelligence); } character.IsReset = false; await _charService.SaveCharacterAsync(character); return(GenericResult.FromSuccess(string.Format(Messages.SKILLS_POINTS_CLAIMED, character.ExperiencePoints))); }
public async Task<RuntimeResult> PayAsync(IUser user, int amount) { if (amount < 1) return GenericResult.FromError(Messages.ERR_NOT_ENOUGH_CAPS); var sourceChar = await _charService.GetCharacterAsync(Context.User.Id); if (sourceChar == null) return CharacterResult.CharacterNotFound(); var targetChar = await _charService.GetCharacterAsync(user.Id); if (targetChar == null) return CharacterResult.CharacterNotFound(); if (amount > sourceChar.Money) return GenericResult.FromError(Messages.ERR_NOT_ENOUGH_CAPS); sourceChar.Money -= amount; targetChar.Money += amount; await _charService.SaveCharacterAsync(sourceChar); await _charService.SaveCharacterAsync(targetChar); return GenericResult.FromSuccess(string.Format(Messages.PAY_SUCCESS, user.Mention, amount)); }
public async Task <RuntimeResult> CheckStatistic(IUser user, Statistic stat, int minimum) { var character = await _charService.GetCharacterAsync(user.Id); if (character == null) { return(CharacterResult.CharacterNotFound()); } var match = character.Statistics.FirstOrDefault(x => x.Statistic.Equals(stat)); if (match == null) { return(GenericResult.FromError("Statistic not found for character.")); } int statValue = match.Value; return(GenericResult.FromSuccess(GetCheckMessage(character.Name, stat.Name, statValue, minimum))); }
public async Task <RuntimeResult> ListEffectsAsync() { var effects = await _effectsService.GetAllOwnedEffectsAsync(Context.User.Id); if (effects == null) { return(GenericResult.FromError(Messages.ERR_EFFECT_NOT_FOUND)); } var message = new StringBuilder(); for (var i = 0; i < effects.Count; i++) { message.Append($"{i + 1}: {effects[i].Name}\n"); } var embed = EmbedHelper.BuildBasicEmbed("Command: $effect list", message.ToString()); await ReplyAsync(Context.User.Mention, embed : embed); return(GenericResult.FromSilentSuccess()); }
public async Task <RuntimeResult> RemoveCharacterAsync([Remainder] string name) { var chars = await _charService.GetAllCharactersAsync(Context.User.Id); if (chars == null) { return(CharacterResult.CharacterNotFound()); } var charMatch = chars.Find(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase)); if (charMatch == null) { return(CharacterResult.CharacterNotFound()); } if (charMatch.Active) { return(GenericResult.FromError(Messages.ERR_CHAR_CANT_REMOVE_ACTIVE)); } await ReplyAsync(String.Format(Messages.CHAR_REMOVE_CONFIRM, charMatch.Name, charMatch.Level)); var response = await NextMessageAsync(); if (response != null && response.Content.Equals(charMatch.Name, StringComparison.OrdinalIgnoreCase)) { await _charService.DeleteCharacterAsync(charMatch); return(GenericResult.FromSuccess(String.Format(Messages.CHAR_REMOVE_SUCCESS, charMatch.Name))); } else { return(GenericResult.FromError(String.Format(Messages.CHAR_NOT_REMOVED, charMatch.Name))); } }