summaryrefslogtreecommitdiffstats
path: root/includes/maps.php
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 /includes/maps.php
parent1da7929920f4939336931fe0bf5df59342f649fd (diff)
downloadpathery-6d7ea09fc40b66904a8ac06b50a22a1861e26ff9.tar.xz
Changed to a map-pool.
Diffstat (limited to 'includes/maps.php')
-rw-r--r--includes/maps.php24
1 files changed, 17 insertions, 7 deletions
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...
/*