/* "guessing.js" is a simple guess the number game created to illustrate the basics of gaming. Usage: this file is invoked from guessing.html Author: David Johnston Date: 2016 Version: 1 */ // game constants -------------------------------------------------- const TITLE = "Guessing Game"; const MAXNUM = 30; const CLUELOWER = "It's lower than that."; const CLUEHIGER = "It's higher than that"; const REPSUCCESS = "Yes! You got it!"; const REPINIT = "Guess the correct number before the score reaches zero."; const NAIREPLY = "That doesn't appear to be an integer. Try again."; const R00 ="You second-hand mound of goofy rotting vegetation."; const R01 = "Ha! Ha! You're wrong"; const R02 = "You pitiful mouthful of rotting lizard droppings."; const R03 = "You manky dollop of yeasty rotting vegetation."; const R04 = "Nope! Try again."; const R05 = "Sigh. You're not very good at this."; const ENTERKEY = 13; // the keycode for the enter key // game variables ------------------------------------------------------------- var theNumber = Math.floor(Math.random() * MAXNUM); var guess = "0"; // will be *string* entered by player var score = MAXNUM; // score counts down from this number var replies = [R00, R01, R02, R03, R04, R05]; var repliesIndex = 0; var comment = "This will be changed later in the code."; var gameIsOver = false; // get and setup the page title ----------------------------------------------- var headingArea = document.getElementById("headingArea"); headingArea.innerHTML = TITLE;