diff --git a/Command.cs b/Command.cs index d759ad8..3b015c5 100644 --- a/Command.cs +++ b/Command.cs @@ -9,6 +9,13 @@ namespace Dungeoneer { if(args.Count == 0) return; + // pass to subcommands + var first = args[0]; + if(Program.RollMacros.ContainsKey(first)) { + Program.RollMacros[first](args); + return; + } + // create new parsed expression object and pretty-print var roll = new RollExpression(args); var result = roll.Result; diff --git a/Program.cs b/Program.cs index ea72dfa..2ffbd75 100644 --- a/Program.cs +++ b/Program.cs @@ -6,7 +6,14 @@ namespace Dungeoneer { public delegate void Command(IList args); public static Dictionary ReplCommands = new Dictionary { + { "new", (Command)Dungeoneer.Command.New }, { "roll", (Command)Dungeoneer.Command.Roll } + // TODO: "with"? + }; + + public static Dictionary RollMacros = new Dictionary { + // TODO: disadvantage ( roll twice and take lowest ) + // TODO: pool ( any of NdX > D => success ) }; public static void Main() { diff --git a/Scripting.cs b/Scripting.cs index dad4064..7ef7a88 100644 --- a/Scripting.cs +++ b/Scripting.cs @@ -22,7 +22,9 @@ namespace Dungeoneer { builtin.SetVariable("input", (Func)Input); builtin.RemoveVariable("open"); - Scope.repl = Program.ReplCommands; + // helper vars + Scope.repl_commands = Program.ReplCommands; + Scope.roll_macros = Program.RollMacros; // helper functions Scope.roll = (Func)Dungeoneer.Util.Roll; diff --git a/repl.py b/repl.py index b78b06f..a118389 100644 --- a/repl.py +++ b/repl.py @@ -7,8 +7,8 @@ def repl_loop(): parts = raw.split(" ") command = parts[0] del parts[0] - if command in repl: - repl[command](parts) + if command in repl_commands: + repl_commands[command](parts) repl_loop()