📄 index.gml
字号:
<sys maxjavatime=0;>
<script>
var CTR=null;
var delmeArray=new Array(),tryDM=false;
function imgBtnMouseMsg(){
var obj=window.event.srcElement ;
switch(window.event.type){
case "mousedown":
obj.style.pixelTop+=2;
obj.testBTN=1;
break;
case "mouseup":
if(obj.testBTN==1) obj.style.pixelTop-=2;
obj.testBTN=0;
break;
case "mouseout":
if(obj.testBTN==1) obj.style.pixelTop-=2;
obj.testBTN=0;
break;
}
}
function initButton(){
var obj=document.images,x=new Array(),y=new Array(),obj2=document.all.txtCurID,x2,y2;
for(var i=0;i<document.images .length ;i++){
if(obj[i].className=="button"){
x[i]=obj[i].offsetLeft
y[i]=obj[i].offsetTop
}
}
x2=obj2.offsetLeft;
y2=obj2.offsetTop;
obj2.style.position ="absolute";
obj2.style.left=x2;
obj2.style.top=y2;
for(var i=0;i<document.images .length ;i++){
if(obj[i].className=="button"){
obj[i].onmouseover=imgBtnMouseMsg
obj[i].onmouseout=imgBtnMouseMsg
obj[i].onmousedown=imgBtnMouseMsg
obj[i].onmouseup=imgBtnMouseMsg
obj[i].testBTN=0;
obj[i].style.position ="absolute";
obj[i].style.left=x[i];
obj[i].style.top=y[i];
}
}
x=null;y=null;
}
init()
function init()
{
if(! document.SYSJSLOADOK)
{
setTimeout('init()',20)
return;
}
toolbar.innerHTML=
"<img class=button ID=PLAYSETUP src=images/1x1.gif width=50 height=26 border=0 class=TOOLIMG onclick=press(this) srchot='images/ask.gif'><br>"+
"<img class=button ID=TRYEND src=images/1x1.gif width=50 height=26 border=0 class=TOOLIMG onclick=press(this) srchot='images/dianmu.gif'><br>"+
"<img class=button ID=DMEND src=images/1x1.gif width=50 height=26 border=0 class=TOOLIMG onclick=press(this) srchot='images/dmok.gif'><br>"+
"<img class=button ID=AGNGO src=images/1x1.gif width=50 height=26 border=0 class=TOOLIMG onclick=press(this) srchot='images/agngo.gif'><br>"+
"<img class=button ID=UNDO src=images/1x1.gif width=50 height=26 border=0 class=TOOLIMG onclick=press(this) srchot='images/huiq.gif'><br>"+
"<img class=button ID=GMHE src=images/1x1.gif width=50 height=26 border=0 class=TOOLIMG onclick=press(this) srchot='images/qiuh.gif'><br>"+
"<img class=button ID=GMOVER src=images/1x1.gif width=50 height=26 border=0 class=TOOLIMG onclick=press(this) srchot='images/lost.gif'><br>"+
"<img class=button ID=START src=images/1x1.gif width=50 height=26 border=0 class=TOOLIMG onclick=press(this) srchot='images/start.gif'>"
setTimeout("initButton()",200);
CTR=new qiclass("GAMEMAP");
$GX.Cmd("<MCLIENTSOCKET port=5308>")
}
function qiclass(gmmapid)
{
this.map=document.all[gmmapid]
this.mapleft=parseInt(this.map.style.left);
this.maptop=parseInt(this.map.style.top);
this.player=new Array()
this.nullimg="images/1x1.gif"
this.qiimgdef=new Array("","images/qizi-h.gif","images/qizi-r.gif")
this.qiNdef=new Array("","B","W")
this.Nbuf="ABCDEFGHIGKLMNOPQRSTUVWXYZ"
this.STEPADD=new Array(0,-1,0,1, 1,-1,-1,1, -1,0,1,0, 1,1,-1,-1);
this.QISX=19
this.QISY=19
this.mqigew=20
this.mqigeh=20;//棋格h大小
this.ALLQIS=this.QISX*this.QISY
this.qiszw=20
this.qiszh=20
this.PLAYERS=2;//游戏所需人数
this.mcolor="rh";//mcolor
this.objects=new Array()
this.endgoid=-1
//规则
this.E_process_strg='';
//this.movemouse=qi_movemouse
this.showall=qi_showall
this.mygo=qi_mygo
this.addgo=qi_addgo
this.curchair=-1;
this.mychair=0;
this.end=qi_end
this.start=qi_start
this.init=qi_init
this.addQZ=qi_addQZ;
// this.map.onmousemove=
document.onmousemove=onmousemove
this.mousetrace=qi_tracemouse
//this.map.onmouseover="CURSOR.style.visibility=''"
//this.map.onmouseout="CURSOR.style.visibility='hide'"
//this.map.onmousedown=onmousedown
document.onmouseup=onmouseup
this.init()
}
function qi_tracemouse(x,y){
//return;
if(CTR.mychair>0){
if(tryDM){
CTR.MYWILLGO=null
CURSOR.style.left=-1000;
return;
}
var mx=x-CTR.mapleft
var my=y-CTR.maptop
var xi=parseInt(mx/CTR.mqigew),yi=parseInt(my/CTR.mqigeh)
if (CTR.qibuf[xi+yi*CTR.QISX]!=null || xi<0 || xi>=CTR.QISX || yi<0 || yi>=CTR.QISY ||
CTR.curchair!=CTR.mychair){
CTR.MYWILLGO=null
CURSOR.style.left=-1000;
return
}
var x=xi*CTR.mqigew+5,y=yi*CTR.mqigeh+5
var c=CTR.mcolor.charAt(CTR.mychair-1)
CTR.MYWILLGO=""+CTR.mychair+CHARDEF.charAt(parseInt(xi))+CHARDEF.charAt(parseInt(yi))
var cursor=CTR.qiimgdef[CTR.mychair]
if(CURSOR.oldsrc!=cursor) {CURSOR.src=cursor;CURSOR.oldsrc=cursor;}
}
}
//具体游戏
var hasInit=false;
function qi_showall(rechg,len)//显示所有对象
{
if (rechg){
this.qibuf=null;
this.qibuf=qi_tozhuzheng(this.E_process_strg,this.QISX,len?len:0,this);
}
var o,c,x,y,s=0,obj,img,strs="",ss=0
for (var y=0;y<this.QISY;y++)
{
for (var x=0;x<this.QISX;x++,s++)
{
obj=this.objects[s];
if (obj==null) {obj=eval("I"+s);this.objects[s]=obj;}
if ( (o=this.qibuf[s])==null)
{
if(!hasInit)
{
obj.oldimg=this.nullimg
obj.qi=0;
continue;
}
img=this.nullimg;
obj.qi=0;
}
else
{
c=o[0];
obj.qi=c;
img=this.qiimgdef[c]
// if(c!=1 && c!=2) alert(c)
}
if (obj.oldimg==img) continue;
obj.src=img;
obj.oldimg=img
strs+=img+","
}
}
hasInit=true
}
function delmeQIZ(delme){
delme+="";
if(!delme) return;
var xi,yi;
for(var i=0;i<delme.length;i+=2){
xi=parseInt(delme.charAt(i),36);
yi=parseInt(delme.charAt(i+1),36);
CTR.E_process_strg=CTR.E_process_strg.substr(0,CTR.E_process_strg.length-2)+myToStr(delmeArray.length);
// alert(myToStr(delmeArray.length))
// alert(CTR.E_process_strg);
delmeArray[delmeArray.length]=delme;
// CTR.qibuf[xi+yi*CTR.QISX]=null;
// alert(xi+yi*CTR.QISX)
}
CTR.showall(true)
}
function myToStr(n){
var t=n.toString(36);
// if(t.length<2) return "00"+t;
if(t.length<2) return "0"+t;
return t;
}
function chgCTRQP(str){
var o,e=new Array();
for(var i=0;i<str.length;i+=3){
o=qi_chang(str.substring(i,i+3));
e[o[1]+o[2]*CTR.QISX]=o;
}
CTR.qibuf=null;
CTR.qibuf=e;
CTR.showall();
}
function seeQipu(n){
var toID=n,max=QIPULIST.length-1;
if(!n && n!=0) toID=n=max;
if(n>max) n=max;
switch(n){
case 0:
document.all.txtCurID.value=0;
CTR.qibuf=new Array();
var obj=CTR.objects[CTR.endgoid];
if(obj){
obj.border=0;
obj.width=CTR.qiszw
obj.height=CTR.qiszh
}
CTR.showall();
return;
case -1:toID=max;break;
case -2:toID=parseInt(document.all.txtCurID.value)+1;
if(toID>=max) toID=max;
break;
case -3:toID=parseInt(document.all.txtCurID.value)-1;
if(toID<=0){
seeQipu(0);
return;
}
break;
}
document.all.txtCurID.value=toID;
CTR.showall(true,toID);
}
</script>
<style>
.man{
Oneat={delmeQIZ("$[ep1]")};
OnDMOK={DIVFEN1.innerHTML="$[ep0]";DIVFEN2.innerHTML="$[ep1]";
CURSOR.style.left=-1000;
tryDM=true;
GUIredraw();
chgCTRQP("$[ep2]");
};
OnallAG={tryDM=false;GUIredraw();};
OnisWin={tryDM=false;
switch($[ep0]){case 0: alert("$[ep1] 获胜!! ");break;
case 1: alert("对方超时,$[ep1] 获胜!! ");break;
}
};
OnnoCuoS={alert("对方不同意您的协商要求!! ");};
OnsetGZ={stepTime=0;
var str="$[ep0]",msg="",msg2="",t1,t2,t3;
oldGZ=str;
timeType=parseInt(str.charAt(0));
switch(str.charAt(0)){case '0':msg2=msg="本局 无限时 ";OPTLIST.item(0).selected=true;break;
case '1':
str=str.split("#");
t3=parseInt(str[1]);
stepAllMoreTime=t3*60000;
str=str[0];
t1=parseInt(str.substr(2),10);
t2=str.charAt(1)=='0';
// ?"分钟":"秒钟");
stepMaxTime=t2? t1*60000 : t1*1000;
msg=t1+(t2?"分钟":"秒钟");
var oOption = document.createElement("OPTION");
oOption.text="每步限时 "+msg;
oOption.selected=true;
document.all.OPTLIST.add(oOption);
msg2="本局每步限时"+msg+"<br>累计超时 "+t3+"分";
msg="本局 每步限时 "+msg+"\n累计超时 "+t3+" 分";
break;
case '2':
t1=parseInt(str.substr(1),10);
stepTime=t1*60000;
msg2=msg="本局限时 "+t1+"分钟";
var oOption = document.createElement("OPTION");
oOption.text=msg;
oOption.selected=true;
document.all.OPTLIST.add(oOption);
break;
}
OPTLIST.disabled=true;
curGZDiv.innerHTML=msg2;
alert(msg);
};
OnaNewG={
newJUStartTime=(new Date()).getTime();
setTimeout("tryEndGame()",100);
// stepTimer=setTimeout("stepTimeIO()",stepTime);
};
OnxiaoY={
playerStepCurTime[1]=$[ep0];playerStepCurTime[2]=$[ep1];
playerStepMoreTime[1]=$[ep2];playerStepMoreTime[2]=$[ep3];
stepMoreTime=0;stepStartTime=(new Date()).getTime();
writeCurTime();
};
Onover={alert("$[ep0]意外退出,游戏结束. ")};
}
.manS:CBTplyS{
class=man;
ifchged(delData)=!{
var temp="$[delData]";
// alert(temp)
if(!delmeArray) delmeArray=new Array();
temp=temp.split(",")
for(var i=0;i<temp.length;i++){
if(temp[i]) delmeArray[delmeArray.length]=temp[i];
}
};
OnerrMsg={switch($[ep0]){case 0: alert("不符合规则");break;
case 1: alert("当前不能点目,请等候对方确认!!! ");break;
case 2: alert("双方同意,请继续");break;
case 3: if(window.confirm ("对方要求如此,您是否同意")){
$GX.Cmd("<:"+document.MYNETNAME+" neteventtos=myDMOK;>");
}else{
$GX.Cmd("<:"+document.MYNETNAME+" neteventtos=noTryDM;>");
}
break;
case 4: alert("对方不同意您的点目方法");break;
case 5: alert("对方不同意点目");break;
case 6: alert("对方不同意点目结束");break;
case 7: alert("对方不同意继续走棋");break;
case 8: alert("计时时间到, 按当前状况计算输赢. ");break;
}
};
OntryDM={if(window.confirm ("对方要求点目,您是否同意")){
$GX.Cmd("<:"+document.MYNETNAME+" neteventtos=dianM;>");
}else{
$GX.Cmd("<:"+document.MYNETNAME+" neteventtos=noDM;>");
}
};
OntryAGNGO={if(window.confirm ("对方要求继续走棋,您是否同意")){
$GX.Cmd("<:"+document.MYNETNAME+" neteventtos=aGNGO;>");
}else{
$GX.Cmd("<:"+document.MYNETNAME+" neteventtos=noAGNGO;>");
}
};
OntryDMEnd={if(window.confirm ("对方要求点目结束,您是否同意")){
$GX.Cmd("<:"+document.MYNETNAME+" neteventtos=dMEnd;>");
}else{
$GX.Cmd("<:"+document.MYNETNAME+" neteventtos=noDMEnd;>");
}
};
}
.manO:CBTplyO{
class=man;
OncuoS={
var str="$[ep0]",msg="";
switch(str.charAt(0)){case '0':msg+="对方要求 本局 无限时 ";break;
case '1':
str=str.split("#");
t3=parseInt(str[1]);
playerStepCurTime[CTR.curchair]=t3*1000;
str=str[0];
msg+="对方要求 本局 每步限时 "+(parseInt(str.substr(2),10))+(str.charAt(1)=='0'?"分钟":"秒钟");
msg+="\n累计超时 "+ t3+" 分";
break;
case '2':msg+="对方要求 本局限时 "+(parseInt(str.substr(1),10))+"分钟";break;
}
msg=="\n您是否同意. ";
if(window.confirm(msg)){
$GX.Cmd("<:"+document.MYNETNAME+" neteventtos=cuoS,$[ep0];>");
}else{
$GX.Cmd("<:"+document.MYNETNAME+" neteventtos=noCuoS;>");
}
}
OnDestroy#delme={if($[Bchair]>0){
alert("$[ownername]退出,游戏结束. ");
clearAllBiaoX();
seeQipu(0);
CTR.curchair=-100;
}}
}
</style>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -