summaryrefslogtreecommitdiffstats
path: root/pages/mapeditor.php
diff options
context:
space:
mode:
Diffstat (limited to 'pages/mapeditor.php')
-rw-r--r--pages/mapeditor.php39
1 files changed, 30 insertions, 9 deletions
diff --git a/pages/mapeditor.php b/pages/mapeditor.php
index b6f4b57..ec02bb6 100644
--- a/pages/mapeditor.php
+++ b/pages/mapeditor.php
@@ -1,10 +1,13 @@
<?php
include_once('./includes/maps.php');
include_once('./includes/mapclass.php');
+include_once('./includes/mapoftheday.php');
//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 +20,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
@@ -221,6 +240,7 @@ function loadPlayableMap() {
playableMap.ID = -1;
$('#playableMapDisplay').html(mapAsHTML(playableMap, 960));
$('#playableMapCodeDisplay').val(playableMap.code);
+ $('#playableMapCodeDisplayOLD').val(playableMap.oldCode);
isLoadingMap = false;
}
});
@@ -322,7 +342,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 +411,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.