/// <summary> /// Performs a roll on a character's statistic and returns the result. /// </summary> /// <param name="callerId">Discord ID of the caller.</param> /// <param name="statName">The statistic name.</param> /// <returns>The result of the roll.</returns> public async Task <IResult> RollStatisticAsync(ulong callerId, string statName, bool useEffects = false) { var character = await _provider.GetActiveCharacterAsync(callerId); if (character == null) { return(CharacterResult.CharacterNotFound()); } var stat = await _statProvider.GetStatisticAsync(statName); if (stat == null) { return(StatisticResult.StatisticNotFound()); } string result = _strategy.GetRollMessage(stat, character, useEffects); if (!string.IsNullOrEmpty(result)) { return(RollResult.Roll(result)); } return(RollResult.RollFailed()); }
/// <summary> /// Gets the character associated with the id and checks /// if their specified statistic is higher than the given value. /// </summary> /// <param name="id">The id of the character to get.</param> /// <param name="statName">The name of the statistic to get.</param> /// <param name="minimum">Checks if the character's StatisticValue is greater than or equal to this value.</param> /// <returns> /// A result detailing if the operation was successful or why it failed. /// </returns> public async Task <IResult> CheckStatisticAsync(ulong id, string statName) { var character = await _charProvider.GetActiveCharacterAsync(id); if (character == null) { return(CharacterResult.CharacterNotFound()); } var stat = await _statProvider.GetStatisticAsync(statName); if (stat == null) { return(StatisticResult.StatisticNotFound()); } var statValue = character.GetStatistic(stat); if (statValue == null) { return(StatisticResult.StatisticNotFound()); } return(StatisticResult.StatisticCheck(character.Name, stat.Name, statValue.Value)); }
/// <summary> /// Gets the caller's active character and returns its active effects. /// </summary> /// <param name="callerId">Discord ID of the caller.</param> /// <returns>A new EffectResult object.</returns> public async Task <IResult> ShowCharacterEffectsAsync(ulong callerId) { var character = await _charProvider.GetActiveCharacterAsync(callerId); if (character == null) { return(CharacterResult.CharacterNotFound()); } if (character.Effects == null || character.Effects.Count <= 0) { return(EffectResult.NoEffects()); } return(EffectResult.ShowCharacterEffects(character)); }
/// <summary> /// Gets the caller's active character and returns the result. /// </summary> /// <param name="callerId">Discord ID of the caller.</param> /// <returns>A new CharacterResult object.</returns> public async Task <IResult> ShowCharacterAsync(ulong callerId) { var character = await _provider.GetActiveCharacterAsync(callerId); if (character == null) { return(CharacterResult.CharacterNotFound()); } return(CharacterResult.Show(character, _progStrategy.GetCharacterLevel(character), await _progStrategy.GetCharacterInfo(character))); }