Role Reveral of Guessing Numbers

[Total: 0    Average: 0/5]

You play the role of a psychic, our job is to read the mind of the computer,

Head Code:

<script>

/* 
 * Script Author: Hell Steinovski <hellsteinovski@hotmail.co.uk>
 */

/*
 * Get the range of numbers to make a guess from
 */
function getSize()
{
  var _default=100;
  var cl;
  var _cl ='Choose level of difficulty.n';
      _cl+='Please input a number of any size, the range will be 0 to whatever your input is'; 
  cl=prompt(_cl,_default); 
  var clic=parseFloat(cl);
  if(cl!=clic)
  {
    alert('Integers only Please! ( -/+ numbers and 0 ) NoLetters or special character');
    history.go(0);
  }
  return clic;
}

function makeNumber(_range)
{
  alert('On the next prompt,input your psychic reading:0-'+_range);
  var eng=Math.round(Math.random()*_range);
  return eng;
}

function getGuess()
{
  var guess=prompt('What number am i thinking of?');
  var numo=parseFloat(guess);
  if(guess!=numo)
  {
    alert('Numbers only Please! No Letters or special character');
    history.go(0);
  }
  return numo;
}

function startGame()
{
  var SIZE=getSize();
  var NUMB=makeNumber(SIZE);
  var GUES=getGuess();
  var YES="<br><br><center><font color='green' size='20'>you are a natural!</font></center>";
  var NOT="<br><br><font color='red' size='16'>You're Not Really Psychic Are You?<br>";
  var TI ="<font color='blue' size='16'>i was thinking of:</font>";
  var _obj=document.getElementById("message");
  if (GUES==NUMB)
    _obj.innerHTML=YES;
  else
    _obj.innerHTML=NOT+TI+NUMB;
}
</script>

Body Code:

You play the role of a psychic, our job is to read the mind of the computer,<BR>
as of version three you get to input your own level, of an infinite value.<BR>
be warned, you only get one (high levels recomended for real psychics).<BR>
<form><input type=button value="Start Guessing Game" onclick="startGame()"></form>
<HR>
<span id=message></span>

Times Viewed: 3

Leave a Reply

Your email address will not be published. Required fields are marked *