From b774fb75be4efde03ef8f69a5ca9d32788d23fa7 Mon Sep 17 00:00:00 2001 From: manveti Date: Thu, 9 Apr 2015 00:26:02 -0700 Subject: [PATCH] Display the dice rolled and their results --- DiceInTheVineyard/ditv.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/DiceInTheVineyard/ditv.js b/DiceInTheVineyard/ditv.js index fe84a7f09..e904dbdeb 100644 --- a/DiceInTheVineyard/ditv.js +++ b/DiceInTheVineyard/ditv.js @@ -139,7 +139,8 @@ var DitV = DitV || { rollCounts[roll - 1] = (rollCounts[roll - 1] || 0) + 1; } } - return DitV.addChips(name, rollCounts); + var error = DitV.addChips(name, rollCounts); + return error || rollCounts; }, countChips: function(name){ @@ -219,7 +220,22 @@ var DitV = DitV || { error = "The 'roll' command requires two argumenst: character name and dice specification"; break; } - error = DitV.rollChips(tokens[2], tokens.slice(3).join(" ")); + var rollSpec = tokens.slice(3).join(" "); + var rollCounts = DitV.rollChips(tokens[2], rollSpec); + if (typeof(rollCounts) == typeof("")){ + error = rollCounts; + } + else{ + var rollMsg = tokens[2] + " rolling " + rollSpec.replace(/ /g, "+") + ":"; + var joinStr = " "; + for (var i = 0; i