using System.Security.Cryptography; using System.Text.RegularExpressions; using Dungeoneer.Error; using Dungeoneer.Interpreter; namespace Dungeoneer { public static class RollMacro { public static void Pool(TokenSet input) { if(input.Count != 2) throw new SyntaxException($"expected 2 arguments ({input.Count} given)"); DiceToken dicePool = null; DcToken target = null; foreach(var token in input) { switch(token) { case DiceToken dice: if(dicePool != null) throw new SyntaxException("two dice"); dicePool = dice; break; case DcToken dc: if(target != null) throw new SyntaxException("two dc values"); target = dc; break; } } bool success = false; foreach(var roll in dicePool.Result) { if(roll > target.Value) { success = true; break; } } string message = success ? $"{Format.Green}pass" : $"{Format.Red}fail"; Console.WriteLine($"{dicePool} > {target}\n => {message}{Format.Reset}"); } } }