added roll macros
This commit is contained in:
parent
48799dc0a7
commit
7af123f5d4
4 changed files with 19 additions and 3 deletions
|
@ -9,6 +9,13 @@ namespace Dungeoneer {
|
||||||
if(args.Count == 0)
|
if(args.Count == 0)
|
||||||
return;
|
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
|
// create new parsed expression object and pretty-print
|
||||||
var roll = new RollExpression(args);
|
var roll = new RollExpression(args);
|
||||||
var result = roll.Result;
|
var result = roll.Result;
|
||||||
|
|
|
@ -6,7 +6,14 @@ namespace Dungeoneer {
|
||||||
|
|
||||||
public delegate void Command(IList<string> args);
|
public delegate void Command(IList<string> args);
|
||||||
public static Dictionary<string, Command> ReplCommands = new Dictionary<string, Command> {
|
public static Dictionary<string, Command> ReplCommands = new Dictionary<string, Command> {
|
||||||
|
{ "new", (Command)Dungeoneer.Command.New },
|
||||||
{ "roll", (Command)Dungeoneer.Command.Roll }
|
{ "roll", (Command)Dungeoneer.Command.Roll }
|
||||||
|
// TODO: "with"?
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Dictionary<string, Command> RollMacros = new Dictionary<string, Command> {
|
||||||
|
// TODO: disadvantage ( roll twice and take lowest )
|
||||||
|
// TODO: pool ( any of NdX > D => success )
|
||||||
};
|
};
|
||||||
|
|
||||||
public static void Main() {
|
public static void Main() {
|
||||||
|
|
|
@ -22,7 +22,9 @@ namespace Dungeoneer {
|
||||||
builtin.SetVariable("input", (Func<string, string>)Input);
|
builtin.SetVariable("input", (Func<string, string>)Input);
|
||||||
builtin.RemoveVariable("open");
|
builtin.RemoveVariable("open");
|
||||||
|
|
||||||
Scope.repl = Program.ReplCommands;
|
// helper vars
|
||||||
|
Scope.repl_commands = Program.ReplCommands;
|
||||||
|
Scope.roll_macros = Program.RollMacros;
|
||||||
|
|
||||||
// helper functions
|
// helper functions
|
||||||
Scope.roll = (Func<int, int>)Dungeoneer.Util.Roll;
|
Scope.roll = (Func<int, int>)Dungeoneer.Util.Roll;
|
||||||
|
|
4
repl.py
4
repl.py
|
@ -7,8 +7,8 @@ def repl_loop():
|
||||||
parts = raw.split(" ")
|
parts = raw.split(" ")
|
||||||
command = parts[0]
|
command = parts[0]
|
||||||
del parts[0]
|
del parts[0]
|
||||||
if command in repl:
|
if command in repl_commands:
|
||||||
repl[command](parts)
|
repl_commands[command](parts)
|
||||||
|
|
||||||
repl_loop()
|
repl_loop()
|
||||||
|
|
||||||
|
|
Reference in a new issue