diff options
Diffstat (limited to 'pages/mapeditor.php')
-rw-r--r-- | pages/mapeditor.php | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/pages/mapeditor.php b/pages/mapeditor.php index 9e1e57c..f67cad1 100644 --- a/pages/mapeditor.php +++ b/pages/mapeditor.php @@ -1,10 +1,17 @@ <?php include_once('./includes/maps.php'); include_once('./includes/mapclass.php'); +include_once('./includes/mapoftheday.php'); + +echo "too broken; will fix soon"; + +exit; //Self-ajax. if ($_REQUEST['mapByCode']) { $map = new map($_REQUEST['mapByCode']); + $map->oldCode = $map->getOldCode(); + $map->code = $map->getCode(); echo json_encode($map); exit; } @@ -17,24 +24,40 @@ if ($_REQUEST['mapByMap']) { $map->$key = $value; } //Store the code in the object - $code = $map->getOldCode(); - $map->code = $code; + $map->oldCode = $map->getOldCode(); + $map->code = $map->getCode(); echo json_encode($map); exit; } if ($_REQUEST['genMap']) { -//function GenerateMap($rows, $cols, $rockchance, $numBlocks = -1, $cp = -1, $tp = -1, $mapName = '') { - $map = GenerateMap($_REQUEST['width'], $_REQUEST['height'], $_REQUEST['rockChance'], $_REQUEST['wallCount'], $_REQUEST['checkpoints'] % 6, $_REQUEST['teleports'] % 6); - //$map = GenerateMap($_REQUEST['height'], $_REQUEST['width'], $_REQUEST['rockChance'], 0, 0, 0); - //$map = insertPoint($map, $_REQUEST['points'], 'o'); +/* + $map = GenerateMap( + normalizeNumber($_REQUEST['width'], 50, 6), + normalizeNumber($_REQUEST['height'], 50, 6), + normalizeNumber($_REQUEST['rockChance'], 999, 5), + normalizeNumber($_REQUEST['wallCount'], 9999, 0), + normalizeNumber($_REQUEST['checkpoints'], 5, 0), + normalizeNumber($_REQUEST['teleports'], 5, 0) + ); + */ + $map = getRandomSpecialMap(); + $code = GenerateMapCode($map); + $map = new map($code); + $map->oldCode = $map->getOldCode(); + $map->code = $map->getCode(); echo json_encode($map); exit; } - +function normalizeNumber($numberToFix, $upperBound, $lowerBound) { + if (!is_int($numberToFix + 0)) return $lowerBound; + if ($numberToFix < $lowerBound) return $lowerBound; + if ($numberToFix > $upperBound) return $upperBound; + return $numberToFix; +} //Add's a new custom challenge map - returns mapid @@ -180,8 +203,8 @@ function updateName() { } function changeDimensions(width, height) { - width = Math.Min(width, 50); - height = Math.Min(height, 50); + width = Math.min(width, 50); + height = Math.min(height, 50); testMap.tiles = constructTiles(width, height, testMap); //testMap.tiles[0][3] = Array('s'); @@ -221,6 +244,7 @@ function loadPlayableMap() { playableMap.ID = -1; $('#playableMapDisplay').html(mapAsHTML(playableMap, 960)); $('#playableMapCodeDisplay').val(playableMap.code); + $('#playableMapCodeDisplayOLD').val(playableMap.oldCode); isLoadingMap = false; } }); @@ -322,7 +346,7 @@ function constructTiles(width, height, baseMap) { </form> </div> - <form><div> + <form onsubmit='return false'><div> <div class='' id='' style='float:left; width:340px;height:450px;'> <fieldset style='width:300px'> @@ -391,7 +415,8 @@ function constructTiles(width, height, baseMap) { <div class="divide"><strong>Playable Map</strong></div> <div style='clear:both;'></div> <div class='wrapper'> - MapCode: <input id='playableMapCodeDisplay' size="100" type="text" value="" class="forminput"/> + OLD MapCode: <input id='playableMapCodeDisplayOLD' size="100" type="text" value="" class="forminput"/> + <br/>NEW MapCode: <input id='playableMapCodeDisplay' size="100" type="text" value="" class="forminput"/> </div> <div id='playableMapDisplay' style='float:left;'> Returned map goes here. |