X-Git-Url: https://git.ucc.asn.au/?p=progcomp2013.git;a=blobdiff_plain;f=web%2Fqwebchess%2Fjs.js;h=3474c3ac61d2fa7a15e8bc6eb2841600a70a6f14;hp=53e92884fe7c331a1e637bea6b06fcac9adf3f15;hb=b62f274ce80bc47fd5bd684cc4157860b8ad65f4;hpb=0138f6b08b7a7f364caf1f7ec6a9a26cf2684dfb;ds=sidebyside diff --git a/web/qwebchess/js.js b/web/qwebchess/js.js index 53e9288..3474c3a 100644 --- a/web/qwebchess/js.js +++ b/web/qwebchess/js.js @@ -6,13 +6,13 @@ */ pieceSelected = ""; // currently selected piece -playerColour = "W"; // colour of this player +playerColour = ""; // colour of this player // Unicode representations of chess pieces pieceChar = {"W" : { "p" : "\u2659", "h" : "\u2658", "b" : "\u2657", "r" : "\u2656", "q" : "\u2655", "k" : "\u2654", "?" : "?"}, "B" : { "p" : "\u265F", "h" : "\u265E", "b" : "\u265D", "r" : "\u265C", "q" : "\u265B", "k" : "\u265A", "?" : "?"}}; -emptyHTML = "     " +emptyHTML = "" gameStarted = false; canClick = true; @@ -32,7 +32,7 @@ $(document).ready(function() $("#status").html("white SELECT?"); $("#start").html("Quit Game"); pieceSelected = ""; - canClick = true; + canClick = false; $.ajax({url : "/cgi-bin/qchess.cgi", data : {r : "force_quit"}, success : function() {}}); $.ajax({url : "/cgi-bin/qchess.cgi", data : {r : "start"}}).done(function(data) {$(this).update(data)}); @@ -44,6 +44,7 @@ $(document).ready(function() $("#welcome").show(); $("#status").html("Game over"); $("#start").html("New Game"); + canClick = false; $.ajax({url : "/cgi-bin/qchess.cgi", data : {r : "quit"}, success : function() {console.log("Quit game");}}); } }); @@ -283,12 +284,25 @@ $(document).ready(function() } else switch (lines[i]) { + case "SELECT?": pieceSelected = ""; case "MOVE?": case "": case "New game.": break; + case "START white": + if (playerColour == "") + { + playerColour = "W"; + break; + } + case "START black": + if (playerColour == "") + { + playerColour = "B"; + break; + } default: alert("Game ends: " + lines[i]); gameStarted = false; @@ -341,7 +355,7 @@ $(document).ready(function() boardHTML += ""; for (var x = 0; x < 8; ++x) { - boardHTML += ""+emptyHTML+""; + boardHTML += ""+emptyHTML+""; } boardHTML += ""; }