From 0759852ab7a9af16e5f4c444ef5d1e0db6feabd3 Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Sat, 18 Aug 2012 17:45:59 -0700 Subject: The start on Multi-day maps and Dual Path mechanic Halfway started both. --- css/maps.css | 4 ++++ css/stats.css | 2 +- do.php | 37 +++++++++++++++++++++++++++++++------ images/OverlayStart2.png | Bin 0 -> 3564 bytes includes/mapoftheday.php | 2 +- includes/maps.php | 37 ++++++++++++++++++++++++++++++++++--- js/mapspecs.js | 4 +++- pages/home.php | 13 ++++++++++++- 8 files changed, 86 insertions(+), 13 deletions(-) create mode 100644 images/OverlayStart2.png diff --git a/css/maps.css b/css/maps.css index cbc0a3b..13fcacb 100644 --- a/css/maps.css +++ b/css/maps.css @@ -159,6 +159,10 @@ background: url(../images/OverlayStart50b.png); background-color: #fbfefb; } +.grid_td_startB { + background: url(../images/OverlayStartB.png); + background-color: #fbfefb; +} .grid_td_finish { background: url(../images/OverlayFinish50c.png); background-color: #666666; diff --git a/css/stats.css b/css/stats.css index 8211711..8d3b361 100644 --- a/css/stats.css +++ b/css/stats.css @@ -81,7 +81,7 @@ td, th { background-color: #222223; } .scoreContainer2 { - width:390px; + width:410px; height:500px; margin-left:auto; margin-right:auto; diff --git a/do.php b/do.php index 549cfaf..5473cba 100644 --- a/do.php +++ b/do.php @@ -128,10 +128,21 @@ if ($_GET['r'] == 'getpath') { $map = GenerateMapByCode($mapcode); $mygrid = MergeMapSolution($map, $solution); + // Old + //$json = routePath($mygrid); + + // New + // !! Broken! //Route the path - $json = routePath($mygrid, $start); + $json['path1'] = routePath($mygrid); + $json['path2'] = routePath($mygrid, 'X'); + + // !! Tmp + //$moves = $json['moves']; + $moves = $json['path1']['moves']; - $moves = $json['moves']; + // !! Tmp + $json['blocked'] = ($json['path1']['blocked']); $json['mapid'] = $mapID; @@ -218,7 +229,7 @@ if ($_GET['r'] == 'getpath') { $checkcm = false; //Is there an existing record? - if ($myMoves > 0) { + if (isset($myMoves)) { if ($myMoves < $moves) { $sql = "UPDATE `solutions` SET `moves` = '$moves' , @@ -265,10 +276,24 @@ if ($_GET['r'] == 'getpath') { function isCurrentMap($mapID) { + // !! Broke include_once('./includes/db.inc.php'); - $sql = "SELECT `ID` FROM `mapOfTheDay` - WHERE `mapDate` = CURDATE() AND - `mapID` = '$mapID' + $sql = "SELECT maps.ID + FROM `mapOfTheDay` + LEFT JOIN `maps` ON maps.ID = `mapID` + WHERE + `mapID` = '$mapID' AND + ( + ( + DATEDIFF(CURDATE(), mapOfTheDay.mapDate) < 1 AND + `mapType` IN (1, 2, 3, 4) + ) + OR + ( + DATEDIFF(CURDATE(), mapOfTheDay.mapDate) < 2 AND + `mapType` IN (5) + ) + ) "; $result = mysql_query($sql) or die(mysql_error()); if (mysql_num_rows($result) == 0) diff --git a/images/OverlayStart2.png b/images/OverlayStart2.png new file mode 100644 index 0000000..123cddd Binary files /dev/null and b/images/OverlayStart2.png differ diff --git a/includes/mapoftheday.php b/includes/mapoftheday.php index 6e0d14d..c5b9834 100644 --- a/includes/mapoftheday.php +++ b/includes/mapoftheday.php @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/includes/maps.php b/includes/maps.php index 1f2363a..1e18804 100644 --- a/includes/maps.php +++ b/includes/maps.php @@ -35,6 +35,9 @@ function DisplayMap($mapMatrix, $idprefix = 1, $style = 'normal', $speed = NULL) { case 's': $maptable .= "
"; break; + + case 'S': $maptable .= " +
"; break; case 'f': $maptable .= "
"; break; //TP1 @@ -835,6 +838,7 @@ function findPath($mapMatrix, $start = '0,1', $target = 'f') { //!! case "p": case "s": case "f": //Start and end tiles + case "S": //!! case "a": case "b": case "c": case "d": case "e": //Checkpoints too case "u": case "n": case "h": case "j": case "l": //Teleport-out towers included! @@ -890,13 +894,29 @@ function routePath($mygrid, $start = '', $validate = false) { //Our response $r = array('start' => NULL, 'path' => NULL, 'blocked' => true); - //Locate the start locations. - $start = findTiles($mygrid, "s"); + + //Scan the map for these tiles. + // Doing this scan once is far more effecient than rescanning. + $tileLocations = findTilesM($mygrid, str_split('S')); + + if (in_array($tileLocations, "S") { + + } + + + // Tmp bad code.. + if ($start == 'X') + $start = findTiles($mygrid, "S"); + else + $start = findTiles($mygrid, "s"); + + //Checkpoint names $cpnames = array("a", "b", "c", "d", "e"); + //!! Improve the 'findTiles' function to prevent duplicate itterations. //Add the existing checkpoints to target array. foreach ($cpnames as $cpt) if (findTiles($mygrid, $cpt)) @@ -1047,5 +1067,16 @@ function weight() { return $weights[rand(0, (count($weights) -1))]; } +function findTilesM ($mapMatrix, $search) { + $r = array(); + for( $i = 1; $i <= $mapMatrix[0][1]; $i++) { //Number of Rows + for( $j = 0; $j < $mapMatrix[0][0]; $j++) { //Number of Columns + foreach($search as $item) + if ($mapMatrix[$i][$j] == $item) + $r[$item][] = "$j,$i"; + } + } + return $r; +} -?> +?> \ No newline at end of file diff --git a/js/mapspecs.js b/js/mapspecs.js index 87bc173..4d4acbe 100644 --- a/js/mapspecs.js +++ b/js/mapspecs.js @@ -284,7 +284,9 @@ function request_path_done() { var disptext = "Record: "+JO.best+" by "+JO.bestby; updateDsp(JO.mapid, 'dspID', disptext); - animatePath(JO.path, JO.mapid, JO.start); + animatePath(JO.path1.path, JO.mapid, JO.path1.start); + + animatePath(JO.path2.path, JO.mapid, JO.path2.start); } function decryptJSON(text) { diff --git a/pages/home.php b/pages/home.php index 7e5e401..2b59bc2 100644 --- a/pages/home.php +++ b/pages/home.php @@ -109,6 +109,15 @@ if ($special == '') { $special = 'Special'; } +$motd = MapOfTheDay(5); +$jmid[5] = $motd['id']; +$mapContent .= displayMaze($motd, 5); + +$special2 = $motd['map'][0][6]; +if ($special2 == '') { + $special2 = 'Special'; +} + ?>
@@ -116,6 +125,7 @@ if ($special == '') { Normal Complex +
@@ -247,7 +257,7 @@ $timerem = strtotime("tomorrow") - strtotime("now");