summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--css/maps.css4
-rw-r--r--css/stats.css2
-rw-r--r--do.php37
-rw-r--r--images/OverlayStart2.pngbin0 -> 3564 bytes
-rw-r--r--includes/mapoftheday.php2
-rw-r--r--includes/maps.php37
-rw-r--r--js/mapspecs.js4
-rw-r--r--pages/home.php13
8 files changed, 86 insertions, 13 deletions
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
--- /dev/null
+++ b/images/OverlayStart2.png
Binary files 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 @@
-<?PHP include_once('maps.php'); include_once('db.inc.php'); function mapOfTheDay($type = 1) { ignore_user_abort(true); $sql = " select maps.ID, maps.code FROM `mapOfTheDay`, `maps` WHERE `mapDate` = CURDATE() AND `mapType` = $type AND mapID = maps.ID "; $result = mysql_query($sql); //No map for today? if (mysql_num_rows($result) == 0) { // If you want to modify the maps created! This is the line //GenerateMap($rows, $cols, $rockchance, $numBlocks = -1, $cp = -1, $tp = -1) { switch ($type) { case 1: //Easy $map = GenerateMap(13, 7, 12, rand(7,10), rand(0, 1), 0); break; case 2: //Normal $map = GenerateMap(15, 9, 7, rand(11,13), rand(1,3) + rand(0,1), 0); break; case 3: //Hard $map = GenerateMap(19, 9, rand(7, 9), rand(14,16), rand(2,5), rand(1,2)); break; case 4: //Full random map $map = getRandomSpecialMap(); break; default: $map = GenerateMap(rand(13, 18), rand(10, 14), rand(6, 9)); break; } //Double check... $sql = " select maps.ID, maps.code FROM `mapOfTheDay`, `maps` WHERE `mapDate` = CURDATE() AND `mapType` = $type AND mapID = maps.ID "; $result = mysql_query($sql); //Are you SURE there's no map? if (mysql_num_rows($result) != 0) return mapOfTheDay($type); $code = GenerateMapCode($map); $sql = "INSERT INTO `maps` (`code`) VALUES ('$code')"; $result = mysql_query($sql); if (!$result) die("Error on inserting map"); $mapID = mysql_insert_id(); $r['code'] = $code; $r['map'] = $map; $r['id'] = $mapID; $sql = "INSERT INTO `mapOfTheDay` (`mapID`, `mapType`, `mapDate`) VALUES ('$mapID', '$type', CURDATE()) "; $result = mysql_query($sql); if (!$result) die("Error on insert into mapOfTheDay"); // ---------- Track statistics for 'yesterdays' map. trackMOTDstats($type); return $r; } $r['code'] = mysql_result($result, 0, 'code'); $r['map'] = GenerateMapByCode($r['code']); $r['id'] = mysql_result($result, 0, 'ID'); return $r; } //Select from yesterday function getYesterdaysMap() { $sql = " select `ID`, `code` from `maps` WHERE ( DAY(dateCreated) = DAY(NOW()) - 1 AND MONTH(dateCreated) = MONTH(NOW()) AND YEAR(dateCreated) = YEAR(NOW()) ) "; $result = mysql_query($sql); //No map for today? if (mysql_num_rows($result) == 0) { return -1; } $r['code'] = mysql_result($result, 0, 'code'); $r['id'] = mysql_result($result, 0, 'ID'); return $r; } function getRandomSpecialMap() { //This can be used to add additional weight to certain maps that we like. $random = weight(0, 1, 2, 3, 4, 5, 6, 7, 8); $shape = array(); $params = array(); switch ($random) { //===================================== case 0: //Thirty $map = GenerateMap( 18, 14, 20 , //width, height, rocks weight(30) , //Walls weight(1) , //Checkpoints weight(1) , //Teleports 'Thirty' ); break; //===================================== case 1: //Simple $map = GenerateMap( 18, 9, 7 , //width, height, rocks weight(15,16,17) , //Walls weight(0) , //Checkpoints weight(0) , //Teleports 'Finite' ); break; //===================================== case 2: //ABC's $map = GenerateMap( 19, 11, 12 , //width, height, rocks weight(20,21,22,22,23) , //Walls weight(3) , //Checkpoints weight(0) , //Teleports "ABC's " ); break; //===================================== case 3: //Tele Madness $map = GenerateMap( 17, 12, 10 , //width, height, rocks weight(17,18) , //Walls weight(1) , //Checkpoints weight(5) , //Teleports 'Teleport Madness' ); break; //===================================== case 4: //Thursday //Rocky Maze $map = GenerateMap( 19, 15, 5 , //width, height, rocks weight(16,17,18) , //Walls weight(1,2,2,2,3,3) , //Checkpoints weight(0) , //Teleports 'Rocky Maze' ); break; //===================================== case 5: //Friday //Side to Side $map = GenerateMap( 26, 6, 12 , //width, height, rocks weight(17,18,19) , //Walls weight(2,2,2,3,3) , //Checkpoints weight(3,3,3,4) , //Teleports 'Side to Side' ); break; //===================================== case 6: //Ultimate's Random map: //Create shape $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; //Insert points $shape = insertPoint($shape, "sfabcr", $target = '?'); $shape = insertPoint($shape, weight("tu", "d", "tu", "", ""), $target = '?'); //Set params $params['rockchance'] = 10; $params['walls'] = weight(21, 20, 22, 20, 21); $params['name'] = 'Ultimate Random'; //Put it all together. $map = GenerateShapedMap($shape, $params); break; //===================================== //===================================== case 7: //Dual map $dualmapa[] = "s???????????????????f"; $dualmapa[] = "s???????????????????f"; $dualmapa[] = "s???????????????????f"; $dualmapa[] = "s???????????????????f"; $dualmapa[] = "s???????????????????f"; $dualmapa[] = "s???????????????????f"; $dualmapa[] = "oqqqqqqqqqqqqqqqqqqqo"; $dualmapb[] = "s???????????????????f"; $dualmapb[] = "s???????????????????f"; $dualmapb[] = "s???????????????????f"; $dualmapb[] = "s???????????????????f"; $dualmapb[] = "s???????????????????f"; $dualmapb[] = "s???????????????????f"; $dualmapa = insertPoint($dualmapa, 'abc'); $dualmapb = insertPoint($dualmapb, 'abc'); $dualmap = array_merge($dualmapa, $dualmapb); $dualmap = insertPoint($dualmap, 'tu'); $myparams['checkpoints'] = 3; $myparams['teleports'] = 1; $myparams['rockchance'] = 9; $myparams['walls'] = weight(20, 20, 21, 21, 22, 23); $myparams['name'] = 'Seeing Double'; $map = GenerateShapedMap($dualmap, $myparams); break; //===================================== //===================================== case 8: //Centralized $myshape[] = "ooooooooooooooooooo"; $myshape[] = "o?????????????????o"; $myshape[] = "o?????????????????o"; $myshape[] = "o?????????????????o"; $myshape[] = "o???????fos???????o"; $myshape[] = "o?????????????????o"; $myshape[] = "o?????????????????o"; $myshape[] = "o?????????????????o"; $myshape[] = "ooooooooooooooooooo"; $myshape = insertPoint($myshape, "abc", $target = '?'); $myshape = insertPoint($myshape, weight("tu", "d", "tud", ""), $target = '?'); $myparams['rockchance'] = 7; $myparams['walls'] = weight(17, 18, 19, 18, 17); $myparams['name'] = 'Centralized'; $map = GenerateShapedMap($myshape, $myparams); break; //===================================== } return $map; } ?> \ No newline at end of file
+<?PHP include_once('maps.php'); include_once('db.inc.php'); function mapOfTheDay($type = 1) { ignore_user_abort(true); if ($type <= 8) $expire = 2; if ($type <= 4) $expire = 1; $sql = " SELECT maps.ID, maps.code FROM `mapOfTheDay`, `maps` WHERE `mapType` = $type AND DATEDIFF(CURDATE(), mapOfTheDay.mapDate) < $expire AND mapID = maps.ID "; $result = mysql_query($sql); //No map for today? if (mysql_num_rows($result) == 0) { // If you want to modify the maps created! This is the line //GenerateMap($rows, $cols, $rockchance, $numBlocks = -1, $cp = -1, $tp = -1) { switch ($type) { case 1: //Easy $map = GenerateMap(13, 7, 12, rand(7,10), rand(0, 1), 0); break; case 2: //Normal $map = GenerateMap(15, 9, 7, rand(11,13), rand(1,3) + rand(0,1), 0); break; case 3: //Hard $map = GenerateMap(19, 9, rand(7, 9), rand(14,16), rand(2,5), rand(1,2)); break; case 4: //Full random map $map = getRandomSpecialMap(); break; case 5: // TEST MAP... $ultraComplex[] = "soooooooooooooooooooooooooooor"; $ultraComplex[] = "ro??????????????????????????of"; $ultraComplex[] = "so??????????????????????????or"; $ultraComplex[] = "ro??????????????????????????of"; $ultraComplex[] = "so??????????????????????????or"; $ultraComplex[] = "ro??????????????????????????of"; $ultraComplex[] = "so??????????????????????????or"; $ultraComplex[] = "ro??????????????????????????of"; $ultraComplex[] = "so??????????????????????????or"; $ultraComplex[] = "ro??????????????????????????of"; $ultraComplex[] = "so??????????????????????????or"; $ultraComplex[] = "roooooooooooooooooooooooooooof"; $ultraComplex = insertPoint($ultraComplex, 'abcde'); $ultraComplex = insertPoint($ultraComplex, 'tumngh'); $ultraComplex = insertPoint($ultraComplex, 'ppppppppppp'); $myparams['checkpoints'] = 5; $myparams['teleports'] = 3; $myparams['rockchance'] = 9; $myparams['walls'] = 38; $myparams['name'] = 'Ultra Complex'; $map = GenerateShapedMap($ultraComplex, $myparams); break; default: $map = GenerateMap(rand(13, 18), rand(10, 14), rand(6, 9)); break; } //Double check... $sql is already set $result = mysql_query($sql); //Are you SURE there's no map? if (mysql_num_rows($result) != 0) return mapOfTheDay($type); $code = GenerateMapCode($map); $sql = "INSERT INTO `maps` (`code`) VALUES ('$code')"; $result = mysql_query($sql); if (!$result) die("Error on inserting map"); $mapID = mysql_insert_id(); $r['code'] = $code; $r['map'] = $map; $r['id'] = $mapID; $sql = "INSERT INTO `mapOfTheDay` (`mapID`, `mapType`, `mapDate`) VALUES ('$mapID', '$type', CURDATE()) "; $result = mysql_query($sql); if (!$result) die("Error on insert into mapOfTheDay"); // ---------- Track statistics for 'yesterdays' map. trackMOTDstats($type); return $r; } $r['code'] = mysql_result($result, 0, 'code'); $r['map'] = GenerateMapByCode($r['code']); $r['id'] = mysql_result($result, 0, 'ID'); return $r; } //Select from yesterday function getYesterdaysMap() { $sql = " select `ID`, `code` from `maps` WHERE ( DAY(dateCreated) = DAY(NOW()) - 1 AND MONTH(dateCreated) = MONTH(NOW()) AND YEAR(dateCreated) = YEAR(NOW()) ) "; $result = mysql_query($sql); //No map for today? if (mysql_num_rows($result) == 0) { return -1; } $r['code'] = mysql_result($result, 0, 'code'); $r['id'] = mysql_result($result, 0, 'ID'); return $r; } function getRandomSpecialMap() { //This can be used to add additional weight to certain maps that we like. $random = weight(0, 1, 2, 3, 4, 5, 6, 7, 8); $shape = array(); $params = array(); switch ($random) { //===================================== case 0: //Thirty $map = GenerateMap( 18, 14, 20 , //width, height, rocks weight(30) , //Walls weight(1) , //Checkpoints weight(1) , //Teleports 'Thirty' ); break; //===================================== case 1: //Simple $map = GenerateMap( 18, 9, 7 , //width, height, rocks weight(15,16,17) , //Walls weight(0) , //Checkpoints weight(0) , //Teleports 'Finite' ); break; //===================================== case 2: //ABC's $map = GenerateMap( 19, 11, 12 , //width, height, rocks weight(20,21,22,22,23) , //Walls weight(3) , //Checkpoints weight(0) , //Teleports "ABC's " ); break; //===================================== case 3: //Tele Madness $map = GenerateMap( 17, 12, 10 , //width, height, rocks weight(17,18) , //Walls weight(1) , //Checkpoints weight(5) , //Teleports 'Teleport Madness' ); break; //===================================== case 4: //Thursday //Rocky Maze $map = GenerateMap( 19, 15, 5 , //width, height, rocks weight(16,17,18) , //Walls weight(1,2,2,2,3,3) , //Checkpoints weight(0) , //Teleports 'Rocky Maze' ); break; //===================================== case 5: //Friday //Side to Side $map = GenerateMap( 26, 6, 12 , //width, height, rocks weight(17,18,19) , //Walls weight(2,2,2,3,3) , //Checkpoints weight(3,3,3,4) , //Teleports 'Side to Side' ); break; //===================================== case 6: //Ultimate's Random map: //Create shape $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; //Insert points $shape = insertPoint($shape, "sfabcr", $target = '?'); $shape = insertPoint($shape, weight("tu", "d", "tu", "", ""), $target = '?'); //Set params $params['rockchance'] = 10; $params['walls'] = weight(21, 20, 22, 20, 21); $params['name'] = 'Ultimate Random'; //Put it all together. $map = GenerateShapedMap($shape, $params); break; //===================================== //===================================== case 7: //Dual map $dualmapa[] = "s???????????????????f"; $dualmapa[] = "s???????????????????f"; $dualmapa[] = "s???????????????????f"; $dualmapa[] = "s???????????????????f"; $dualmapa[] = "s???????????????????f"; $dualmapa[] = "s???????????????????f"; $dualmapa[] = "oqqqqqqqqqqqqqqqqqqqo"; $dualmapb[] = "s???????????????????f"; $dualmapb[] = "s???????????????????f"; $dualmapb[] = "s???????????????????f"; $dualmapb[] = "s???????????????????f"; $dualmapb[] = "s???????????????????f"; $dualmapb[] = "s???????????????????f"; $dualmapa = insertPoint($dualmapa, 'abc'); $dualmapb = insertPoint($dualmapb, 'abc'); $dualmap = array_merge($dualmapa, $dualmapb); $dualmap = insertPoint($dualmap, 'tu'); $myparams['checkpoints'] = 3; $myparams['teleports'] = 1; $myparams['rockchance'] = 9; $myparams['walls'] = weight(20, 20, 21, 21, 22, 23); $myparams['name'] = 'Seeing Double'; $map = GenerateShapedMap($dualmap, $myparams); break; //===================================== //===================================== case 8: //Centralized $myshape[] = "ooooooooooooooooooo"; $myshape[] = "o?????????????????o"; $myshape[] = "o?????????????????o"; $myshape[] = "o?????????????????o"; $myshape[] = "o???????fos???????o"; $myshape[] = "o?????????????????o"; $myshape[] = "o?????????????????o"; $myshape[] = "o?????????????????o"; $myshape[] = "ooooooooooooooooooo"; $myshape = insertPoint($myshape, "abc", $target = '?'); $myshape = insertPoint($myshape, weight("tu", "d", "tud", ""), $target = '?'); $myparams['rockchance'] = 7; $myparams['walls'] = weight(17, 18, 19, 18, 17); $myparams['name'] = 'Centralized'; $map = GenerateShapedMap($myshape, $myparams); break; //===================================== } return $map; } ?> \ 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 .= "<td title='Start tile. Position: $j,$i' class='grid_td_start' id='$handle' >
<div id='child_$handle' class='grid_inner'></div></td>"; break;
+
+ case 'S': $maptable .= "<td title='Start tile. Position: $j,$i' class='grid_td_startB' id='$handle' >
+ <div id='child_$handle' class='grid_inner'></div></td>"; break;
case 'f': $maptable .= "<td title='Finish tile. Position: $j,$i' class='grid_td_finish' id='$handle' >
<div id='child_$handle' class='grid_inner'></div></td>"; 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';
+}
+
?>
<div id="difficulties">
@@ -116,6 +125,7 @@ if ($special == '') {
<a href="javascript:showStats(2)" id="dl-2">Normal</a>
<a href="javascript:showStats(3)" id="dl-3">Complex</a>
<a href="javascript:showStats(4)" id="dl-4"><? echo $special; ?></a>
+ <a href="javascript:showStats(5)" id="dl-5"><? echo $special2; ?></a>
</div>
<div style="clear: both"></div>
@@ -247,7 +257,7 @@ $timerem = strtotime("tomorrow") - strtotime("now");
<script>
function showStats(type) {
- for (var i = 1; i <= 4; i++) {
+ for (var i = 1; i <= 5; i++) {
var elem = document.getElementById("yms-" + i);
elem.className = elem.className.replace('shown-maps', 'hidden-maps');
elem = document.getElementById("dl-" + i);
@@ -268,6 +278,7 @@ function showStats(type) {
jmid[2] = '$jmid[2]';
jmid[3] = '$jmid[3]';
jmid[4] = '$jmid[4]';
+ jmid[5] = '$jmid[5]';
";
?>
scoresRequestPage(jmid[type], currentPage[jmid[type]]);