<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Food instanceof Game - RJM Programming - March, 2018</title>
<style>
td { width: 12%; height: 25%; border: 1px solid red; text-align: center; font-size: 40px; }
.f1:before { content: '\01f371 bento box' }
.f2:before { content: '\01f358 rice cracker' }
.f3:before { content: '\01f359 rice ball' }
.f4:before { content: '\01f35a cooked rice' }
.f5:before { content: '\01f35b curry rice' }
.f6:before { content: '\01f35c steaming bowl' }
.f7:before { content: '\01f35d spaghetti' }
.f8:before { content: '\01f360 roasted sweet potato' }
.f9:before { content: '\01f362 oden' }
.f10:before { content: '\01f363 sushi' }
.f11:before { content: '\01f364 fried shrimp' }
.f12:before { content: '\01f365 fish cake with swirl' }
.f13:before { content: '\01f361 dango' }
.f14:before { content: '\01F366 soft ice cream' }
.f15:before { content: '\01F367 shaved ice' }
.f16:before { content: '\01F368 ice cream' }
.f17:before { content: '\01F369 doughnut' }
.f18:before { content: '\01F36A cookie' }
.f19:before { content: '\01F382 birthday cake' }
.f0:before { content: '\01F370 shortcake' }
//1674 U+1F371 🍱 🍱 🍱 🍱 🍱 🍱 🍱 🍱 🍱 🍱 — 🍱 bento box
//1675 U+1F358 🍘 🍘 🍘 🍘 🍘 🍘 🍘 🍘 🍘 🍘 — 🍘 rice cracker
//1676 U+1F359 🍙 🍙 🍙 🍙 🍙 🍙 🍙 🍙 🍙 🍙 🍙 🍙 rice ball
//1677 U+1F35A 🍚 🍚 🍚 🍚 🍚 🍚 🍚 🍚 🍚 🍚 — 🍚 cooked rice
//1678 U+1F35B 🍛 🍛 🍛 🍛 🍛 🍛 🍛 🍛 🍛 🍛 — 🍛 curry rice
//1679 U+1F35C 🍜 🍜 🍜 🍜 🍜 🍜 🍜 🍜 🍜 🍜 🍜 🍜 steaming bowl
//1680 U+1F35D 🍝 🍝 🍝 🍝 🍝 🍝 🍝 🍝 🍝 🍝 — 🍝 spaghetti
//1681 U+1F360 🍠 🍠 🍠 🍠 🍠 🍠 🍠 🍠 🍠 — — 🍠 roasted sweet potato
//1682 U+1F362 🍢 🍢 🍢 🍢 🍢 🍢 🍢 🍢 🍢 🍢 — 🍢 oden
//1683 U+1F363 🍣 🍣 🍣 🍣 🍣 🍣 🍣 🍣 🍣 🍣 — 🍣 sushi
//1684 U+1F364 🍤 🍤 🍤 🍤 🍤 🍤 🍤 🍤 🍤 — — 🍤 fried shrimp
//1685 U+1F365 🍥 🍥 🍥 🍥 🍥 🍥 🍥 🍥 🍥 — — 🍥 fish cake with swirl
//1686 U+1F361 🍡 🍡 🍡 🍡 🍡 🍡 🍡 🍡 🍡 🍡 — 🍡 dango
//1687 U+1F95F 🥟 🥟 🥟 🥟 🥟 🥟 — 🥟 — — — — ⊛ dumpling
//1688 U+1F960 🥠 🥠 🥠 🥠 🥠 🥠 — 🥠 — — — — ⊛ fortune cookie
//1689 U+1F961
//1690 U+1F366 🍦 🍦 🍦 🍦 🍦 🍦 🍦 🍦 🍦 🍦 — 🍦 soft ice cream
//1691 U+1F367 🍧 🍧 🍧 🍧 🍧 🍧 🍧 🍧 🍧 🍧 — 🍧 shaved ice
//1692 U+1F368 🍨 🍨 🍨 🍨 🍨 🍨 🍨 🍨 🍨 — — 🍨 ice cream
//1693 U+1F369 🍩 🍩 🍩 🍩 🍩 🍩 🍩 🍩 🍩 — — 🍩 doughnut
//1694 U+1F36A 🍪 🍪 🍪 🍪 🍪 🍪 🍪 🍪 🍪 — — 🍪 cookie
//1695 U+1F382 🎂 🎂 🎂 🎂 🎂 🎂 🎂 🎂 🎂 🎂 🎂 🎂 birthday cake
//1696 U+1F370 🍰 🍰 🍰 🍰 🍰 🍰 🍰 🍰 🍰 🍰 🍰 🍰 shortcake
</style>
<script type='text/javascript'>
var foodsel='';
var morsel=[null,null];
var classes=['shortcake','bento box','rice cracker','rice ball','cooked rice','curry rice','steaming bowl','spaghetti','roasted sweet potato','oden','sushi','fried shrimp','fish cake with swirl','dango','soft ice cream','shaved ice','ice cream','doughnut','cookie','birthday cake'];
function Food(name) {
this.name = name;
this.Show = function(cla, pnum) {
if (cla == '') cla='f1';
var ss=document.getElementsByTagName('span');
if (eval(ss.length % 2) == 0) {
foodsel=this.name;
document.getElementById('mydiv' + pnum).innerHTML='<hr><span style="display:none;border:1px solid red;" id=s' + ss.length + ' class=' + cla + '></span><br>' + document.getElementById('mydiv' + pnum).innerHTML;
//alert('pnum=' + pnum);
//alert("eval(3 - eval('' + pnum))=" + eval(3 - eval('' + pnum)));
document.getElementById('tinstructions').innerHTML=document.getElementById('dname' + eval(3 - eval('' + pnum))).innerHTML + ', have a go at guessing what food ' + document.getElementById('dname' + pnum).innerHTML + ' chose.';
document.getElementById('opt' + eval(3 - eval('' + pnum))).innerHTML='Please select food ' + document.getElementById('dname' + pnum).innerHTML + ' chose below ...';
} else {
var tscore=eval(document.getElementById('score' + pnum).innerHTML.split('Score: ')[1].split('/')[0]);
var tgoes=eval(document.getElementById('score' + pnum).innerHTML.split('Score: ')[1].split('/')[1]);
tgoes++;
var found=false;
try {
eval("found=(morsel[" + eval(pnum % 2) + "] instanceof " + retclass(this.name) + ");");
} catch (eee) {
found=false;
}
if (found) { // if (this.name == foodsel) {
tscore+=classes.length;
document.getElementById('tinstructions').innerHTML='Well done, ' + document.getElementById('dname' + pnum).innerHTML + '. Who wants to select next?';
} else {
tscore=tscore;
document.getElementById('tinstructions').innerHTML='Bad luck, ' + document.getElementById('dname' + pnum).innerHTML + '. Who wants to select next?';
}
document.getElementById('score' + pnum).innerHTML='Score: ' + tscore + '/' + tgoes;
foodsel='';
document.getElementById('s' + eval(-1 + ss.length)).style.display='inline';
document.getElementById('mydiv' + pnum).innerHTML='<hr><span id=s' + ss.length + ' class=' + cla + '></span><br>' + document.getElementById('mydiv' + pnum).innerHTML;
document.getElementById('opt1').innerHTML='Please select your food below, out of view ...';
document.getElementById('opt2').innerHTML='Please select your food below, out of view ...';
}
};
}
function Shortcake(name) {
Food.call(this, name);
}
function BentoBox(name) {
Food.call(this, name);
}
function RiceCracker(name) {
Food.call(this, name);
}
function RiceBall(name) {
Food.call(this, name);
}
function CookedRice(name) {
Food.call(this, name);
}
function CurryRice(name) {
Food.call(this, name);
}
function SteamingBowl(name) {
Food.call(this, name);
}
function Spaghetti(name) {
Food.call(this, name);
}
function RoastedSweetPotato(name) {
Food.call(this, name);
}
function Oden(name) {
Food.call(this, name);
}
function Sushi(name) {
Food.call(this, name);
}
function FriedShrimp(name) {
Food.call(this, name);
}
function FishCakeWithSwirl(name) {
Food.call(this, name);
}
function Dango(name) {
Food.call(this, name);
}
function SoftIceCream(name) {
Food.call(this, name);
}
function ShavedIce(name) {
Food.call(this, name);
}
function IceCream(name) {
Food.call(this, name);
}
function Doughnut(name) {
Food.call(this, name);
}
function Cookie(name) {
Food.call(this, name);
}
function BirthdayCake(name) {
Food.call(this, name);
}
function putone(sto) {
var inum=eval(sto.id.replace('mysel',''));
//alert(eval(-1 + inum));
eval("morsel[" + eval(-1 + inum) + "]=new " + retclass(sto.options[sto.selectedIndex].text) + "('" + sto.options[sto.selectedIndex].text + "')");
morsel[eval(-1 + inum)].Show(sto.options[sto.selectedIndex].value, inum);
document.getElementById('mysel' + inum).value='';
}
function retclass(vianame) {
var bits=vianame.split(' ');
var sofar='';
for (var io=0; io<bits.length; io++) {
sofar+=bits[io].substring(0,1).toUpperCase() + bits[io].substring(1).toLowerCase();
}
return sofar;
}
function populate_select() {
for (var i=0; i<classes.length; i++) {
document.getElementById('mysel1').innerHTML+='<option value=f' + i + '>' + classes[i] + '</option>';
document.getElementById('mysel2').innerHTML+='<option value=f' + i + '>' + classes[i] + '</option>';
}
}
</script>
</head>
<body onload="populate_select();">
<h1>Food instanceof Game</h1>
<h3>RJM Programming - March, 2018</h3><br>
<table style='width:100%' border=50>
<tr><th><div id=dname1 contenteditable=true>Player1</div> <div id=score1>Score: 0/0</div></th><th>Instructions</th><th><div id=dname2 contenteditable=true>Player2</div> <div id=score2>Score: 0/0</div></th></tr>
<tr><td>
<select id='mysel1' onchange='putone(this);'><option id=opt1 value=''>Please select your food below, out of view ...</option></select><br><br>
<div id='mydiv1' style='float:left;'></div>
</td><td id=tinstructions></td><td>
<select id='mysel2' onchange='putone(this);'><option id=opt2 value=''>Please select your food below, out of view ...</option></select><br><br>
<div id='mydiv2' style='float:left;'></div>
</td></tr>
</table>
</body>
</html>