»
EnglishFrenchVietnamese

Print - Tiger and Bull Chess - JavaScriptBank.com

Full version: jsB@nk » Game » Tiger and Bull Chess
URL: https://www.javascriptbank.com/tiger-and-bull-chess-index.html

Tiger and Bull Chess © JavaScriptBank.comThis is a JavaScript Chess Game for kids. This script won't allow users to make non-compliant moves and gives hints.

Full version: jsB@nk » Game » Tiger and Bull Chess
URL: https://www.javascriptbank.com/tiger-and-bull-chess-index.html



JavaScript
<script language="JavaScript"><!-- Startboxs = new Array; var value1 = "tiger.jpg", value2 = 0, value4 = "ready"; boxs[100] =document.A0;boxs[101] =document.A1;boxs[102] =document.A2;boxs[103] =document.A3;boxs[110] =document.B0;boxs[111] =document.B1;boxs[112] =document.B2;boxs[113] =document.B3;boxs[120] =document.C0;boxs[121] =document.C1;boxs[122] =document.C2;boxs[123] =document.C3;boxs[130] =document.D0;boxs[131] =document.D1;boxs[132] =document.D2;boxs[133] =document.D3;boxs[140] =document.E0;boxs[141] =document.E1;boxs[142] =document.E2;boxs[143] =document.E3;load_img1 = new Image();load_img2 = new Image();load_img1.src = "tiger_x.jpg";load_img2.src = "bull_x.jpg";function selected(var_k, var_num) {   if (var_num == "ready") {    if (checksrc(boxs[var_k].src, value1)) {       boxs[var_k].src = altersrc(boxs[var_k].src);       value2 = var_k; value4 = "move";     } else { movehelp(); }   } else if (var_num == "move") {    if (movable(var_k)) {      boxs[var_k].src = value1;       value1 = alterplay(value1);       boxs[value2].src = "blank.jpg";       value4 = "ready";     } else if (altersrc(boxs[var_k].src) == altersrc(value1)) {      boxs[value2].src = value1;       selected(var_k, "ready");     } else { movehelp(); }  }}function movable(var_k) {   var step = var_k - value2; step *= step;   if (step == 100 || step == 1) {    if (altersrc(boxs[var_k].src) == "blank.jpg") {      return 1;     }   } else if (step == 400 || step == 4) {    if (value1 == "tiger.jpg" &&         altersrc(boxs[var_k].src) == "bull_x.jpg") {      var halfsrc = boxs[(var_k + value2) / 2].src;       if (altersrc(halfsrc) == "blank.jpg") { return 2; }     }   } else { return 0; } }function alterplay(var_src) {   if (checksrc(var_src, "tiger.jpg")) {    return "bull.jpg";   } else if (checksrc(var_src, "bull.jpg")) {    return "tiger.jpg";   } else { return "blank.jpg"; } }function altersrc(var_src) {   if (checksrc(var_src, "tiger.jpg")) { return "tiger_x.jpg"; } else   if (checksrc(var_src, "bull.jpg")) { return "bull_x.jpg"; }  else { return "blank.jpg"; } }function checksrc(var_src, var_text) {   var snum = var_src.length;   var src_text = var_src.substring(snum - var_text.length, snum);   if (src_text == var_text) { return 1 } else { return 0 } }function attackhelp() {   var rulestext1 = "";   rulestext1 += "1. A Tiger chessman can kill a Bull chessman " +   "at the place pass a blank grid.";   rulestext1 += "\n2. But a Tiger chessman " +   "can not kill any Bull chessman just at the next grid.";   alert(rulestext1); }function movehelp() {   var rulestext2 = "",  rulestext3 = "";   if (value4 == "ready") {     if (value1 == "tiger.jpg"){       rulestext2 += "Tiger can move now; ";     } else if (value1 == "bull.jpg"){       rulestext2 += "Bull can move now; ";     }     rulestext2 += "Please select a chessman you want to move. ";     alert(rulestext2);   } else if (value4 == "move") {    rulestext2 += "This chessman can move one grid: ";      for (var i=0; i<5; i++) {      for (var j=0; j<4; j++) {        rulestext2 += teststep(i * 10 + j + 100, 1);       }     }     if (rulestext2 == "This chessman can move one grid: ")     { rulestext2 = "Sorry, this chessman can not move to anywhere now."; }     rulestext3 += "or two grids: ";      for (var i=0; i<5; i++) {      for (var j=0; j<4; j++) {        rulestext3 += teststep(i * 10 + j + 100, 2);       }     }     if (rulestext3 != "or two grids: ") { rulestext2 += rulestext3; }     alert(rulestext2 + "at present.");   }}function teststep(var_k, mv_num) {   var steptext = "";   if (movable(var_k)) {    if (var_k - value2 == 1 * mv_num) { steptext += "right; "; }    if (var_k - value2 == -1 * mv_num) { steptext += "left; "; }    if (var_k - value2 == 10 * mv_num) { steptext += "down; "; }    if (var_k - value2 == -10 * mv_num) { steptext += "up; "; }  }   return steptext; }// END / Many more are available free online --></script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<table width="100%" border="0" align="center" cellpadding="25" cellspacing="1" bgcolor="#ffeecc" class="main0">  <tbody><tr>     <td align="center" colspan="2" bgcolor="#ffffff">  <p align="center">    <a href="javascript:movehelp();" class="main0">(1). Help on the Moving</a>&nbsp;&nbsp;&nbsp;&nbsp;    <a href="javascript:attackhelp();" class="main0">(2). Help on the Attack</a>&nbsp;&nbsp;&nbsp;&nbsp; (3). Rules on Winning: <br>If the Tiger chessmen have killed all the Bull chessmen, then the Tiger chessmen win; or the <br>Bull chessmen have made all the Tiger chessmen not able to move anywhere, then the Bull chessmen win.   </p> <form name="cform" class="liform"><table border="0" width="540" cellspacing="20" bgcolor="#cc6666" cellpadding="2">  <tbody><tr>    <td width="100%" bgcolor="#ffffff"><table border="0" width="480" height="475" bgcolor="#cc6666"><tbody><tr><td width="120" height="95" bgcolor="#ffffff"><img border="0" name="A0" src="bull.jpg" onmousedown="selected(100, value4)" width="120" height="95"></td><td width="120" height="95" bgcolor="#ffffff"><img border="0" name="A1" src="bull.jpg" onmousedown="selected(101, value4)" width="120" height="95"></td><td width="120" height="95" bgcolor="#ffffff"><img border="0" name="A2" src="bull.jpg" onmousedown="selected(102, value4)" width="120" height="95"></td><td width="120" height="95" bgcolor="#ffffff"><img border="0" name="A3" src="bull.jpg" onmousedown="selected(103, value4)" width="120" height="95"></td></tr><tr><td width="120" height="95" bgcolor="#ffffff"><img border="0" name="B0" src="bull.jpg" onmousedown="selected(110, value4)" width="120" height="95"></td><td width="120" height="95" bgcolor="#ffffff"><img border="0" name="B1" src="bull.jpg" onmousedown="selected(111, value4)" width="120" height="95"></td><td width="120" height="95" bgcolor="#ffffff"><img border="0" name="B2" src="bull.jpg" onmousedown="selected(112, value4)" width="120" height="95"></td><td width="120" height="95" bgcolor="#ffffff"><img border="0" name="B3" src="bull.jpg" onmousedown="selected(113, value4)" width="120" height="95"></td></tr><tr><td width="120" height="95" bgcolor="#ffffff"><img border="0" name="C0" src="blank.jpg" onmousedown="selected(120, value4)" width="120" height="95"></td><td width="120" height="95" bgcolor="#ffffff"><img border="0" name="C1" src="blank.jpg" onmousedown="selected(121, value4)" width="120" height="95"></td><td width="120" height="95" bgcolor="#ffffff"><img border="0" name="C2" src="blank.jpg" onmousedown="selected(122, value4)" width="120" height="95"></td><td width="120" height="95" bgcolor="#ffffff"><img border="0" name="C3" src="blank.jpg" onmousedown="selected(123, value4)" width="120" height="95"></td></tr><tr><td width="120" height="95" bgcolor="#ffffff"><img border="0" name="D0" src="blank.jpg" onmousedown="selected(130, value4)" width="120" height="95"></td><td width="120" height="95" bgcolor="#ffffff"><img border="0" name="D1" src="blank.jpg" onmousedown="selected(131, value4)" width="120" height="95"></td><td width="120" height="95" bgcolor="#ffffff"><img border="0" name="D2" src="blank.jpg" onmousedown="selected(132, value4)" width="120" height="95"></td><td width="120" height="95" bgcolor="#ffffff"><img border="0" name="D3" src="blank.jpg" onmousedown="selected(133, value4)" width="120" height="95"></td></tr><tr><td width="120" height="95" bgcolor="#ffffff"><img border="0" name="E0" src="blank.jpg" onmousedown="selected(140, value4)" width="120" height="95"></td><td width="120" height="95" bgcolor="#ffffff"><img border="0" name="E1" src="tiger.jpg" onmousedown="selected(141, value4)" width="120" height="95"></td><td width="120" height="95" bgcolor="#ffffff"><img border="0" name="E2" src="tiger.jpg" onmousedown="selected(142, value4)" width="120" height="95"></td><td width="120" height="95" bgcolor="#ffffff"><img border="0" name="E3" src="blank.jpg" onmousedown="selected(143, value4)" width="120" height="95"></td></tr>  </tbody></table>    </td>  </tr></tbody></table></form><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


Files
http://javascriptbank.com/javascript/game/Tiger_and_Bull_Chess/blank.jpghttp://javascriptbank.com/javascript/game/Tiger_and_Bull_Chess/bull.jpghttp://javascriptbank.com/javascript/game/Tiger_and_Bull_Chess/tiger.jpg