诘屈聱牙之javascript中国象棋
IE6.0 Only
非XHTML标准,可能IE 7.0也看不了....哈哈
蓝方先走
* { font:24px arial, "宋体"; font-weight:bold; color:white; cursor:default; }
table { table-layout:fixed; border-collapse:collapse; position:absolute; left:50px; top:50px; }
td { width:80px; height:80px; border:1px solid silver; color:black; text-align:center; line-height:80px; }
img.i1 { width:78px; height:78px; }
img.i2 { width:49px; height:49px; }
img.i3 { width:25px; height:49px; }
.chessman_red { background:url(/attachments/2007/3/29/20070329_2187cc5e9def581951f2v22EfdUSXQ7J.jpg); width:50px; height:50px; line-height:50px; text-align:center; }
.chessman_blue { background:url(/attachments/2007/3/29/20070329_5caa80c54f776b93bd582BwraVRWXf43.jpg); width:50px; height:50px; line-height:50px; text-align:center; }
var tb;
var cch=new Array();
var his=new Array();
var players=["red","blue"];
var curPlayer=1;
window.onload=function(){
document.onselectstart=function(){ return(false); }
document.onclick=do_click;
document.oncontextmenu=do_context;
tb=document.createElement("table");
document.body.appendChild(tb);
for(var i=0;ithis.y?this.y:y;
ma=y>this.y?y:this.y;
for(var i=mi+1;ithis.x?this.x:x;
ma=x>this.x?x:this.x;
for(var i=mi+1;i5||(!(y6))||Math.abs(this.x-x)!=1||Math.abs(this.y-y)!=1)return(false);
break;
case "相":
if(Math.abs(this.x-x)!=2||Math.abs(this.y-y)!=2||y>4)return(false);
if(cch[(this.y+y)/2*9+(this.x+x)/2])return(false);
break;
case "象":
if(Math.abs(this.x-x)!=2||Math.abs(this.y-y)!=2||y5||(!(y6))||(!((Math.abs(this.x-x)==1&&Math.abs(this.y-y)==0)||(Math.abs(this.x-x)==0&&Math.abs(this.y-y)==1))))return(false);
break;
case "兵":
//if(curPlayer%2==0){
if(y4){
if(y-this.y!=-1)return(false);
}else{
if(!((y-this.y==-1&&x==this.x)||(y==this.y&&Math.abs(this.x-x)==1)))return(false);
}
//}
break;
case "卒":
//if(curPlayer%2==0){
if(y>4){
if(y-this.y!=-1)return(false);
}else{
if(!((y-this.y==-1&&x==this.x)||(y==this.y&&Math.abs(this.x-x)==1)))return(false);
}
break;
//}else{
if(ythis.y?this.y:y;
ma=y>this.y?y:this.y;
for(var i=mi+1;ithis.x?this.x:x;
ma=x>this.x?x:this.x;
for(var i=mi+1;ithis.y?this.y:y;
ma=y>this.y?y:this.y;
for(var i=mi+1;ithis.x?this.x:x;
ma=x>this.x?x:this.x;
for(var i=mi+1;i25&&(event.x-50)%8025&&(event.y-50)%80-1&&x-1&&y
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]