Back to Shut the Box Project

Shut the Box Project - JS file

Additional Scripts Two

Instructions:

Use the block of code below to add to your stbScripts.js file. This code will be part of the IF STATEMENT instructions for what happens when you click on a tile. Copy and paste this code into the 'select(obj)' function between the conditional if{.....} and else{....};.
Lastly, you will need to fix the bug of being able to click on additional tiles after you have reached your dice roll total. To do this: make the variable total=0 when you the current tile total reaches the dice total. Then, add a conditional statement that will alert the user to roll and 'return;' to exit the select() function.

    else if (tempTotal==total) {
        //show roll button in leftside div.
        document.getElementById("leftside").style.visibility="visible";
        img.style.visibility="hidden";

        //change the array holding current tiles
        // to input a zero for the original value
        currentTiles.splice(obj-1,1,0);

        //make our temporary tileTotal back to empty and reset selectCount to zero.  tileTotal = Array();
        selectCount=0;
    }
            

You will need to add this line to your roll() function:
document.getElementById("leftside").style.visibility="hidden";

David Johns and Electric Teaching ~ All Rights Reserved 2015