From d70cbf638a0ba6f610c793678083e563bc3b62ae Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Thu, 25 Apr 2013 14:23:12 -0700 Subject: FIX: Blocks/Used walls are now stored in the client-side mapdata. --- js/mapspecs.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/js/mapspecs.js b/js/mapspecs.js index 446bc53..f55eb14 100644 --- a/js/mapspecs.js +++ b/js/mapspecs.js @@ -27,7 +27,6 @@ var isChallenge = false; var isTutorial = false; var solution = new Array(); -var blocks = new Array(); var count = new Array(); var mapdata = new Array(); var mapjson = new Array(); @@ -128,12 +127,12 @@ function grid_click(obj) { obj.setAttribute("class", "o"); childdiv.setAttribute("class", "child"); - blocks[mapid]++; + mapdata[mapid].usedWallCount++; //Remove wall solution[mapid] = solution[mapid].replace('.'+y+','+x+'.', '.'); } else { //Placing a wall - if (blocks[mapid] < 1) { + if (mapdata[mapid].usedWallCount < 1) { updateDsp(mapid, 'dspWalls', "OUT!"); return; } @@ -156,15 +155,12 @@ function grid_click(obj) { //Add Wall solution[mapid] += y+','+x+'.'; - blocks[mapid]--; + mapdata[mapid].usedWallCount--; } - //document.getElementById('blocksdisplay').innerHTML = ""+blocks[mapid]+""; if (isChallenge == true) { challengeWall(mapid); } - updateDsp(mapid, 'dspWalls', blocks[mapid]+" walls"); -//document.getElementById(mapid+',dspWalls').innerHTML = " "+blocks[mapid]+" walls"; - + updateDsp(mapid, 'dspWalls', mapdata[mapid].usedWallCount+" walls"); } function updateDsp(mapid, element, data) { @@ -180,13 +176,12 @@ function updateDsp(mapid, element, data) { function getmapdata(mapid) { - //console.log('getting data for mapID', mapid); if (typeof(mapdata[mapid]) != 'object') mapdata[mapid] = decryptJSON(jsonmapdata[mapid]); - blocks[mapid] = mapdata[mapid].walls; + mapdata[mapid].usedWallCount = mapdata[mapid].walls; solution[mapid] = '.'; - updateDsp(mapid, 'dspWalls', blocks[mapid]+" walls"); + updateDsp(mapid, 'dspWalls', mapdata[mapid].usedWallCount+" walls"); } function doSend(mapid) { @@ -827,6 +822,7 @@ function restoreSolution(mapid) { function displayMap(mapid, divID, goalSize, solution, moves, challengeMap, isThumb) { + clearwalls(mapid); var stringURL = 'a/map/'+mapid+".js"; if (challengeMap == true) stringURL = 'a/challenge/'+mapid+".js"; $.ajax({ @@ -868,6 +864,7 @@ function mapAsHTML(map, targetWidth, mapEditor) { //console.log("MapID:", map.mapid); //console.log("MapObj", map); mapdata[map.ID] = map; + getmapdata(map.ID); //Map bigger than target width? if (!targetWidth || (map.width * 35) <= targetWidth) -- cgit v1.2.3