function addGold() { $response = getSessionValue("totalGold", 0); $addThis = getValue("gold"); $response = $response + $addThis; setSessionValue("totalGold", $response); return $response; }
function addColor() { $response = getSessionValue("listOfColors", []); $color = getValue("color"); $response[] = $color; setSessionValue("listOfColors", $response); return $response; }
function guess() { $response = ""; $mynum = getSessionValue("randnum", -1); if ($mynum == -1) { $mynum = rand(0, 10); setSessionValue("randnum", $mynum); } $yourguess = getValue("num"); if ($yourguess == $mynum) { $response = "Correct! Play again"; setSessionValue("randnum", -1); } else { if ($yourguess < $mynum) { $response = "Too low, guess again."; } else { $response = "Too high, guess again."; } } return $response; }