<script src="jewel_class.js"></script> </head> <body> <h2>石取ゲームβ版</h2> <script type="text/javascript"> var jewel = new jewel_class(); // num から val 個の石を取り除く if (param["num"] >= param["val"]) param["num"] -= param["val"]; // 石を表示する jewel.disp(); // プレイする jewel.play(); </script> |
this.play = function() { if (param["num"] < 2) { // ゲームの終了 document.write('<form action="isitori3.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('<input type="text" value="私の勝ちです">'); else document.write('<input type="text" value="私の負けです">'); document.write('<input type="submit" value="送信">'); document.write('</form>'); return; } |
if (param["teban"] == 1) { // プレイヤーがプレイする document.write('<form action="isitori3.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('<input type=radio name="val" value=1 CHECKED>1 個取る<br>'); for(i=2; i<=w; i++) document.write('<input type=radio name="val" value=',i,'>',i,' 個取る<br>'); document.write('<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="isitori3.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('<input type="text" value="私の番です">'); document.write('<input type="submit" value="送信">'); document.write('</form>'); } } } </script> |