diff options
Diffstat (limited to 'do.php')
-rw-r--r-- | do.php | 44 |
1 files changed, 29 insertions, 15 deletions
@@ -129,23 +129,32 @@ if ($_GET['r'] == 'getpath') { $mapID = $_GET[mapid] + 0;
if (!is_int($mapID)) return;
//$firephp->log($mapID, "mapID");
+
+ //Is a challenge?
+ $challenge = ($_GET['isChallenge'] == 'true');
+
+
- //TODO: Get rid of this hackyness:
- //the first 10 ID's reserved for challenges & tutorial.
- if ($mapID > 10)
+ if ($challenge) {
+ $mapcode = getChallengeMapCode($mapID);
+ } else {
$mapcode = getMapCode($mapID);
- else
- $mapcode = $_GET['mapcode'];
-
+ }
+ //Hack - trust any map with an ID below 10.
+ if ($mapID < 10) $mapcode = $_GET['mapcode'];
+
//mygrid will be the map, with the solution applied.
$map = GenerateMapByCode($mapcode);
$mygrid = MergeMapSolution($map, $solution);
//Check both starting point groups for paths
$json = routeMultiPath($mygrid);
-
$moves = $json['totalMoves'];
+
+ //Return some basic info:
$json['mapid'] = $mapID;
+ $json['isAChallenge'] = $challenge;
+ $json['mapcodeExecuted'] = $mapcode;
//What could go wrong?
if ($json['blocked']) {
@@ -165,12 +174,16 @@ if ($_GET['r'] == 'getpath') { die($encoded);
}
- if ($_GET['isChallenge'] == 'true' AND isChallengeMap($mapID)) {
- // $firephp->log('Calling challenges');
- $json['info'][] = 'Executed as a challenge';
- $json['completedChallenges'] = getCompletedChallenges($userID, $mapID, $solution, $moves, $json['path']);
- // $firephp->log('Challenges called!');
- die(json_encode($json));
+
+ if ($_GET['isChallenge'] == 'true') {
+ if (isChallengeMap($mapID)) {
+ // $firephp->log('Calling challenges');
+ $json['info'][] = 'Executed as a challenge';
+ $json['completedChallenges'] = getCompletedChallenges($userID, $mapID, $solution, $moves, $json['path']);
+ // $firephp->log('Challenges called!');
+ die(json_encode($json));
+ }
+ exit;
}
//Get current score data. - to see if a pertinent score was beat.
@@ -235,9 +248,10 @@ if ($_GET['r'] == 'getpath') { // return;
//} //x
+ //TODO: Delete the below?
//TODO: I changed this; note these changes before re-applying the above.
//Challenge/Tutorial?
- if ($mapID <= 10 AND $_GET['isChallenge'] = 'true') {
+/* if ($mapID <= 10 AND $_GET['isChallenge'] = 'true') {
$json['error'][] = 'executed as a challenge';
//This will allow me to give insentive to logging in.
@@ -257,7 +271,7 @@ if ($_GET['r'] == 'getpath') { getCompletedChallenges($userID, $mapID, $solution, $moves, $paths);
//die(json_encode($json));
}
-
+ */
// --------- USER NOT LOGGED IN?
if ($_SESSION['accepted'] !== 1) {
|