1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
<?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, $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'));
?>
<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 />dialogStart <input name='dialogStart' size="20" type="hint" value="" class="forminput"/>
<br />dialogFail <input name='dialogFail' size="20" type="hint" value="" class="forminput"/>
<br />dialogSuccess <input name='dialogSuccess' size="20" 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();
?>
|