summaryrefslogtreecommitdiffstats
path: root/includes/maps.php
diff options
context:
space:
mode:
authorPatrick Davison <snapwilliam@gmail.com>2012-08-18 17:45:59 -0700
committerPatrick Davison <snapwilliam@gmail.com>2012-08-18 17:45:59 -0700
commit0759852ab7a9af16e5f4c444ef5d1e0db6feabd3 (patch)
tree3d14988dee9ff20584ab5227cbdb81df3389b6e2 /includes/maps.php
parent6206e6f71133e1266275c7309134bb7f876ea85e (diff)
downloadpathery-0759852ab7a9af16e5f4c444ef5d1e0db6feabd3.tar.xz
The start on Multi-day maps and Dual Path mechanic
Halfway started both.
Diffstat (limited to 'includes/maps.php')
-rw-r--r--includes/maps.php37
1 files changed, 34 insertions, 3 deletions
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