From 95d067a02b4a979f0ff3b23291d0b3b9718f615e Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Fri, 26 Apr 2013 21:26:13 -0700 Subject: Challenge Editor --- index.php | 8 +++ pages/challengeeditor.php | 165 ++++++++++++++++++++++++++++++++++++++++++++++ pages/challengelist.php | 8 +++ 3 files changed, 181 insertions(+) create mode 100644 pages/challengeeditor.php diff --git a/index.php b/index.php index 0e5bb2e..43a26d6 100644 --- a/index.php +++ b/index.php @@ -226,6 +226,14 @@ switch ($request) { require 'pages/mapeditor.php'; break; + case "challengeeditor": + if ($_SESSION['isAdmin'] == true) { + require 'pages/challengeeditor.php'; + } else { + require 'pages/home.php'; + } + break; + case "admin": if ($_SESSION['isAdmin'] == true) { require 'pages/admin.php'; diff --git a/pages/challengeeditor.php b/pages/challengeeditor.php new file mode 100644 index 0000000..33a9511 --- /dev/null +++ b/pages/challengeeditor.php @@ -0,0 +1,165 @@ + $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, + $restrictWallCount = 'null', $restrictWallPlacement = 'null', $restrictTeleportCount = 'null', + $restrictTeleportsUsed = 'null', $restrictStartPoint = 'null', $restrictEndPoint = 'null') { + + $sql = "INSERT INTO `challenges` ( + `mapID`, `inequality`, `goal`, `ordering`, `hint` + ) + VALUES ( + '$mapID', '$inequality', $goal, $ordering, '$hint' + )"; + + // `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']; + $challengeID = addNewChallenge($mapID, $inequality, $goal, $ordering, $hint); + $infoDisplayText = "Challenge Added!: $challengeID"; +} + + +htmlHeader(array('stats'), 'Challenge Editor', + 'Challenge Editor', + array('dateformat')); + +?> + + + + + + + +
+

Challenge Edit -doesn't work.

+
Info:
+
+
+ Add Challenge Map +
+ Code: +
Name: +
Tier: +
Suborder: + +
+
+
+
+
+ Add Challenge To Map +
+ Challenge Map ID: +
Goal: +
"inequality"
E.G. greater than, less than, equal: +
hint +
Order: +
+
+
+
+
+ + \ No newline at end of file diff --git a/pages/challengelist.php b/pages/challengelist.php index df04bdd..d460ef5 100644 --- a/pages/challengelist.php +++ b/pages/challengelist.php @@ -16,6 +16,12 @@ topbar($Links); ?>