Adding default diceRecipe
This commit is contained in:
parent
01d504c077
commit
345304537a
@ -15,7 +15,7 @@ namespace ChaosBot.Discord.Modules.User
|
|||||||
public class Roll : ModuleBase
|
public class Roll : ModuleBase
|
||||||
{
|
{
|
||||||
private static readonly ILogger _logger = Program.Logger;
|
private static readonly ILogger _logger = Program.Logger;
|
||||||
|
|
||||||
[Command("roll")]
|
[Command("roll")]
|
||||||
[Alias("random", "dice")]
|
[Alias("random", "dice")]
|
||||||
[CheckCommandPerm("User")]
|
[CheckCommandPerm("User")]
|
||||||
@ -23,35 +23,42 @@ namespace ChaosBot.Discord.Modules.User
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string diceRecipe = Strings.Join(args, " ");
|
string diceRecipe = null;
|
||||||
|
|
||||||
var sb = new StringBuilder();
|
|
||||||
var embed = new EmbedBuilder();
|
|
||||||
|
|
||||||
RollResult rollResult = Roller.Roll(diceRecipe);
|
if (args.Length > 1)
|
||||||
|
diceRecipe = Strings.Join(args, " ");
|
||||||
embed.WithColor(new Color(255, 255,0));
|
else
|
||||||
// embed.Title = $"Dice Roll";
|
diceRecipe = "1d20";
|
||||||
sb.AppendLine($"{Context.User.Mention} :game_die:");
|
|
||||||
sb.AppendLine($"Result: {diceRecipe} ({DiceOutput(rollResult)})");
|
|
||||||
sb.AppendLine($"Total: {rollResult.Value}");
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Add the string to the Embed
|
|
||||||
*/
|
|
||||||
embed.Description = sb.ToString();
|
|
||||||
|
|
||||||
/*
|
var sb = new StringBuilder();
|
||||||
* Reply with the Embed created above
|
var embed = new EmbedBuilder();
|
||||||
*/
|
|
||||||
await ReplyAsync(null, false, embed.Build());
|
RollResult rollResult = Roller.Roll(diceRecipe);
|
||||||
|
|
||||||
|
embed.WithColor(new Color(255, 255, 0));
|
||||||
|
// embed.Title = $"Dice Roll";
|
||||||
|
sb.AppendLine($"{Context.User.Mention} :game_die:");
|
||||||
|
sb.AppendLine($"Result: {diceRecipe} ({DiceOutput(rollResult)})");
|
||||||
|
sb.AppendLine($"Total: {rollResult.Value}");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add the string to the Embed
|
||||||
|
*/
|
||||||
|
embed.Description = sb.ToString();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Reply with the Embed created above
|
||||||
|
*/
|
||||||
|
await ReplyAsync(null, false, embed.Build());
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error($"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
_logger.Error(
|
||||||
|
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private string DiceOutput(RollResult rollResult)
|
|
||||||
|
private string DiceOutput(RollResult rollResult)
|
||||||
{
|
{
|
||||||
if (rollResult.RollRoot == null) return "";
|
if (rollResult.RollRoot == null) return "";
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
@ -64,7 +71,7 @@ namespace ChaosBot.Discord.Modules.User
|
|||||||
sb.Append(result);
|
sb.Append(result);
|
||||||
sb.Append(DieFormatting(dieResult.Flags, true));
|
sb.Append(DieFormatting(dieResult.Flags, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,14 +104,14 @@ namespace ChaosBot.Discord.Modules.User
|
|||||||
case SpecialDie.OpenParen:
|
case SpecialDie.OpenParen:
|
||||||
return "(";
|
return "(";
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private string DieFormatting(DieFlags flags, bool reverse=false)
|
private string DieFormatting(DieFlags flags, bool reverse = false)
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
if ((flags & (DieFlags.Critical ^ DieFlags.Success ^ DieFlags.Failure ^ DieFlags.Fumble)) != 0)
|
if ((flags & (DieFlags.Critical ^ DieFlags.Success ^ DieFlags.Failure ^ DieFlags.Fumble)) != 0)
|
||||||
@ -112,7 +119,7 @@ namespace ChaosBot.Discord.Modules.User
|
|||||||
|
|
||||||
if ((flags & DieFlags.Dropped) != 0)
|
if ((flags & DieFlags.Dropped) != 0)
|
||||||
sb.Append("~~");
|
sb.Append("~~");
|
||||||
|
|
||||||
if ((flags & DieFlags.Extra) != 0)
|
if ((flags & DieFlags.Extra) != 0)
|
||||||
sb.Append("*");
|
sb.Append("*");
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user