TDKHome.old/TDKCade/extras/subdivide.html
MattTheTekie 98d6691f82 uwu
uwu
2023-07-14 10:46:07 -04:00

341 lines
No EOL
24 KiB
HTML

<html>
<head>
<meta name="viewport" content="width=240">
<title>Subdivide</title>
<style>
body { margin: 0px; }
#nbessai, #remaining { border: 0px; }
#ecranduhaut, #ecrandubas { overflow: hidden; width: 240px; height: 176px; }
#resultat { padding-top: 2px; font-family: Sans-Serif; font-weight: bold; font-size: 8pt; line-height: 10pt; height: 12pt; background-color: #FFA000; margin-top: 3px; margin-bottom: 3px; }
#attempt { margin-top: 10px; }
#score { font-family: Sans-Serif; font-weight: bold; font-size: 8pt; line-height: 12pt; height: 12pt; float: left; margin-bottom: 3px; margin-left: 2px; text-align: left; }
#level { font-family: Sans-Serif; font-weight: bold; font-size: 8pt; line-height: 12pt; height: 12pt; float: right; margin-bottom: 3px; margin-right: 2px; text-align: right; }
#instruct { color: #000080; }
#popup { position: absolute; left: 18px; top: 16px; width: 200px; height: 312px; border: 4px solid #777777; background-color: #DDDDDD; display: none; }
#infoarea { margin: 5px; width: 190px; height: 278px; overflow: hidden; font-size: 8px; font-family: sans-serif; color: black; }
#buttonarea { margin: 5px; width: 190px; height: 18px; line-height: 18px; background-color: #FFB000; color: #DDDDDD; }
#hiscores, #instructions { float: left; text-align: center; width: 95px; height: 18px; font: 12px sans-serif; }
.selected { background-color: #CC5500; color: white; }
</style>
<script>
var COUNTS = [10, 50, 100, 250, 500, 1000, 1500, 2000, 2500, 5000, 7500, 9999];
var URlpage = location.href;
var cook;
var best;
var place;
var place2;
var level = 1;
var guesses = 5;
var score = 0;
var compteur = 0;
var plustard;
plustard = new Date(2020,11,11);
plustard = plustard.toGMTString();
function Secret(){
var secret = Math.round(Math.random() * COUNTS[Math.min(level-1, COUNTS.length-1)]);
var xam = guesses << 2;
var sesseug = 0;
if(secret == 0) secret++;
this.isNumeric = function(str)
{
for(var i=0; i<str.length; i++)
{ if(str.charCodeAt(i) < "0".charCodeAt(0) || str.charCodeAt(i) > "9".charCodeAt(0)) return false;
}
return true;
}
this.check = function(value)
{
sesseug++;
if(sesseug >= xam) window.elbasid = true;
if(value > secret) return 1;
if(value < secret) return -1;
return 0;
}
}
function record(){
document.jeu.rejou.value = "New game";
if(hiscores.isScoreHigher(score) && !window.elbasid) showScoreSubmit();
}
var secret = new Secret();
function verif(){
if(!secret.isNumeric(document.jeu.essai.value)) return;
if (secret.check(document.jeu.essai.value) > 0)
{
guesses--;
{document.getElementById("resultat").innerHTML = document.jeu.essai.value + ' is too large';}
}
if (secret.check(document.jeu.essai.value) < 0)
{
guesses--;
{document.getElementById("resultat").innerHTML = document.jeu.essai.value + ' is too small';}
}
if (secret.check(document.jeu.essai.value) == 0)
{
document.jeu.nbessai.value = " ";
document.getElementById("resultat").innerHTML = 'Victory in ' + (compteur+1) + ' attempts!';
compteur = -1;
document.jeu.valid.disabled = true;
document.jeu.essai.disabled = true;
setTimeout(function() {
var points = (COUNTS[Math.min(level-1, COUNTS.length-1)] * guesses * level);
score += points;
document.getElementById("resultat").innerHTML = points + " points earned";
}, 4000);
setTimeout(function() {
level++;
guesses += 5;
secret = new Secret();
updateScore();
updateLevel();
updateInstruct();
document.getElementById("resultat").innerHTML = "You earned 5 more guesses";
}, 7000);
setTimeout(function() {
document.jeu.valid.disabled = false;
document.jeu.essai.disabled = false;
document.getElementById("resultat").innerHTML = "Begin Level "+level;
document.getElementById("remaining").value = guesses;
}, 10000);
}
document.getElementById("remaining").value = guesses;
document.jeu.nbessai.value = ++compteur;
document.jeu.essai.value="";
document.jeu.essai.focus();
updateScore();
updateLevel();
updateInstruct();
if(guesses < 1){
document.jeu.valid.disabled = true;
document.jeu.essai.disabled = true;
document.getElementById("resultat").innerHTML = "Game Over";
record();
}
}
function updateScore(){
document.getElementById("score").innerHTML = "Score: "+score;
}
function updateLevel(){
document.getElementById("level").innerHTML = "Level: "+level;
}
function updateInstruct(){
document.getElementById("instruct").innerHTML = "Number between (1-"+(COUNTS[Math.min(level-1, COUNTS.length-1)])+")";
}
function showHighScores(){
var scores = hiscores.getScores();
var info = document.getElementById("infoarea");
var table;
var row;
var cell;
clearElement(info);
document.getElementById("hiscores").className = "selected";
document.getElementById("instructions").className = "";
if(scores.length < 1){
info.appendChild(document.createTextNode("No scores are currently available."));
return;
}
table = document.createElement("table");
table.cellSpacing = "0";
table.cellPadding = "0";
table.border = "0";
table.style.width = "190px";
table.style.fontSize = "8pt";
table.style.color = "black";
for(var i=0; i<scores.length && i<20; i++){
row = table.insertRow(-1);
cell = row.insertCell(-1);
cell.appendChild(document.createTextNode((i+1)+". "));
cell = row.insertCell(-1);
cell.appendChild(document.createTextNode(scores[i].name));
cell = row.insertCell(-1);
cell.align = "right";
cell.appendChild(document.createTextNode(scores[i].score));
}
info.appendChild(table);
}
function clearElement(element){
while(element.hasChildNodes()) element.removeChild(element.childNodes[0]);
}
function showHidePopup(evt){
var popup = document.getElementById("popup");
if(evt && evt.keyCode != 13) return;
if(evt){
evt.preventDefault();
evt.stopPropagation();
}
if(popup.style.display == "block"){
popup.style.display = "none";
clearElement(document.getElementById("infoarea"));
}
else{
popup.style.display = "block";
if(document.getElementById("hiscores").className == "selected") showHighScores();
else showInstructions();
}
}
function showInstructions(){
alert("Subdivide is a game that challenges you to think logically and use your intuition to take risks. Each level the computer thinks of a random number and asks you to guess it. You have a limited number of guesses before you lose. Each time you make a successful guess you get 5 more guesses for the next round. The more guesses remaining at the end of each level, the more points you earn. The higher the level the more each remaining guess is worth.");
/*var info = document.getElementById("infoarea");
var button = document.getElementById("hiscores");
var instructions = [
"Subdivide is a game that challenges you to think logically and use your intuition to take risks.",
"Each level, the computer thinks of a random number and asks you to guess it. You have a limited number of guesses before you lose. Each time you make a successful guess, you get 5 more guesses for the next round.",
"The more guesses remaining at the end of each level, the more points you earn. The higher the level, the more each remaining guess is worth.",
"Do you have the mental skill to own the leaderboards?",
"(Use A to dismiss this window.)"
];
clearElement(info);
for(var i=0; i<instructions.length; i++)
{
var p = document.createElement("p");
p.style.textAlign = "justify";
p.style.paddingLeft = "5px";
p.style.paddingRight = "5px";
p.appendChild(document.createTextNode(instructions[i]));
info.appendChild(p);
}
document.getElementById("hiscores").className = "";
document.getElementById("instructions").className = "selected";
}
function showScoreSubmit()
{
var info = document.getElementById("infoarea");
var line;
var input;
clearElement(info);
line = document.createElement("div");
line.align = "center";
line.style.fontSize = "16px";
line.style.color = "black";
line.style.fontWeight = "bold";
line.appendChild(document.createTextNode("A new high score!"));
info.appendChild(line);
line = document.createElement("div");
line.align = "center";
line.style.fontSize = "20px";
line.style.color = "red";
line.style.fontWeight = "bold";
line.style.marginTop = "20px";
line.style.marginBottom = "20px";
line.appendChild(document.createTextNode(score));
info.appendChild(line);
line = document.createElement("div");
line.align = "center";
line.style.fontSize = "16px";
line.style.color = "black";
line.style.fontWeight = "bold";
line.style.marginBottom = "75px";
line.appendChild(document.createTextNode("Enter your name below to submit your score."));
info.appendChild(line);
line = document.createElement("div");
input = document.createElement("input");
line.align = "center";
line.style.fontSize = "16px";
line.style.color = "black";
line.style.fontWeight = "bold";
line.style.marginBottom = "10px";
input.style.width = "120px";
input.id = "user";
input.maxLength = "16";
if(hiscores.getCachedName()) input.value = hiscores.getCachedName().substring(0, 16);
line.appendChild(input);
info.appendChild(line);
line = document.createElement("div");
input = document.createElement("button");
line.align = "center";
line.style.fontSize = "16px";
line.style.color = "black";
line.style.fontWeight = "bold";
input.onclick = submitScore;
input.appendChild(document.createTextNode("Submit"));
line.appendChild(input);
info.appendChild(line);
document.getElementById("popup").style.display = "block";*/
}
function submitScore(){
var user = document.getElementById("user").value;
var high = new HighScore(user, score);
if(user.length < 1) return;
high.level = level;
high.attempts = compteur;
hiscores.submitScore(high);
showHighScores();
}
document.addEventListener("keypress", showHidePopup, false);
</script>
<script>
if(!this.JSON){JSON={};}
(function(){function f(n){return n<10?'0'+n:n;}
if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return this.getUTCFullYear()+'-'+
f(this.getUTCMonth()+1)+'-'+
f(this.getUTCDate())+'T'+
f(this.getUTCHours())+':'+
f(this.getUTCMinutes())+':'+
f(this.getUTCSeconds())+'Z';};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}
var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}
function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}
if(typeof rep==='function'){value=rep.call(holder,key,value);}
switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}
v=partial.length===0?'[]':gap?'[\n'+gap+
partial.join(',\n'+gap)+'\n'+
mind+']':'['+partial.join(',')+']';gap=mind;return v;}
if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}
v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+
mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}
if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}
rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}
return str('',{'':value});};}
if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}
return reviver.call(holder,key,value);}
cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+
('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}
if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}
throw new SyntaxError('JSON.parse');};}}());
</script>
</head>
<body>
<div id="ecrandubas">
<div align="center">
<div id="level">Level: 1</div>
<div id="score">Score: 0</div>
<div>&nbsp;</div>
<font size="2" face="Verdana, Arial">
<form name="jeu">
<div id="instruct">Number between (1-10)</div>
<div id="attempt">
Your attempt : <input type="text" name="essai" size="3" maxlength="4">
<input type="button" name="valid" value="Guess" onClick="verif()">
</div>
<div id="resultat"></div>
Number of attempts : <input type="text" id="nbessai" name="nbessai" size=3 readonly value="0"><br />
Remaining Guesses : <input type="text" id="remaining" name="remaining" size=3 readonly value="5"><br /><br />
<input type="button" value="Instructions" onClick="showInstructions();">
<input type="button" name="rejou" value="Replay" onClick="location.href = URlpage">
</form>
</font>
</div>
</div>
</body>
</html>