summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Davison <snapwilliam@gmail.com>2012-04-17 16:16:45 -0700
committerPatrick Davison <snapwilliam@gmail.com>2012-04-17 16:16:45 -0700
commit6d7ea09fc40b66904a8ac06b50a22a1861e26ff9 (patch)
tree9e49e6cbbaf21af918dd6d05805ba14b430c8b5d
parent1da7929920f4939336931fe0bf5df59342f649fd (diff)
downloadpathery-6d7ea09fc40b66904a8ac06b50a22a1861e26ff9.tar.xz
Changed to a map-pool.
-rw-r--r--images/OverlayStart50b.pngbin879 -> 2767 bytes
-rw-r--r--includes/mapoftheday.php2
-rw-r--r--includes/maps.php24
-rw-r--r--pages/home.php83
4 files changed, 68 insertions, 41 deletions
diff --git a/images/OverlayStart50b.png b/images/OverlayStart50b.png
index 4168da4..a42210a 100644
--- a/images/OverlayStart50b.png
+++ b/images/OverlayStart50b.png
Binary files differ
diff --git a/includes/mapoftheday.php b/includes/mapoftheday.php
index ee6a29e..6e0d14d 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 //Get the current day as int. $numday = date('w'); $numday = intval($numday); switch ($numday) { case 0: //Sunday //Thirty $map = GenerateMap( 18, 14, 20 , //width, height, rocks weight(30) , //Walls weight(1) , //Checkpoints weight(1) //Teleports ); break; case 1: //Monday //Simple $map = GenerateMap( 18, 9, 7 , //width, height, rocks weight(15,16,17) , //Walls weight(0) , //Checkpoints weight(0) //Teleports ); break; case 2: //Tuesday //ABC's $map = GenerateMap( 19, 11, 12 , //width, height, rocks weight(20,21,22,22,23) , //Walls weight(3) , //Checkpoints weight(0) //Teleports ); break; case 3: //Wednesday //Tele Madness $map = GenerateMap( 17, 12, 10 , //width, height, rocks weight(17,18) , //Walls weight(1) , //Checkpoints weight(5) //Teleports ); 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 ); 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 ); break; case 6: //Saturday //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); $map = GenerateShapedMap($dualmap, $myparams); break; } 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; } ?> \ No newline at end of file
+<?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
diff --git a/includes/maps.php b/includes/maps.php
index 37eae5f..4978411 100644
--- a/includes/maps.php
+++ b/includes/maps.php
@@ -93,6 +93,7 @@ function DisplayMap($mapMatrix, $idprefix = 1, $style = 'normal', $speed = NULL)
$mapdata['rocks'] = $mapMatrix[0][3];
$mapdata['walls'] = $mapMatrix[0][4];
$mapdata['teleports'] = $mapMatrix[0][5];
+ $mapdata['name'] = $mapMatrix[0][6];
$mapdata['example'] = $example;
$mapdata['mapid'] = $idprefix;
@@ -282,7 +283,7 @@ function DisplayMap($mapMatrix, $idprefix = 1, $style = 'normal', $speed = NULL)
}
//Generates map
-function GenerateMap($rows, $cols, $rockchance, $numBlocks = -1, $cp = -1, $tp = -1) {
+function GenerateMap($rows, $cols, $rockchance, $numBlocks = -1, $cp = -1, $tp = -1, $mapName = '') {
if ($numBlocks == -1)
$numBlocks = Rand(7, (int)($rows * $cols) * .12);
@@ -373,7 +374,8 @@ function GenerateMap($rows, $cols, $rockchance, $numBlocks = -1, $cp = -1, $tp =
$grid[0][3] = $rocks;
$grid[0][4] = $numBlocks;
$grid[0][5] = count($teleport);
-
+ $grid[0][6] = $mapName;
+
//Validate map
$path = routePath($grid, '', true);
//Only repeat if it's blocked.
@@ -413,6 +415,11 @@ function GenerateShapedMap($shape, $params) {
else
$teleports = 0;
+ if ($params['name'])
+ $mapName = $params['name'];
+ else
+ $mapName = '';
+
if (is_int($params['walls']))
$walls = $params['walls'];
else
@@ -426,6 +433,7 @@ function GenerateShapedMap($shape, $params) {
//walls
$mapMatrix[0][4] = $walls;
$mapMatrix[0][5] = $teleports;
+ $mapMatrix[0][6] = $mapName;
do {
@@ -569,11 +577,12 @@ function GenerateMapCode($mapMatrix) {
// $mapMatrix[1] count will always be the width.
$mapsize = $mapMatrix[0][0].'x'.$mapMatrix[0][1]; //Width x Height
- $code = $mapsize.
- '.c'.$mapMatrix[0][2].
- '.r'.$mapMatrix[0][3].
- '.w'.$mapMatrix[0][4].
- '.t'.$mapMatrix[0][5];
+ $code = $mapsize;
+ $code .= '.c'.$mapMatrix[0][2];
+ $code .= '.r'.$mapMatrix[0][3];
+ $code .= '.w'.$mapMatrix[0][4];
+ $code .= '.t'.$mapMatrix[0][5];
+ $code .= '.'.$mapMatrix[0][6];
// dimensions + # checkpoints + # rocks + # placeable walls
//echo $code."<br />";
@@ -624,6 +633,7 @@ function GenerateMapByCode($code) {
$mapMatrix[0][3] = (int)substr($headers[2], 1); //Number of Rocks
$mapMatrix[0][4] = (int)substr($headers[3], 1); //Number of Wall Blocks
$mapMatrix[0][5] = (int)substr($headers[4], 1); //Number of Teleports
+ $mapMatrix[0][6] = $headers[5]; //Map Name
//Printing out parameters for debug purposes...
/*
diff --git a/pages/home.php b/pages/home.php
index ff47634..fb1d434 100644
--- a/pages/home.php
+++ b/pages/home.php
@@ -110,13 +110,32 @@ topbar($Links);
echo "<table><tr><td style='background-color:#4444ff;' class='grid_td_rocks'></td></tr></table></center><br />";
}
}
- ?>
+}
+
+$motd = MapOfTheDay(1);
+$mapContent .= displayMaze($motd, 1);
+
+$motd = MapOfTheDay(2);
+$mapContent .= displayMaze($motd, 2);
+
+$motd = MapOfTheDay(3);
+$mapContent .= displayMaze($motd, 3);
+
+$motd = MapOfTheDay(4);
+$mapContent .= displayMaze($motd, 4);
+
+$special = $motd['map'][0][6];
+if ($special == '') {
+ $special = 'Special';
+}
+
+?>
<div id="difficulties">
<a href="javascript:showStats(1)" id="dl-1">Simple</a>
<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 $mapstyle; ?></a>
+ <a href="javascript:showStats(4)" id="dl-4"><? echo $special; ?></a>
</div>
<div style="clear: both"></div>
@@ -124,15 +143,17 @@ topbar($Links);
<br />This game is best viewed in <a href='http://www.google.com/chrome'>Google Chrome</a>
</noscript>
+ <? echo $mapContent; ?>
<?
-function displayMaze($mapType, $name) {
+
+function displayMaze($motd, $mapType) {
//Gather data for map;
- $motd = MapOfTheDay($mapType);
$mapID = $motd['id'];
$map = $motd['map'];
$width = $map[0][0];
+
//data for the topscores
$topscores = topScores($motd['id'], 30);
$topscorediv = "<div id='$mapID,dspScore'>\n$topscores\n</div>";
@@ -148,46 +169,42 @@ function displayMaze($mapType, $name) {
$mysolution = $_SESSION[$mapID.'sol'];
$mymoves = $_SESSION[$mapID.'moves'];
}
-
-
- echo "<div id=\"yms-$mapType\" class='hidden-maps'>";
- echo " <div class='wrapper'>";
+
+ $r .= "<div id=\"yms-$mapType\" class='hidden-maps'>";
+ $r .= " <div class='wrapper'>";
// if ($width <= 16) {
- // echo ' <div class="col1">';
- // echo $topscorediv;
- // echo ' </div>';
+ // $r .= ' <div class="col1">';
+ // $r .= $topscorediv;
+ // $r .= ' </div>';
- // echo ' <div class="col2">';
- // echo "<a href='javascript:requestSol(\"$mapID\");'>Load your best solution</a><br />";
- // echo DisplayMap($map, $mapID);
- // echo ' </div>';
- echo " <div style='text-align: center;'>";
- echo " <div style='display:inline-block;margin: 0 auto;text-align: left;'>";
- echo " <a href='javascript:requestSol(\"$mapID\");'><strong>Load your best solution</strong></a><br />";
- echo DisplayMap($map, $mapID);
- echo " </div></div>";
-
- echo " <div style='padding-top: 20px;'>";
- echo $topscorediv;
- echo ' </div>';
-
- echo ' </div>';
- echo '</div>';
+ // $r .= ' <div class="col2">';
+ // $r .= "<a href='javascript:requestSol(\"$mapID\");'>Load your best solution</a><br />";
+ // $r .= DisplayMap($map, $mapID);
+ // $r .= ' </div>';
+ $r .= " <div style='text-align: center;'>";
+ $r .= " <div style='display:inline-block;margin: 0 auto;text-align: left;'>";
+ $r .= " <a href='javascript:requestSol(\"$mapID\");'><strong>Load your best solution</strong></a><br />";
+ $r .= DisplayMap($map, $mapID);
+ $r .= " </div></div>";
+
+ $r .= " <div style='padding-top: 20px;'>";
+ $r .= $topscorediv;
+ $r .= ' </div>';
+
+ $r .= ' </div>';
+ $r .= '</div>';
$mapSolDiv = "<script>
loadSol(\"$mapID:$mysolution\", \"$mymoves\");
</script>";
- echo $mapSolDiv;
+ $r .= $mapSolDiv;
//Clear our floatingness
- echo '<div style="clear: both"></div>';
+ $r .= '<div style="clear: both"></div>';
+ return $r;
}
-displayMaze(1, 'Simple');
-displayMaze(2, 'Normal');
-displayMaze(3, 'Complex');
-displayMaze(4, 'Special');
$timerem = strtotime("tomorrow") - strtotime("now");
?>