From d511f8156ce8a6b4848a79c105de48a4dd9d0c4e Mon Sep 17 00:00:00 2001 From: Douglas Muth Date: Wed, 1 Feb 2017 21:50:33 -0500 Subject: [PATCH] Modified diceRoll() to return the raw value as well as the dice roll, updated unit tests, updated code that displays the dice. --- main.js | 18 ++++++++++++------ tests/tests.js | 10 +++++++--- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/main.js b/main.js index bed8424..2251282 100644 --- a/main.js +++ b/main.js @@ -150,10 +150,12 @@ Diceware.getNumValuesFromNumDice = function(num_dice) { * Get our maximum number for a random value, turn it into base-6, * then turn it into a dice roll! * +* @return object An object that contains a dice roll and the raw random value. +* */ Diceware.rollDice = function(num_dice) { - var retval = []; + var retval = {}; var max = Diceware.getNumValuesFromNumDice(num_dice); @@ -163,7 +165,8 @@ Diceware.rollDice = function(num_dice) { var dice = Diceware.convertBase6ToDice(base6, num_dice); - retval = dice; + retval.value = random; + retval.roll = dice; return(retval); @@ -428,8 +431,11 @@ Diceware.go = function() { for (var i=0; i