diff options
Diffstat (limited to 'gameserver/gameserver.html')
-rw-r--r-- | gameserver/gameserver.html | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/gameserver/gameserver.html b/gameserver/gameserver.html index d8528ab..7fc27fc 100644 --- a/gameserver/gameserver.html +++ b/gameserver/gameserver.html @@ -74,19 +74,33 @@ function preinit(){ MOVES.push(arg[1]); addmovelistrow(arg[1]); nextmove(); - } else alert(arg[1]); - } else if(cmd=="your_turn"){ - canAlreadyTurn=true; - if(hasInited){ + } else { + alert(arg[1]); enableClicking(true,isFirstMove&&imPlayer==1); - isFirstMove=false; } + } else if(cmd=="other_turn"){ if(arg){ MOVES.push(arg); addmovelistrow(arg); nextmove(); } - } + } else if(cmd=="your_turn"){ + canAlreadyTurn=true; + if(hasInited){ + enableClicking(true,isFirstMove&&imPlayer==1); + isFirstMove=false; + } + } else if(cmd=="game_stop"){ + alert("Game has been stopped:\n"+arg); + enableClicking(false); + } else if(cmd=="game_win"){ + bgcell(neuidx).classList.add("win"); + if(arg==imPlayer){ + alert("You have won the game!"); + } else { + alert("You have lost the game! Better luck next time."); + } + } else alert("Unrecognised message "+msg); }); ws.addEventListener("open",function(){ ws.send("nick"); @@ -262,8 +276,8 @@ function addmovelistrow(mv,i/*optional*/){ if(moveidx==target)return; while(moveidx<target)nextmove(true); while(moveidx>target)prevmove(true); - setselectedmovelistline(i+1); - };})(i+1)); + setselectedmovelistline(target); + };})(i-1)); movelisttbody.appendChild(tr); } @@ -339,7 +353,7 @@ function nextmove(notimeout){ fgcells[neuidx]=null; neuidx=newidx; - if(moveidx==MOVES.length-1)bgcell(neuidx).classList.add("win"); + //if(moveidx==MOVES.length-1)bgcell(neuidx).classList.add("win"); } newidx=indexafterslide(MOVES[moveidx][1],MOVES[moveidx][2]); @@ -371,7 +385,9 @@ function prevmove(notimeout){ if(moveidx==0||!canclick)return false; moveidx--; - if(MOVES[moveidx][0]!=-1&&moveidx==MOVES.length-1)winGlowIdxToRemove=neuidx; + //if(MOVES[moveidx][0]!=-1&&moveidx==MOVES.length-1)winGlowIdxToRemove=neuidx; + for(var i=0;i<S*S;i++)if(bgcell(i).classList.contains("win"))break; + if(i<S*S)winGlowIdxToRemove=i; newidx=indexafterslide(MOVES[moveidx][1],MOVES[moveidx][2],true); board[MOVES[moveidx][1]]=board[newidx]; @@ -559,6 +575,12 @@ div#movelist tr.selected{ input[type=button].selected{ background-color:#aaf; } + +div#nickname{ + margin-top:10px; + font-family:Sans-serif; + font-style:italic; +} </style> </head> <body> |