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. --- includes/maps.php | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'includes/maps.php') 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 -- cgit v1.2.3