$value) { $map->$key = $value; } //Store the code in the object $code = $map->getOldCode(); $map->code = $code; 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'); $code = GenerateMapCode($map); $map = new map($code); echo json_encode($map); exit; } //Add's a new custom challenge map - returns mapid function addNewChallengeMap($mapCode, $tier, $subOrder, $name) { $sql = "INSERT INTO `challengeMaps` (`code`, `ChallengeTier`, `ChallengeSuborder`, `Name`) VALUES ('$mapCode', $tier, $subOrder, '$name')"; echo $sql; mysql_query($sql); $mapID = mysql_insert_id(); return $mapID; } //Returns challenge ID function addNewChallenge($mapID, $inequality, $goal, $ordering, $hint, $dialogStart, $dialogFail, $dialogSuccess, $restrictWallCount = 'null', $restrictWallPlacement = 'null', $restrictTeleportCount = 'null', $restrictTeleportsUsed = 'null', $restrictStartPoint = 'null', $restrictEndPoint = 'null') { $sql = "INSERT INTO `challenges` ( `mapID`, `inequality`, `goal`, `ordering`, `hint`, `dialogStart`, `dialogFail`, `dialogSuccess` ) VALUES ( '$mapID', '$inequality', $goal, $ordering, '$hint', '$dialogStart', '$dialogFail', '$dialogSuccess' )"; // `restrictWallCount`, `restrictWallPlacement`, `restrictTeleportCount`, //`restrictTeleportsUsed`, `restrictStartPoint`, `restrictEndPoint` echo $sql; mysql_query($sql); $challengeID = mysql_insert_id(); return $challengeID; } // Start Page: if (isset($_POST['mapCode'])) { //Validate data $mapCode = $_POST['mapCode']; $tier = $_POST['tier']; $subOrder = $_POST['subOrder']; $name = $_POST['name']; $mapID = addNewChallengeMap($mapCode, $tier, $subOrder, $name); $infoDisplayText = "Map Added with mapID: $mapID"; } if (isset($_POST['challengeMapID'])) { //Validate data $mapID = $_POST['challengeMapID']; $inequality = $_POST['inequality']; $goal = $_POST['goal']; $ordering = $_POST['ordering']; $hint = $_POST['hint']; $dialogStart = $_POST['dialogStart']; $dialogFail = $_POST['dialogFail']; $dialogSuccess = $_POST['dialogSuccess']; $challengeID = addNewChallenge( $mapID, $inequality, $goal, $ordering, $hint, $dialogStart, $dialogFail, $dialogSuccess ); $infoDisplayText = "Challenge Added!: $challengeID"; } htmlHeader(array('stats'), 'Challenge Editor', 'Challenge Editor', array('dateformat')); ?>