summaryrefslogtreecommitdiffstats
path: root/pages
diff options
context:
space:
mode:
authorPatrick Davison <snapwilliam@gmail.com>2013-04-26 21:26:13 -0700
committerPatrick Davison <snapwilliam@gmail.com>2013-04-26 21:26:13 -0700
commit95d067a02b4a979f0ff3b23291d0b3b9718f615e (patch)
tree36d41ccfdcce57b0fbffd22df906d3a9fbcde6b3 /pages
parentd70cbf638a0ba6f610c793678083e563bc3b62ae (diff)
downloadpathery-95d067a02b4a979f0ff3b23291d0b3b9718f615e.tar.xz
Challenge Editor
Diffstat (limited to 'pages')
-rw-r--r--pages/challengeeditor.php165
-rw-r--r--pages/challengelist.php8
2 files changed, 173 insertions, 0 deletions
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 @@
+<?php
+include_once('./includes/maps.php');
+include_once('./includes/mapclass.php');
+
+
+
+if (!$_SESSION['isAdmin']) die('Admin Only');
+
+
+//Self-ajax.
+if ($_REQUEST['mapByCode']) {
+ $map = new map($_REQUEST['mapByCode']);
+ echo json_encode($map);
+ exit;
+}
+
+if ($_REQUEST['mapByMap']) {
+ $jsonMap = json_decode($_REQUEST['mapByMap']);
+
+ $map = new map();
+ foreach ($jsonMap as $key => $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'));
+
+?>
+
+<body>
+<?php
+echo soundManager2();
+topbar($Links);
+
+?>
+<script>
+
+
+</script>
+
+<style>
+
+#infoDisplay {
+ background-color:gray;
+ color:orange;
+ text-align:center;
+ min-width:30px;
+ height:22px;
+}
+
+</style>
+
+<div class='wrapper'>
+ <h2>Challenge Edit -doesn't work.</h2>
+ <div id='infoDisplay'>Info: <? echo $infoDisplayText; ?></div>
+ <form action="challengeeditor" method="post" id='addMap'>
+ <fieldset>
+ <legend>Add Challenge Map</legend>
+ <div class='plusMinus' style='width:600px;'>
+ Code:<input name='mapCode' size="30" type="text" value="" class="forminput"/>
+ <br />Name:<input name='name' size="30" type="text" value="" class="forminput"/>
+ <br />Tier:<input name='tier' size="5" type="text" value="" class="forminput"/>
+ <br />Suborder:<input name='subOrder' size="5" type="text" value="" class="forminput"/>
+ <input type="submit" value="Add Map" class="forminput" />
+ </div>
+ </fieldset>
+ </form>
+ <form action="challengeeditor" method="post" id='addChallenge'>
+ <fieldset>
+ <legend>Add Challenge To Map</legend>
+ <div class='plusMinus' style='width:600px;'>
+ Challenge Map ID:<input name='challengeMapID' size="5" type="number" value="" class="forminput"/>
+ <br />Goal:<input name='goal' size="5" type="number" value="" class="forminput"/>
+ <br /><b>"inequality" </b><br />E.G. greater than, less than, equal: <input name='inequality' size="15" type="text" value="" class="forminput"/>
+ <br />hint <input name='hint' size="15" type="hint" value="" class="forminput"/>
+ <br />Order:<input name='ordering' size="5" type="text" value="" class="forminput"/>
+ <br /><input type="submit" value="Add Challenge" class="forminput"/>
+ </div>
+ </fieldset>
+ </form>
+</div>
+
+<?php
+htmlFooter();
+?> \ 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);
?>
<script>
+
+//Legacy functions
+function challengeLoad() {}
+function challengeWall() {}
+function challengeGo() {}
+
// -display sections labeled..
// -*click
// -display levels
@@ -24,6 +30,8 @@ topbar($Links);
// -*finish map:
// -highlight 'Next'
+//Temporary hack..
+isChallenge = true;
function navShowChallengeTiers() {