function play()
{
if (param["num"] < 2)
{ // ゲームの終了
document.write('<form action="isitori.html" method="get">');
document.write('<input type="hidden" name="num" value=0>');
document.write('<input type="hidden" name="max" value=1>');
document.write('<input type="hidden" name="teban" value=1>');
if ((param["num"]==1 && param["teban"]==1) ||
(param["num"]==0 && param["teban"]==-1))
document.write('<br><input type="text" value="私の勝ちです">');
else
document.write('<br><input type="text" value="私の負けです">');
document.write('<br><br><input type="submit" value="送信">');
document.write('</form>');
return;
}
if (param["teban"] == 1)
{ // プレイヤーがプレイする
document.write('<form action="isitori.html" method="get">');
document.write('<input type="hidden" name="num" value=',param["num"],'>');
document.write('<input type="hidden" name="max" value=',param["max"],'>');
document.write('<input type="hidden" name="teban" value=-1>');
w = param["max"];
if (w>param["num"]) w = param["num"];
document.write('<br><input type=radio name="val" value=1 CHECKED>1 個取る<br>');
for(i=2; i<=w; i++)
document.write('<br><input type=radio name="val" value=',i,'>',i,' 個取る<br>');
document.write('<br><input type=radio name="val" value=0>END<br>');
document.write('<br><input type="submit" value="送信">');
document.write('</form>');
}
else
{ // コンピュータがプレイする
mx = param["max"];
nm = param["num"];
v = (nm+mx) % (mx+1);
if (v==0) v = 1;
param["num"] -= v;
document.write('<form action="isitori.html" method="get">');
document.write('<input type="hidden" name="num" value=',param["num"],'>');
document.write('<input type="hidden" name="max" value=',param["max"],'>');
document.write('<input type="hidden" name="teban" value=1>');
document.write('<br><input type="text" value="私の番です"><br>');
document.write('<br><input type="submit" value="送信">');
document.write('</form>');
}
}
</script>
</head>
|