26 lines
497 B
C#
26 lines
497 B
C#
using System.Text.RegularExpressions;
|
|
|
|
namespace Dungeoneer {
|
|
|
|
public sealed class Command {
|
|
|
|
public static void Roll(IList<string> args) {
|
|
// don't do anything with empty expressions
|
|
if(args.Count == 0)
|
|
return;
|
|
|
|
// create new parsed expression object and pretty-print
|
|
var roll = new RollExpression(args);
|
|
var result = roll.Result;
|
|
if(result == null)
|
|
Console.WriteLine("invalid expression");
|
|
else
|
|
Console.WriteLine($"{roll.Print}\n => {result}");
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|