summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Davison <snapwilliam@gmail.com>2013-01-08 01:53:05 -0800
committerPatrick Davison <snapwilliam@gmail.com>2013-01-08 01:53:05 -0800
commit6b8c58ac2d4de502421acef48f4434bee605633f (patch)
treeb6ed4553388d0058952a987734a317ecfaea13f9
parenta431308aa3c6c698d23b45bf5e1f905123e0cba5 (diff)
downloadpathery-6b8c58ac2d4de502421acef48f4434bee605633f.tar.xz
Challenges Implementation. LOTS of stuff
Fixed an issue with loading best solution from logged out to logged in state. Commented out a lot of firephp stuff; feel free to uncomment.
-rw-r--r--css/challenge.css15
-rw-r--r--css/stats.css19
-rw-r--r--do.php85
-rw-r--r--includes/datas.php244
-rw-r--r--includes/mapoftheday.php2
-rw-r--r--includes/maps.php13
-rw-r--r--index.php12
-rw-r--r--js/mapspecs.js46
-rw-r--r--js/scores.js224
-rw-r--r--pages/challenge.php17
-rw-r--r--pages/challengelist.php7
-rw-r--r--pages/faq.php4
-rw-r--r--pages/gallery.php178
-rw-r--r--pages/home.php21
-rw-r--r--pages/tutorial.php1
15 files changed, 769 insertions, 119 deletions
diff --git a/css/challenge.css b/css/challenge.css
index 12ba61a..399570b 100644
--- a/css/challenge.css
+++ b/css/challenge.css
@@ -5,11 +5,20 @@
font-weight: bold;
}
#challenge_wrapper #challenges_listing { }
-#challenge_wrapper #challenges_listing .challenge_complete {
- text-decoration: line-through;
+.challenge_complete {
+ color:green;
+ font-weight: normal;
}
-#challenge_wrapper #challenges_listing .challenge_incomplete {
+.challenge_incomplete {
font-weight: bold;
+ color:red;
+}
+
+.challenge_complete a {
+ display:inline;
+}
+.challenge_incomplete a {
+ display: none;
}
/** Challenge listing page **/
diff --git a/css/stats.css b/css/stats.css
index 8d3b361..ab4cb96 100644
--- a/css/stats.css
+++ b/css/stats.css
@@ -87,10 +87,15 @@ td, th {
margin-right:auto;
position:relative;
}
+
+
.scoreMedal {
- text-align:right;
- vertical-align:bottom;
- background-repeat:no-repeat;
+ text-align:left;
+}
+.scoreMedal img {
+ width:32px;
+ height:32px;
+ vertical-align:middle;
}
.scoreGold {
background-image: url(../images/MedalGoldCAb.png);
@@ -98,4 +103,12 @@ td, th {
.scoreSilver {
background-image: url(../images/MedalSilverCAb.png);
}
+.scoreName {
+ float:left;
+ padding: 5px 0px 3px 3px;
+ width:120px;
+ overflow:hidden;
+ text-overflow: ellipsis;
+ white-space:nowrap;
+}
diff --git a/do.php b/do.php
index c82de22..bbaa665 100644
--- a/do.php
+++ b/do.php
@@ -56,6 +56,18 @@ if (isset($_GET['checkachieve']) && $_GET['checkachieve'] == 'true' && $_SESSION
$json['notificationtext'] = $note;
}
+if ($_GET['r'] == 'reqMemberPage') {
+
+ $order = 'ORDER BY dateJoined DESC';
+ $page = $_GET['reqPage'] + 0;
+ if (!is_int($page))
+ return;
+ $json = getMembers($order, $page, 4);
+ $json['page'] = $page;
+ $encoded = json_encode($json);
+ die($encoded);
+}
+
if ($_GET['r'] == 'reqScorePage') {
$mapID = $_GET['mapid'] + 0;
$page = $_GET['reqPage'] + 0;
@@ -107,14 +119,14 @@ if ($_GET['r'] == 'getsol') {
$userID = $_SESSION['userID'];
-///// TODO: FIX FIX FIX FIX FIX FIX //////
- if ($_SESSION['accepted'] == 1) {
- $json = getSolution($userID, $mapID);
- if ($tmp['moves'] > $_SESSION[$mapID.'sol']) {
- $json = $tmp;
- }
+ $json['solution'] = '';
+ $json['moves'] = 0;
+ if ($accepted) {
+ $sol = getSolution($userID, $mapID);
+ $json['solution'] = $sol['solution'];
+ $json['moves'] = $sol['moves'];
}
- if (isset($_SESSION[$mapID.'sol'])) {
+ if (isset($_SESSION[$mapID.'sol']) && $_SESSION[$mapID.'moves'] > $json['moves']) {
$json['solution'] = $_SESSION[$mapID.'sol'];
$json['moves'] = $_SESSION[$mapID.'moves'];
}
@@ -125,6 +137,22 @@ if ($_GET['r'] == 'getsol') {
die($encoded);
}
+if ($_GET['r'] == 'getChallengeSolution') {
+ $mapID = $_GET['mapID'] + 0;
+ $challengeID = $_GET['challengeID'] + 0;
+ //echo "working...";
+ if (!is_int($mapID) OR !is_int($challengeID)) return;
+ if (!$accepted) return;
+
+ $userID = $_SESSION['userID'];
+
+ $json = getChallengeSolution($userID, $challengeID);
+
+ $json['mapid'] = $mapID;
+ $encoded = json_encode($json);
+ die($encoded);
+}
+
// ------------ MAIN; getpath.
if ($_GET['r'] == 'getpath') {
@@ -137,7 +165,8 @@ if ($_GET['r'] == 'getpath') {
// Enables the ability to discover an exact duplicate solution.
$solution = formSolution($_GET['solution']);
-
+ $userID = $_SESSION['userID'];
+
//valid mapID?
$mapID = $_GET[mapid] + 0;
if (!is_int($mapID)) return;
@@ -176,9 +205,15 @@ if ($_GET['r'] == 'getpath') {
$encoded = json_encode($json);
die($encoded);
}
+
+ if ($_GET['isChallenge'] == 'true' AND isChallengeMap($mapID)) {
+ // $firephp->log('Calling challenges');
+ $json['completedChallenges'] = getCompletedChallenges($userID, $mapID, $solution, $moves, $json['path']);
+ // $firephp->log('Challenges called!');
+ die(json_encode($json));
+ }
//Get current score data. - to see if a pertinent score was beat.
- $userID = $_SESSION['userID'];
$sql = "SELECT `moves` as bestmoves, `displayName`, IFNULL(q1.mymoves, 0)
FROM `solutions`, `users`
LEFT JOIN (
@@ -203,8 +238,10 @@ if ($_GET['r'] == 'getpath') {
$json['best'] = 0;
$json['bestby'] = 'no one';
}
-
- // --------- RUSH THE PATH BACK TO THE USER
+
+ // --------- ------------------------------ ---------
+ // --------- RUSH THE PATH BACK TO THE USER ---------
+ // --------- ------------------------------ ---------
if (!$debug) {
ignore_user_abort(true);
$encoded = json_encode($json);
@@ -212,22 +249,21 @@ if ($_GET['r'] == 'getpath') {
header("Content-Length: " . mb_strlen($encoded));
echo $encoded;
flush();
+ //The connection is now closed, no further communication to the client can be done!
}
+ // --------- CONTINUE EXECUTION ---------
- $json['error'][] = "bestMoves, byName, myMoves: $bestMoves, $byName, $myMoves;";
-
- // --------- CONTINUE EXECUTION
+ // Now we don't have to worry about how long we're taking.
+ // All of this code will execute without the user waiting on the server.
+
+ //$json['error'][] = "bestMoves, byName, myMoves: $bestMoves, $byName, $myMoves;";
//TODO: Commented this out - temporarly.
// $firephp->log('Got this far');
// $firephp->log($_SESSION['accepted'], '$_SESSION["accepted"]');
////Challenge/Tutorial?
- // if ($_GET['isChallenge'] == 'true') {
- // $firephp->log('Calling challenges');
- // $json['completedChallenges'] = getCompletedChallenges($userID, $mapID, $solution, $moves, $json['path']);
- // $firephp->log('Challenges called!');
- // }
+
////--------- RUSH THE PATH BACK TO THE USER
// ignore_user_abort(true);
@@ -255,10 +291,9 @@ if ($_GET['r'] == 'getpath') {
$_SESSION['preCompletedTutorialNotified'] = false;
}
if ($accepted == false)
- return;
-
+ die(json_encode($json));
getCompletedChallenges($userID, $mapID, $solution, $moves, $paths);
- return;
+ die(json_encode($json));
}
@@ -332,12 +367,12 @@ if ($_GET['r'] == 'getpath') {
$json['error'][] = 'Rush-send failed';
-$encoded = json_encode($json);
-die($encoded);
+//$encoded = json_encode($json);
+die(json_encode($json));
function isCurrentMap($mapID) {
- // TODO: Broke
+ // TODO: change methodology
include_once('./includes/db.inc.php');
$sql = "SELECT maps.ID
FROM `mapOfTheDay`
diff --git a/includes/datas.php b/includes/datas.php
index fa04300..6cc8f07 100644
--- a/includes/datas.php
+++ b/includes/datas.php
@@ -313,25 +313,25 @@ function getCompletedChallenges($userID, $mapID, $solution, $moves, $paths) {
return;
}
- $firephp->log($mapID, "mapID");
- $firephp->log($userID, "userID");
+ //$firephp->log($mapID, "mapID");
+ //$firephp->log($userID, "userID");
$challengeResultset = loadChallengesForMap($mapID, $userID);
$challengesCompleted = array();
while($challenge = mysql_fetch_array($challengeResultset))
{
- $firephp->log("Checking a challenge");
- $firephp->log("Checking challenge number" . $challenge['challengeID']);
- $firephp->log($challenge["dateSolved"], "dateCompleted");
+ //$firephp->log("Checking a challenge");
+ //$firephp->log("Checking challenge number" . $challenge['challengeID']);
+ //$firephp->log($challenge["dateSolved"], "dateCompleted");
//Skip checking challenges which have already been completed
if($challenge["dateSolved"] !== NULL)
{
- $firephp->log('Challenge was already completed');
+ //$firephp->log('Challenge was already completed');
$challengesCompleted[] = $challenge["challengeID"];
}
else if(hasChallengeBeenCompleted($challenge, $solution, $moves, $paths))
{
- $firephp->log('Challenge was completed!');
+ //$firephp->log('Challenge was completed!');
setChallengeCompleted($challenge, $solution, $userID, $moves);
$challengesCompleted[] = $challenge["challengeID"];
}
@@ -368,7 +368,7 @@ function onCompletedTutorial($userID) {
* Checks if the given solution meets the requirements for the given challenge
*/
function hasChallengeBeenCompleted($challenge, $solution, $moves, $paths) {
- $firephp = FirePHP::getInstance(true);
+ //$firephp = FirePHP::getInstance(true);
//Check the maze-length
if($challenge['goal'] != 0) {
//Er, "greater than" should really be called "greater than or equal to" :\
@@ -376,7 +376,7 @@ function hasChallengeBeenCompleted($challenge, $solution, $moves, $paths) {
|| ($challenge['inequality'] == "less than" && $moves >= $challenge['goal'])
|| ($challenge['inequality'] == "equal" && $moves != $challenge['goal']))
{
- $firephp->log("Failed at distance");
+ //$firephp->log("Failed at distance");
return false;
}
}
@@ -388,7 +388,7 @@ function hasChallengeBeenCompleted($challenge, $solution, $moves, $paths) {
$temp = count_chars($solution, 1); //$temp needed due to extreme PHP-stupidity
$numWalls = $temp[ord(",")];
if($numWalls > $challenge['restrictWallCount']) {
- $firephp->log("Failed at wall-count");
+ //$firephp->log("Failed at wall-count");
return false;
}
}
@@ -402,8 +402,8 @@ function hasChallengeBeenCompleted($challenge, $solution, $moves, $paths) {
$stringToSearchFor = "." . swapXandYCoordinates($invalidWall) . ".";
if(strpos($solution,$stringToSearchFor) !== false)
{
- $firephp->log("Failed at wall-placement: " . $invalidWall);
- $firephp->log("Solution: " . $solution);
+ //$firephp->log("Failed at wall-placement: " . $invalidWall);
+ //$firephp->log("Solution: " . $solution);
return false;
}
}
@@ -419,7 +419,7 @@ function hasChallengeBeenCompleted($challenge, $solution, $moves, $paths) {
if(count($usedTeleports) !== $challenge['restrictTeleportCount'] &&
($challenge['restrictTeleportCount'] != 0 || $usedTeleports[0] != ""))
{
- $firephp->log("Failed at teleport count");
+ //$firephp->log("Failed at teleport count");
return false;
}
}
@@ -434,7 +434,7 @@ function hasChallengeBeenCompleted($challenge, $solution, $moves, $paths) {
//Check each path to see if it walks over that teleport
if(strpos($path['path'], $usedTeleport) !== false)
{
- $firephp->log("Failed at teleports used");
+ //$firephp->log("Failed at teleports used");
return false;
}
}
@@ -454,7 +454,7 @@ function hasChallengeBeenCompleted($challenge, $solution, $moves, $paths) {
if(!$usesCorrectStartPoint)
{
- $firephp->log("Failed at start-point");
+ //$firephp->log("Failed at start-point");
return false;
}
}
@@ -471,13 +471,13 @@ function hasChallengeBeenCompleted($challenge, $solution, $moves, $paths) {
if(!$usesCorrectEndPoint)
{
- $firephp->log("Failed at endpoint");
+ //$firephp->log("Failed at endpoint");
return false;
}
}
//All of the restrictions were met, meaning the challenge was completed!
- $firephp->log("Succeeded!");
+ //$firephp->log("Succeeded!");
return true;
}
@@ -504,6 +504,21 @@ function setChallengeCompleted($challenge, $solution, $userID, $moves) {
mysql_query($sql);
}
+
+function isChallengeMap($mapID) {
+ include_once('./includes/db.inc.php');
+ $sql = "SELECT ID
+ FROM `maps`
+ WHERE
+ ID = '$mapID' AND `isChallenge` = true;
+ ";
+ $result = mysql_query($sql) or die(mysql_error());
+ if (mysql_num_rows($result) == 0)
+ return false;
+ else
+ return true;
+}
+
function applyAchievements($userID, $aType) {
$amount = getAchievementCurrency($userID, $aType);
@@ -768,11 +783,163 @@ function trackMOTDstats($mapType) {
+//Select Members
+function getMembers($order, $pageNumber = 1, $pageDivide = 50) {
+
+ $top = $pageNumber * $pageDivide;
+ $bottom = $top - $pageDivide;
+
+ $limitTop = ($pageNumber - 1) * $pageDivide;
+
+ $sql = "SELECT COUNT(*) as 'count' FROM `users`";
+ $result = mysql_query($sql) or die(mysql_error());
+ $row = mysql_fetch_assoc($result);
+ $total = $row['count'];
+
+ $output['pageCount'] = $total / $pageDivide;
+
+ $pageRequest = 'all';
+ if ($pageRequest == 'all') {
+ $pageReqStart = 1;
+ $pageReqEnd = 1000;
+ } elseif (is_int($pageRequest)) {
+ $pageReqStart = $pageRequest;
+ $pageReqEnd = $pageRequest;
+ } else {
+ $tmp = explode($pageRequest, "-");
+ $pageReqStart = $tmp[0];
+ $pageReqEnd = $tmp[1];
+ }
+
+ $sql = "
+ SELECT
+ users.ID as ID,
+ users.displayName as display,
+ IfNull(
+ (SELECT SUM(moves) FROM solutions
+ WHERE solutions.userID = users.ID AND
+ solutions.dateModified < CURRENT_DATE)
+ , 0) AS totalMoves,
+ IfNull(
+ (SELECT SUM(moves) FROM solutions
+ WHERE solutions.userID = users.ID AND
+ solutions.dateModified BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY) AND CURRENT_DATE)
+ , 0) AS totalMovesThisWeek,
+ IfNull(
+ (SELECT COUNT(*) FROM solutions
+ WHERE solutions.userID = users.ID AND
+ solutions.dateModified < CURRENT_DATE)
+ , 0) AS totalMazes,
+ SUM(CASE WHEN statistics.type IN (32, 33, 34, 35) THEN statistics.value ELSE 0 END) as totalWins,
+ SUM(CASE WHEN statistics.type IN (1, 2, 3, 4) THEN statistics.value ELSE 0 END) as totalTies,
+ IfNull(userData.wallColor, '#666666') as wallColor,
+ IfNull(userData.displayColor, '#cccccc'),
+ userData.wallEmblem as wallEmblem,
+ users.datejoined as dateJoined,
+ users.dateLogin as dateLogin
+ FROM `users`
+ LEFT JOIN `userData` ON users.ID = userData.userID
+ LEFT JOIN `statistics` ON users.ID = statistics.userID
+ GROUP BY users.ID
+ $order
+ LIMIT $limitTop, $pageDivide
+ ";
+
+ $result = mysql_query($sql);
+ //$utime = date("g:i A (T)");
+
+ $output['updateTime'] = date("g:i A (T)");
+
+ $i = $limitTop;
+ $foundUser = false;
+ while ($row = mysql_fetch_assoc($result)) {
+ $i++;
+
+ $moves = $row['moves'];
+
+ $userID = $row['ID'];
+ if ($_SESSION['userID'] == $userID) {
+ $userPosition = $i;
+ }
+ // } else {
+ // if ($i > $top)
+ // continue;
+ // if ($i <= $bottom)
+ // continue;
+ // }
+
+ if ($wallEmblem == '')
+ $wallEmblem = 'blank.png';
+
+ $cdate = $row['cdate'];
+ $cdate = date("g:i A (T)", strtotime($cdate));
+
+ $row['dateJoined'] = Date("Y-m-d", strtotime($row['dateJoined']));
+ $row['dateLogin'] = Date("Y-m-d", strtotime($row['dateLogin']));
+
+ $scoredDate = strtotime($row['cdate']);
+ $secondsSinceScored = strtotime("now") - $scoredDate ;
+
+ //Alternate background colors
+ $background = '#262631';
+ if ($i % 2 == 1)
+ $background = '#20202a';
+
+ if ($userPosition == $i) {
+ $background = '#343c57';
+ $foundUser = true;
+ }
+
+ // if is blind map.
+ // $row['moves'] = '???';
+
+ $output['users'][$i] = $row;
+ $output['users'][$i]['scoredDate'] = $cdate;
+ $output['users'][$i]['secondsSinceScored'] = $secondsSinceScored;
+ $output['users'][$i]['background'] = $background;
+ $output['users'][$i]['medal'] = $medal;
+ $output['users'][$i]['isUser'] = $userPosition == $i;
+ //$output['users'][$i]['debug'] = "Bestmoves: $bestMoves moves: $moves";
+ } // END WHILE
+
+ //Need to look this up.
+ //$output['pageCount'] = ceil(($i / $pageDivide));
+ //$output['pageCount'] = 5;
+ if ($prevPage > 0) {
+ $navi .= " <a href='javascript:scoresShowPage($mapid, 1);'>&lt;&lt;</a> ";
+ $navi .= " <a href='javascript:scoresShowPage($mapid, $prevPage);'>&lt;</a> ";
+ } else {
+ $navi .= " &lt;&lt; ";
+ $navi .= " &lt;";
+ }
+ for ($x = 1; $x <= $pageCount; $x++) {
+ if ($x < $pageNumber - 3 OR $x > $pageNumber + 3)
+ continue;
+ if ($x == $pageNumber)
+ $navi .= "<strong> $x </strong>";
+ elseif ($userPage == $x)
+ $navi .= " <a href='javascript:scoresShowPage($mapid, $x)'><i>$x</i></a> ";
+ else
+ $navi .= " <a href='javascript:scoresShowPage($mapid, $x)'>$x</a> ";
+ }
+ if ($nextPage <= $pageCount) {
+ $navi .= " <a href='javascript:scoresShowPage($mapid, $nextPage);'>&gt;</a> ";
+ $navi .= " <a href='javascript:scoresShowPage($mapid, $pageCount);'>&gt;&gt;</a> ";
+ }
+
+ return $output;
+}
+
+
+
//Select Stats/Scores.
-function getScores($mapid, $pageNumber = 1, $pageDivide = 10) {
+function getScores($mapID, $pageNumber = 1, $pageDivide = 10) {
$top = $pageNumber * $pageDivide;
$bottom = $top - $pageDivide;
+ //TODO: !! set to false before uploading.
+ $isBlindMap = false;
+
$pageRequest = 'all';
if ($pageRequest == 'all') {
@@ -787,6 +954,17 @@ function getScores($mapid, $pageNumber = 1, $pageDivide = 10) {
$pageReqEnd = $tmp[1];
}
+ $userID = $_SESSION['userID'];
+ $myBestMoves = 0;
+ if ($isBlindMap) {
+ $sql = "SELECT `moves` FROM `solutions` WHERE `mapID` = '$mapID' AND `userID` = '$userID'";
+ $result = mysql_query($sql) or die(mysql_error());
+ $row = mysql_fetch_assoc($result);
+ $myBestMoves = $row['moves'];
+ // echo "XX $myBestMoves XX ";
+ // echo "XX $userID XX ";
+ }
+
$sql = "
SELECT
timediff(solutions.dateModified, TIMESTAMP(CURDATE())) as diff,
@@ -803,9 +981,10 @@ function getScores($mapid, $pageNumber = 1, $pageDivide = 10) {
ON users.ID = solutions.userID
LEFT JOIN `userData`
ON users.ID = userData.userID
- WHERE solutions.mapID = '$mapid'
+ WHERE solutions.mapID = '$mapID'
ORDER BY solutions.moves DESC, solutions.dateModified ASC, solutions.ID DESC
";
+ // ORDER BY solutions.moves ASC, solutions.dateModified DESC, solutions.ID ASC
$result = mysql_query($sql);
//$utime = date("g:i A (T)");
@@ -813,19 +992,22 @@ function getScores($mapid, $pageNumber = 1, $pageDivide = 10) {
$i = 0;
$foundUser = false;
+
while ($row = mysql_fetch_assoc($result)) {
$i++;
$moves = $row['moves'];
- $userID = $row['ID'];
+
+ $requestedUserID = $row['ID'];
if ($i == 1) {
$bestMoves = $moves;
$output['bestMoves'] = $bestMoves;
$output['bestBy'] = $row['display'];
}
- if ($_SESSION['userID'] == $userID) {
+ if ($_SESSION['userID'] == $requestedUserID) {
$userPosition = $i;
+ //$myBestMoves = $moves;
} else {
if ($i > $top)
continue;
@@ -857,6 +1039,10 @@ function getScores($mapid, $pageNumber = 1, $pageDivide = 10) {
$medal = 'silver';
if ($i == 1)
$medal = 'gold';
+
+ // if is blind map.
+ if ($isBlindMap AND $myBestMoves < $moves)
+ $row['moves'] = '???';
$output['users'][$i] = $row;
$output['users'][$i]['scoredDate'] = $cdate;
@@ -864,7 +1050,7 @@ function getScores($mapid, $pageNumber = 1, $pageDivide = 10) {
$output['users'][$i]['background'] = $background;
$output['users'][$i]['medal'] = $medal;
$output['users'][$i]['isUser'] = $userPosition == $i;
- $output['users'][$i]['debug'] = "Bestmoves: $bestMoves moves: $moves";
+ //$output['users'][$i]['debug'] = "Bestmoves: $bestMoves moves: $moves";
} // END WHILE
if ($foundUser) {
@@ -876,8 +1062,8 @@ function getScores($mapid, $pageNumber = 1, $pageDivide = 10) {
$output['pageCount'] = ceil(($i / $pageDivide));
if ($prevPage > 0) {
- $navi .= " <a href='javascript:scoresShowPage($mapid, 1);'>&lt;&lt;</a> ";
- $navi .= " <a href='javascript:scoresShowPage($mapid, $prevPage);'>&lt;</a> ";
+ $navi .= " <a href='javascript:scoresShowPage($mapID, 1);'>&lt;&lt;</a> ";
+ $navi .= " <a href='javascript:scoresShowPage($mapID, $prevPage);'>&lt;</a> ";
} else {
$navi .= " &lt;&lt; ";
$navi .= " &lt;";
@@ -888,13 +1074,13 @@ function getScores($mapid, $pageNumber = 1, $pageDivide = 10) {
if ($x == $pageNumber)
$navi .= "<strong> $x </strong>";
elseif ($userPage == $x)
- $navi .= " <a href='javascript:scoresShowPage($mapid, $x)'><i>$x</i></a> ";
+ $navi .= " <a href='javascript:scoresShowPage($mapID, $x)'><i>$x</i></a> ";
else
- $navi .= " <a href='javascript:scoresShowPage($mapid, $x)'>$x</a> ";
+ $navi .= " <a href='javascript:scoresShowPage($mapID, $x)'>$x</a> ";
}
if ($nextPage <= $pageCount) {
- $navi .= " <a href='javascript:scoresShowPage($mapid, $nextPage);'>&gt;</a> ";
- $navi .= " <a href='javascript:scoresShowPage($mapid, $pageCount);'>&gt;&gt;</a> ";
+ $navi .= " <a href='javascript:scoresShowPage($mapID, $nextPage);'>&gt;</a> ";
+ $navi .= " <a href='javascript:scoresShowPage($mapID, $pageCount);'>&gt;&gt;</a> ";
}
return $output;
@@ -949,7 +1135,7 @@ function loadChallengeListing($userIdUnsanitized)
{
$userID = mysql_escape_string($userIdUnsanitized);
$sql = "
- SELECT maps.ID AS mapID, maps.challengeTier, maps.challengeName, challengeSolutions.dateSolved
+ SELECT maps.ID AS mapID, maps.challengeTier, maps.name, challengeSolutions.dateSolved
FROM maps
INNER JOIN challenges ON maps.ID = challenges.mapID
LEFT JOIN challengeSolutions ON challenges.ID = challengeSolutions.challengeID
diff --git a/includes/mapoftheday.php b/includes/mapoftheday.php
index 5ae7ebd..d244635 100644
--- a/includes/mapoftheday.php
+++ b/includes/mapoftheday.php
@@ -1 +1 @@
-<?php include_once('maps.php'); include_once('db.inc.php'); /** * Returns the Map Of The Day with the given type (index) */ function mapOfTheDay($type = 1) { ignore_user_abort(true); if ($type <= 8) $expire = 2; if ($type <= 4) $expire = 1; $sql = " SELECT maps.ID, maps.code FROM `mapOfTheDay`, `maps` WHERE `mapType` = $type AND DATEDIFF(CURDATE(), mapOfTheDay.mapDate) < $expire AND mapID = maps.ID "; $result = mysql_query($sql); //No map for today? if (mysql_num_rows($result) != 0) { $r['code'] = mysql_result($result, 0, 'code'); $r['map'] = GenerateMapByCode($r['code']); $r['id'] = mysql_result($result, 0, 'ID'); return $r; } return generateNewMapOfTheDay($type, $sql); } /** * Generates a new map of the day. DO NOT CALL OUTSIDE OF mapoftheday.php */ function generateNewMapOfTheDay($type, $sql) { // If you want to modify the maps created! This is the line //GenerateMap($rows, $cols, $rockchance, $numBlocks = -1, $cp = -1, $tp = -1) { switch ($type) { case 1: //Easy $map = GenerateMap(13, 7, 12, rand(7, 10), rand(0, 1), 0); break; case 2: //Normal $map = GenerateMap(15, 9, 7, rand(11, 13), rand(1, 3) + rand(0, 1), 0); break; case 3: //Hard $map = getRandomComplexMap(); break; case 4: //Full random map $map = getRandomSpecialMap(); break; case 5: // TEST MAP... $ultraComplex[] = "soooooooooooooooooooooooooooor"; $ultraComplex[] = "ro??????????????????????????of"; $ultraComplex[] = "so??????????????????????????or"; $ultraComplex[] = "ro??????????????????????????of"; $ultraComplex[] = "so??????????????????????????or"; $ultraComplex[] = "ro??????????????????????????of"; $ultraComplex[] = "so??????????????????????????or"; $ultraComplex[] = "ro??????????????????????????of"; $ultraComplex[] = "so??????????????????????????or"; $ultraComplex[] = "ro??????????????????????????of"; $ultraComplex[] = "so??????????????????????????or"; $ultraComplex[] = "roooooooooooooooooooooooooooof"; $ultraComplex = insertPoint($ultraComplex, 'abcde'); $ultraComplex = insertPoint($ultraComplex, 'tumngh'); $ultraComplex = insertPoint($ultraComplex, 'ppppppppppp'); $myparams['checkpoints'] = 5; $myparams['teleports'] = 3; $myparams['rockchance'] = 9; $myparams['walls'] = 38; $myparams['name'] = 'Ultra Complex'; $map = GenerateShapedMap($ultraComplex, $myparams); break; default: $map = GenerateMap(rand(13, 18), rand(10, 14), rand(6, 9)); break; } $lock = acquireMotdLock(); try { //Double check... $sql is already set $result = mysql_query($sql); //Are you SURE there's no map? if (mysql_num_rows($result) != 0) { releaseMotdLock($lock); return mapOfTheDay($type); } $code = GenerateMapCode($map); $sql = "INSERT INTO `maps` (`code`) VALUES ('$code')"; $result = mysql_query($sql); if (!$result) { releaseMotdLock($lock); die("Error on inserting map"); } $mapID = mysql_insert_id(); $r['code'] = $code; $r['map'] = $map; $r['id'] = $mapID; $sql = "INSERT INTO `mapOfTheDay` (`mapID`, `mapType`, `mapDate`) VALUES ('$mapID', '$type', CURDATE()) "; $result = mysql_query($sql); if (!$result) { releaseMotdLock($lock); die("Error on insert into mapOfTheDay"); } } catch (Exception $exc) { /* Ignore... :| */ } releaseMotdLock($lock); // ---------- Track statistics for 'yesterdays' map. trackMOTDstats($type); return $r; } /** * The file locked in order to create serialize map-creations, since our DB doesn't support transactions... */ define('FILE_MOTD_LOCK', './motdLockFile'); /** * Obtains the mutex used for creating the Map Of The Day, so that race-conditions cannot occur (like two threads * creating and inserting the maps into the database at the same time, which has happened */ function acquireMotdLock() { $fileHandle = fopen(FILE_MOTD_LOCK, 'a+'); flock($fileHandle, LOCK_EX); return $fileHandle; } /** * Releases the lock acquired from acquireMotdLock */ function releaseMotdLock($fileHandle) { if($fileHandle) flock($fileHandle, LOCK_UN); } //Select from yesterday function getYesterdaysMap() { $sql = " select `ID`, `code` from `maps` WHERE ( DAY(dateCreated) = DAY(NOW()) - 1 AND MONTH(dateCreated) = MONTH(NOW()) AND YEAR(dateCreated) = YEAR(NOW()) ) "; $result = mysql_query($sql); //No map for today? if (mysql_num_rows($result) == 0) { return -1; } $r['code'] = mysql_result($result, 0, 'code'); $r['id'] = mysql_result($result, 0, 'ID'); return $r; } function getRandomComplexMap() { $random = weight(0, 0, 0, 0, 0, 0, 0, 1); switch ($random) { case 0: $map = GenerateMap(19, 9, rand(7, 9), rand(14, 16), rand(2, 5), rand(1, 2)); break; case 1: $reversePath[] = 'fo?????????????oS'; $reversePath[] = 'fo?????????????oS'; $reversePath[] = 'fo?????????????oS'; $reversePath[] = 'fo?????????????oS'; $reversePath[] = 'fo?????????????oS'; $reversePath[] = 'fo?????????????oS'; $reversePath[] = 'fo?????????????oS'; $reversePath[] = 'fo?????????????oS'; $reversePath = insertPoint($reversePath, 'abc'); $reversePath = insertPoint($reversePath, 'tu'); $myparams['checkpoints'] = 3; $myparams['teleports'] = 0; $myparams['rockchance'] = 7; $myparams['walls'] = 12; $myparams['name'] = 'Reverse Order'; $map = GenerateShapedMap($reversePath, $myparams); break; } return $map; } function getRandomSpecialMap() { //This can be used to add additional weight to certain maps that we like. $random = weight(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); $shape = array(); $params = array(); switch ($random) { //===================================== case 0: //Thirty $map = GenerateMap( 18, 14, 20, //width, height, rocks weight(30), //Walls weight(1), //Checkpoints weight(1), //Teleports 'Thirty' ); break; //===================================== case 1: //Simple $map = GenerateMap( 18, 9, 7, //width, height, rocks weight(15, 16, 17), //Walls weight(0), //Checkpoints weight(0), //Teleports 'Finite' ); break; //===================================== case 2: //ABC's $map = GenerateMap( 19, 11, 12, //width, height, rocks weight(20, 21, 22, 22, 23), //Walls weight(3), //Checkpoints weight(0), //Teleports "ABC's " ); break; //===================================== case 3: //Tele Madness $map = GenerateMap( 17, 12, 10, //width, height, rocks weight(17, 18), //Walls weight(1), //Checkpoints weight(5), //Teleports 'Teleport Madness' ); break; //===================================== case 4: //Thursday //Rocky Maze $map = GenerateMap( 19, 15, 5, //width, height, rocks weight(16, 17, 18), //Walls weight(1, 2, 2, 2, 3, 3), //Checkpoints weight(0), //Teleports 'Rocky Maze' ); break; //===================================== case 5: //Friday //Side to Side $map = GenerateMap( 26, 6, 12, //width, height, rocks weight(17, 18, 19), //Walls weight(2, 2, 2, 3, 3), //Checkpoints weight(3, 3, 3, 4), //Teleports 'Side to Side' ); break; //===================================== case 6: //Ultimate's Random map: //Create shape $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; //Insert points $shape = insertPoint($shape, "sfabcr", $target = '?'); $shape = insertPoint($shape, weight("tu", "d", "tu", "", ""), $target = '?'); //Set params $params['rockchance'] = 10; $params['walls'] = weight(21, 20, 22, 20, 21); $params['name'] = 'Ultimate Random'; //Put it all together. $map = GenerateShapedMap($shape, $params); break; //===================================== //===================================== case 7: //Dual map $dualmapa[] = "s???????????????????f"; $dualmapa[] = "s???????????????????f"; $dualmapa[] = "s???????????????????f"; $dualmapa[] = "s???????????????????f"; $dualmapa[] = "s???????????????????f"; $dualmapa[] = "s???????????????????f"; $dualmapa[] = "oqqqqqqqqqqqqqqqqqqqo"; $dualmapb[] = "s???????????????????f"; $dualmapb[] = "s???????????????????f"; $dualmapb[] = "s???????????????????f"; $dualmapb[] = "s???????????????????f"; $dualmapb[] = "s???????????????????f"; $dualmapb[] = "s???????????????????f"; $dualmapa = insertPoint($dualmapa, 'abc'); $dualmapb = insertPoint($dualmapb, 'abc'); $dualmap = array_merge($dualmapa, $dualmapb); $dualmap = insertPoint($dualmap, 'tu'); $myparams['checkpoints'] = 3; $myparams['teleports'] = 1; $myparams['rockchance'] = 9; $myparams['walls'] = weight(20, 20, 21, 21, 22, 23); $myparams['name'] = 'Seeing Double'; $map = GenerateShapedMap($dualmap, $myparams); break; //===================================== //===================================== case 8: //Centralized $myshape[] = "ooooooooooooooooooo"; $myshape[] = "o?????????????????o"; $myshape[] = "o?????????????????o"; $myshape[] = "o?????????????????o"; $myshape[] = "o???????fos???????o"; $myshape[] = "o?????????????????o"; $myshape[] = "o?????????????????o"; $myshape[] = "o?????????????????o"; $myshape[] = "ooooooooooooooooooo"; $myshape = insertPoint($myshape, "abc", $target = '?'); $myshape = insertPoint($myshape, weight("tu", "d", "tud", ""), $target = '?'); $myparams['rockchance'] = 7; $myparams['walls'] = weight(17, 18, 19, 18, 17); $myparams['name'] = 'Centralized'; $map = GenerateShapedMap($myshape, $myparams); break; //===================================== //===================================== case 9: $dualingPaths[] = 'so??????????????xf'; $dualingPaths[] = 'so??????????????xf'; $dualingPaths[] = 'so??????????????xf'; $dualingPaths[] = 'so??????????????xf'; $dualingPaths[] = 'Xo??????????????ox'; $dualingPaths[] = 'fX??????????????oS'; $dualingPaths[] = 'fX??????????????oS'; $dualingPaths[] = 'fX??????????????oS'; $dualingPaths[] = 'fX??????????????oS'; $dualingPaths = insertPoint($dualingPaths, 'abc'); $dualingPaths = insertPoint($dualingPaths, weight('xx', 'xxx', 'xxxx').weight('XX', 'XXX', 'XXXX')); $myparams['checkpoints'] = 3; $myparams['teleports'] = 0; $myparams['rockchance'] = 9; $myparams['walls'] = 13; $myparams['name'] = 'Dualing paths'; $map = GenerateShapedMap($dualingPaths, $myparams); break; //===================================== //===================================== case 10: $unlimited[] = 'so?o?o?o?o?o?o?of'; $unlimited[] = 's???????????????f'; $unlimited[] = 'so?????????????of'; $unlimited[] = 's???????????????f'; $unlimited[] = 'so?????????????of'; $unlimited[] = 's???????????????f'; $unlimited[] = 'so?????????????of'; $unlimited[] = 's???????????????f'; $unlimited[] = 'so?o?o?o?o?o?o?of'; $unlimited = insertPoint($unlimited, 'abc'); $unlimited = insertPoint($unlimited, weight('tu', 'dtu')); $myparams['checkpoints'] = 3; $myparams['teleports'] = 1; $myparams['rockchance'] = 9; $myparams['walls'] = 999; $myparams['name'] = 'Unlimited'; $map = GenerateShapedMap($unlimited, $myparams); break; //===================================== } return $map; } ?> \ No newline at end of file
+<?php include_once('maps.php'); include_once('db.inc.php'); /** * Returns the Map Of The Day with the given type (index) */ function mapOfTheDay($type = 1) { ignore_user_abort(true); if ($type <= 8) $expire = 2; if ($type <= 4) $expire = 1; $sql = " SELECT maps.ID, maps.code FROM `mapOfTheDay`, `maps` WHERE `mapType` = $type AND DATEDIFF(CURDATE(), mapOfTheDay.mapDate) < $expire AND mapID = maps.ID "; $result = mysql_query($sql); //No map for today? if (mysql_num_rows($result) != 0) { $r['code'] = mysql_result($result, 0, 'code'); $r['map'] = GenerateMapByCode($r['code']); $r['id'] = mysql_result($result, 0, 'ID'); return $r; } return generateNewMapOfTheDay($type, $sql); } /** * Generates a new map of the day. DO NOT CALL OUTSIDE OF mapoftheday.php */ function generateNewMapOfTheDay($type, $sql) { // If you want to modify the maps created! This is the line //GenerateMap($rows, $cols, $rockchance, $numBlocks = -1, $cp = -1, $tp = -1) { switch ($type) { case 1: //Easy $map = GenerateMap(13, 7, 12, rand(7, 10), rand(0, 1), 0); break; case 2: //Normal $map = GenerateMap(15, 9, 7, rand(11, 13), rand(1, 3) + rand(0, 1), 0); break; case 3: //Hard $map = getRandomComplexMap(); break; case 4: //Full random map $map = getRandomSpecialMap(); break; case 5: $map = getRandomWeeklyMap(); break; default: $map = GenerateMap(rand(13, 18), rand(10, 14), rand(6, 9)); break; } $lock = acquireMotdLock(); try { //Double check... $sql is already set $result = mysql_query($sql); //Are you SURE there's no map? if (mysql_num_rows($result) != 0) { releaseMotdLock($lock); return mapOfTheDay($type); } $code = GenerateMapCode($map); $sql = "INSERT INTO `maps` (`code`) VALUES ('$code')"; $result = mysql_query($sql); if (!$result) { releaseMotdLock($lock); die("Error on inserting map"); } $mapID = mysql_insert_id(); $r['code'] = $code; $r['map'] = $map; $r['id'] = $mapID; $sql = "INSERT INTO `mapOfTheDay` (`mapID`, `mapType`, `mapDate`) VALUES ('$mapID', '$type', CURDATE()) "; $result = mysql_query($sql); if (!$result) { releaseMotdLock($lock); die("Error on insert into mapOfTheDay"); } } catch (Exception $exc) { /* Ignore... :| */ } releaseMotdLock($lock); // ---------- Track statistics for 'yesterdays' map. trackMOTDstats($type); return $r; } /** * The file locked in order to create serialize map-creations, since our DB doesn't support transactions... */ define('FILE_MOTD_LOCK', './motdLockFile'); /** * Obtains the mutex used for creating the Map Of The Day, so that race-conditions cannot occur (like two threads * creating and inserting the maps into the database at the same time, which has happened */ function acquireMotdLock() { $fileHandle = fopen(FILE_MOTD_LOCK, 'a+'); flock($fileHandle, LOCK_EX); return $fileHandle; } /** * Releases the lock acquired from acquireMotdLock */ function releaseMotdLock($fileHandle) { if($fileHandle) flock($fileHandle, LOCK_UN); } //Select from yesterday function getYesterdaysMap() { $sql = " select `ID`, `code` from `maps` WHERE ( DAY(dateCreated) = DAY(NOW()) - 1 AND MONTH(dateCreated) = MONTH(NOW()) AND YEAR(dateCreated) = YEAR(NOW()) ) "; $result = mysql_query($sql); //No map for today? if (mysql_num_rows($result) == 0) { return -1; } $r['code'] = mysql_result($result, 0, 'code'); $r['id'] = mysql_result($result, 0, 'ID'); return $r; } function getRandomComplexMap() { $random = weight(0, 0, 0, 0, 0, 0, 0, 1); switch ($random) { case 0: $map = GenerateMap(19, 9, rand(7, 9), rand(14, 16), rand(2, 5), rand(1, 2)); break; case 1: $reversePath[] = 'fo?????????????oS'; $reversePath[] = 'fo?????????????oS'; $reversePath[] = 'fo?????????????oS'; $reversePath[] = 'fo?????????????oS'; $reversePath[] = 'fo?????????????oS'; $reversePath[] = 'fo?????????????oS'; $reversePath[] = 'fo?????????????oS'; $reversePath[] = 'fo?????????????oS'; $reversePath = insertPoint($reversePath, 'abc'); $reversePath = insertPoint($reversePath, 'tu'); $myparams['checkpoints'] = 3; $myparams['teleports'] = 0; $myparams['rockchance'] = 7; $myparams['walls'] = 12; $myparams['name'] = 'Reverse Order'; $map = GenerateShapedMap($reversePath, $myparams); break; } return $map; } function getRandomSpecialMap() { //This can be used to add additional weight to certain maps that we like. $random = weight(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); $shape = array(); $params = array(); switch ($random) { //===================================== case 0: //Thirty $map = GenerateMap( 18, 14, 20, //width, height, rocks weight(30), //Walls weight(1), //Checkpoints weight(1), //Teleports 'Thirty' ); break; //===================================== case 1: //Simple $map = GenerateMap( 18, 9, 7, //width, height, rocks weight(15, 16, 17), //Walls weight(0), //Checkpoints weight(0), //Teleports 'Finite' ); break; //===================================== case 2: //ABC's $map = GenerateMap( 19, 11, 12, //width, height, rocks weight(20, 21, 22, 22, 23), //Walls weight(3), //Checkpoints weight(0), //Teleports "ABC's " ); break; //===================================== case 3: //Tele Madness $map = GenerateMap( 17, 12, 10, //width, height, rocks weight(17, 18), //Walls weight(1), //Checkpoints weight(5), //Teleports 'Teleport Madness' ); break; //===================================== case 4: //Thursday //Rocky Maze $map = GenerateMap( 19, 15, 5, //width, height, rocks weight(16, 17, 18), //Walls weight(1, 2, 2, 2, 3, 3), //Checkpoints weight(0), //Teleports 'Rocky Maze' ); break; //===================================== case 5: //Friday //Side to Side $map = GenerateMap( 26, 6, 12, //width, height, rocks weight(17, 18, 19), //Walls weight(2, 2, 2, 3, 3), //Checkpoints weight(3, 3, 3, 4), //Teleports 'Side to Side' ); break; //===================================== case 6: //Ultimate's Random map: //Create shape $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; $shape[] = "??????????????????"; //Insert points $shape = insertPoint($shape, "sfabcr", $target = '?'); $shape = insertPoint($shape, weight("tu", "d", "tu", "", ""), $target = '?'); //Set params $params['rockchance'] = 10; $params['walls'] = weight(21, 20, 22, 20, 21); $params['name'] = 'Ultimate Random'; //Put it all together. $map = GenerateShapedMap($shape, $params); break; //===================================== //===================================== case 7: //Dual map $dualmapa[] = "s???????????????????f"; $dualmapa[] = "s???????????????????f"; $dualmapa[] = "s???????????????????f"; $dualmapa[] = "s???????????????????f"; $dualmapa[] = "s???????????????????f"; $dualmapa[] = "s???????????????????f"; $dualmapa[] = "oqqqqqqqqqqqqqqqqqqqo"; $dualmapb[] = "s???????????????????f"; $dualmapb[] = "s???????????????????f"; $dualmapb[] = "s???????????????????f"; $dualmapb[] = "s???????????????????f"; $dualmapb[] = "s???????????????????f"; $dualmapb[] = "s???????????????????f"; $dualmapa = insertPoint($dualmapa, 'abc'); $dualmapb = insertPoint($dualmapb, 'abc'); $dualmap = array_merge($dualmapa, $dualmapb); $dualmap = insertPoint($dualmap, 'tu'); $myparams['checkpoints'] = 3; $myparams['teleports'] = 1; $myparams['rockchance'] = 9; $myparams['walls'] = weight(20, 20, 21, 21, 22, 23); $myparams['name'] = 'Seeing Double'; $map = GenerateShapedMap($dualmap, $myparams); break; //===================================== //===================================== case 8: //Centralized $myshape[] = "ooooooooooooooooooo"; $myshape[] = "o?????????????????o"; $myshape[] = "o?????????????????o"; $myshape[] = "o?????????????????o"; $myshape[] = "o???????fos???????o"; $myshape[] = "o?????????????????o"; $myshape[] = "o?????????????????o"; $myshape[] = "o?????????????????o"; $myshape[] = "ooooooooooooooooooo"; $myshape = insertPoint($myshape, "abc", $target = '?'); $myshape = insertPoint($myshape, weight("tu", "d", "tud", ""), $target = '?'); $myparams['rockchance'] = 7; $myparams['walls'] = weight(17, 18, 19, 18, 17); $myparams['name'] = 'Centralized'; $map = GenerateShapedMap($myshape, $myparams); break; //===================================== //===================================== case 9: $dualingPaths[] = 'so??????????????xf'; $dualingPaths[] = 'so??????????????xf'; $dualingPaths[] = 'so??????????????xf'; $dualingPaths[] = 'so??????????????xf'; $dualingPaths[] = 'Xo??????????????ox'; $dualingPaths[] = 'fX??????????????oS'; $dualingPaths[] = 'fX??????????????oS'; $dualingPaths[] = 'fX??????????????oS'; $dualingPaths[] = 'fX??????????????oS'; $dualingPaths = insertPoint($dualingPaths, 'abc'); $dualingPaths = insertPoint($dualingPaths, weight('xx', 'xxx', 'xxxx').weight('XX', 'XXX', 'XXXX')); $myparams['checkpoints'] = 3; $myparams['teleports'] = 0; $myparams['rockchance'] = 9; $myparams['walls'] = 13; $myparams['name'] = 'Dualing paths'; $map = GenerateShapedMap($dualingPaths, $myparams); break; //===================================== //===================================== case 10: $unlimited[] = 'so?o?o?o?o?o?o?of'; $unlimited[] = 's???????????????f'; $unlimited[] = 'so?????????????of'; $unlimited[] = 's???????????????f'; $unlimited[] = 'so?????????????of'; $unlimited[] = 's???????????????f'; $unlimited[] = 'so?????????????of'; $unlimited[] = 's???????????????f'; $unlimited[] = 'so?o?o?o?o?o?o?of'; $unlimited = insertPoint($unlimited, 'abc'); $unlimited = insertPoint($unlimited, weight('tu', 'dtu')); $myparams['checkpoints'] = 3; $myparams['teleports'] = 1; $myparams['rockchance'] = 9; $myparams['walls'] = 999; $myparams['name'] = 'Unlimited'; $map = GenerateShapedMap($unlimited, $myparams); break; //===================================== } return $map; } function getRandomWeeklyMap() { // TEST MAP... $ultraComplex[] = "sooooooooooooooooooooooor"; $ultraComplex[] = "ro?????????????????????of"; $ultraComplex[] = "so?????????????????????or"; $ultraComplex[] = "ro?????????????????????of"; $ultraComplex[] = "so?????????????????????or"; $ultraComplex[] = "ro?????????????????????of"; $ultraComplex[] = "so?????????????????????or"; $ultraComplex[] = "ro?????????????????????of"; $ultraComplex[] = "so?????????????????????or"; $ultraComplex[] = "ro?????????????????????of"; $ultraComplex[] = "so?????????????????????or"; $ultraComplex[] = "ro?????????????????????of"; $ultraComplex[] = "so?????????????????????or"; $ultraComplex[] = "ro?????????????????????of"; $ultraComplex[] = "sooooooooooooooooooooooor"; $ultraComplex = insertPoint($ultraComplex, 'abcde'); $ultraComplex = insertPoint($ultraComplex, weight('a', 'b', 'c', 'd', 'e')); $ultraComplex = insertPoint($ultraComplex, weight('a', 'b', 'c', 'd', 'e', 'u', 'n', 'j', 'h', 'n')); $ultraComplex = insertPoint($ultraComplex, weight('a', 'b', 'c', 'd', 'e', 'u', 'n', 'j', 'h', 'n')); $ultraComplex = insertPoint($ultraComplex, 'tumnghij'); $myparams['checkpoints'] = 5; $myparams['teleports'] = 3; $myparams['rockchance'] = 12; $myparams['walls'] = 50; $myparams['name'] = 'Ultra Complex'; $map = GenerateShapedMap($ultraComplex, $myparams); return $map; } ?> \ No newline at end of file
diff --git a/includes/maps.php b/includes/maps.php
index 431f006..1df258d 100644
--- a/includes/maps.php
+++ b/includes/maps.php
@@ -726,6 +726,19 @@ function getSolution($userID, $mapID) {
}
}
+function getChallengeSolution($userID, $challengeID) {
+ include_once('db.inc.php');
+ $sql = "SELECT `solution`, `moves`
+ FROM `challengeSolutions`
+ WHERE `userID` = '$userID' AND
+ `challengeID` = '$challengeID'
+ ";
+ $result = mysql_query($sql);
+ if (mysql_num_rows($result) > 0) {
+ return mysql_fetch_assoc($result);
+ }
+}
+
function getMapCode($mapID) {
include_once('db.inc.php');
$sql = "SELECT `code`
diff --git a/index.php b/index.php
index 60cd81a..9175b30 100644
--- a/index.php
+++ b/index.php
@@ -1,5 +1,16 @@
<?PHP
ob_start("ob_gzhandler");
+
+//TODO: !! Make sure updating.php exists, and that the images in images/btns/ are uploaded.
+//Show updating page?
+//$showUpdatePage = true;
+$showUpdatePage = false;
+
+if ($showUpdatePage AND $_GET['cu'] !== "true") {
+ require("updating.php");
+ exit;
+}
+
//globe will start the session.
include_once("globe.php");
include_once("./includes/header.php");
@@ -48,6 +59,7 @@ if (isset($_SESSION['isAdmin']) && $_SESSION['isAdmin'] == true) {
//Links appear in order.
$Links['home'] = "Home";
$Links['leaderboard'] = "Scores";
+$Links['challengelist'] = "Challenges <i>BETA!</i>";
//$Links['howtoplay'] = "How to Play";
//$Links['tutorial'] = "Tutorial";
diff --git a/js/mapspecs.js b/js/mapspecs.js
index e1def28..ee9759d 100644
--- a/js/mapspecs.js
+++ b/js/mapspecs.js
@@ -20,6 +20,7 @@ else if (document.attachEvent) { // IE 8-
}
var isChallenge = false;
+var isTutorial = false;
var solution = new Array();
var blocks = new Array();
@@ -190,6 +191,12 @@ function requestSol(mapID) {
ajax.runAJAX();
}
+function requestChallengeSolution(mapID, challengeID) {
+ ajax.requestFile = "do.php?r=getChallengeSolution&mapID="+mapID+'&challengeID='+challengeID; //prepare strdata
+ ajax.onCompletion = requestSolDone; // specify function to be executed on response
+ ajax.runAJAX();
+}
+
function requestSolDone() {
var JO;
JO = decryptJSON(ajax.response);
@@ -261,7 +268,10 @@ function request_path_done() {
return;
}
+
var disptext = "Record: "+JO.best+" by "+JO.bestby;
+ if (isChallenge)
+ disptext = '';
updateDsp(JO.mapid, 'dspID', disptext);
mapdata[mapid].moveCount = new Object;
@@ -277,18 +287,6 @@ function request_path_done() {
mapdata[mapid].pathColor[i] = '#ffffff';
animatePath(JO.path[i].path, mapid, JO.path[i].start, i);
}
-
- //Mark off challenges
- //TODO: Temporarly disabled because it breaks the tutorial;
- if(isChallenge && 2 == 4)
- {
- for(var i = 0; i < JO.completedChallenges.length; i++)
- {
- var challengeId = JO.completedChallenges[i];
- document.getElementById("challenge_id_" + challengeId).className = "challenge_complete";
- }
- }
-
}
function decryptJSON(text) {
@@ -323,6 +321,22 @@ function animatePathDone(mapid) {
if (isChallenge == true) {
challengeGo(mapid);
}
+ //Mark off challenges
+ //TODO: This hack is stupidd :(
+ if(isChallenge && isTutorial == false)
+ {
+ for(var i = 0; i < mapjson[mapid].completedChallenges.length; i++)
+ {
+ var challengeId = mapjson[mapid].completedChallenges[i];
+ var handle = document.getElementById("challenge_id_" + challengeId);
+
+ if (handle.className.indexOf('challenge_complete') < 0) {
+
+ handle.className = "challenge_complete";
+ flashelement("challenge_id_" + challengeId, 4);
+ }
+ }
+ }
}
function checkSound(mapid) {
@@ -597,6 +611,7 @@ function doanimate(x, y, p, c, mapid, pathNumber) {
switch (selected) {
case '1':
rs =120;
+ rs =0;
break;
case '2':
@@ -670,8 +685,13 @@ function doanimate(x, y, p, c, mapid, pathNumber) {
// if (mapdata[mapid].moveCount[1] < mapdata[mapid].moveCount[pathNumber] - 2
// || mapdata[mapid].moveCount[0] < mapdata[mapid].moveCount[pathNumber] - 2)
// rs = rs + 100;
+
+ if (count[mapid] % 2 == 1 && rs == 0)
+ doanimate(x,y,p,t,mapid,pathNumber);
+ else
+ setTimeout("doanimate("+x+","+y+",'"+p+"','"+t+"','"+mapid+"','"+pathNumber+"')",rs);
+ //setTimeout("doanimate("+x+","+y+",'"+p+"','"+t+"','"+mapid+"','"+pathNumber+"')",1);
- setTimeout("doanimate("+x+","+y+",'"+p+"','"+t+"','"+mapid+"','"+pathNumber+"')",rs);
}
diff --git a/js/scores.js b/js/scores.js
index 0c1383f..734683a 100644
--- a/js/scores.js
+++ b/js/scores.js
@@ -28,10 +28,12 @@ function scoresRequestPage(mapid, page) {
ajax.runAJAX();// Do it!
return true;
}
+
function scoresRequestLoading() {
//Signify that it's working in some manner?
//console.log("I'm loading teh page...");
}
+
function scoresRequestPageDone() {
//console.log("Request Page Done", ajax.response);
var JO = decryptJSON(ajax.response);
@@ -46,6 +48,7 @@ function scoresRequestPageDone() {
}
}
}
+
function scoresUpdatePage(mapid, page, html) {
// console.log("Updating Page", mapid, page);
scoresPreparePage(mapid, page);
@@ -55,6 +58,7 @@ function scoresUpdatePage(mapid, page, html) {
scoresShowPage(mapid, page);
}
}
+
function scoresShowMyPage(mapid) {
//Future use
}
@@ -101,6 +105,7 @@ function scoresPreparePage (mapid, page) {
}
return true;
}
+
function scoresFormatPage(JO) {
// console.log("Formating page");
@@ -132,14 +137,14 @@ function scoresFormatPage(JO) {
styleClass = 'border-top: 6px solid #777799;';
p = p+ "<tr style='"+styleClass+" background-color: "+u.background+"; color:"+u.displayColor+";' title='Scored "+scoredLocalTime.format("h:MM:ss TT")+"'>";
- p = p+ "<td style='text-align:left;'>";
+ p = p+ "<td class='scoreMedal'>";
if (u.medal == 'gold') {
- p = p+ "<img title='Current Champion' src='../images/MedalGoldCAR.png' style='width:32px;height:32px;vertical-align:middle'>";
+ p = p+ "<img title='Current Champion' src='../images/MedalGoldCAR.png'>";
} else if (u.medal == 'silver') {
- p = p+ "<img title='Tied Top Score' src='../images/MedalSilverCAR.png' style='width:32px;height:32px;vertical-align:middle'>";
+ p = p+ "<img title='Tied Top Score' src='../images/MedalSilverCAR.png'>";
} else {
- p = p+ "<img src='../images/blank.png' style='width:32px;height:32px;vertical-align:middle'>";
+ p = p+ "<img src='../images/blank.png'>";
}
p = p+ i+ "</td>";
p = p+ "<td style='vertical-align: middle;'>";
@@ -148,7 +153,7 @@ function scoresFormatPage(JO) {
p = p+ " </div>";
p = p+ " </div>";
p = p+ "";
- p = p+ "<span style='float:left; padding: 5px 0px 3px 3px; width:120px; overflow:hidden; text-overflow: ellipsis; white-space:nowrap; '><a href='achievements?id="+u.ID+"' style='color:"+u.displayColor+"'>"+u.display+"</a></span>";
+ p = p+ "<span class='scoreName'><a href='achievements?id="+u.ID+"' style='color:"+u.displayColor+"'>"+u.display+"</a></span>";
p = p+ "</td>";
p = p+ "<td style='text-align:right;'>"+u.moves+"</td>";
p = p+ "</tr>";
@@ -181,6 +186,7 @@ function scoresFormatPage(JO) {
//p = JO.navi+p;
return p;
}
+
function scoresFormatPageNavi(JO) {
var r = '';
var showedPrevPage = true;
@@ -208,4 +214,210 @@ function scoresFormatPageNavi(JO) {
}
return r;
-} \ No newline at end of file
+}
+
+
+//Memberlist related functions:
+var membersPages = new Object;
+var membersCurrentPage = 1;
+
+function membersRequestPage(page) {
+ console.log('membersRequestPage', page);
+ if (typeof(ajax) != 'object') {
+ setTimeout(function() {membersRequestPage(page)},200);
+ return false;
+ }
+ // Ask again if it's busy.
+ switch (ajax.xmlhttp.readyState) {
+ case 4:
+ case 0:
+ break;
+ default:
+ setTimeout(function() {membersRequestPage(page)},300);
+ return false;
+ }
+
+ //console.log("Requesting Page", page, ajax.inUse);
+ // == Additionally, check for achievements.
+ ajax.requestFile = "do.php?r=reqMemberPage&reqPage="+page;
+ ajax.onCompletion = membersRequestPageDone; // Specify function to be executed on response.
+ //ajax.onLoading = '';
+ //ajax.onLoaded = '';
+ //ajax.onFail = '';
+ ajax.runAJAX();// Do it!
+ return true;
+}
+
+function membersRequestPageDone() {
+ //console.log("Request Page Done", ajax.response);
+ var JO = decryptJSON(ajax.response);
+ if (JO == undefined)
+ return;
+ membersUpdatePage(JO.page, membersFormatPage(JO));
+}
+
+function membersShowPage(page) {
+ page = page - 0;
+ console.log('membersShowPage', page);
+ if (membersPreparePage(page) == false) {
+ membersCurrentPage = page;
+ //Signify some sort of loadingness?
+ //Request Page
+ membersRequestPage(page);
+ return;
+ }
+
+ if (typeof(membersPages[page].html) === 'undefined') {
+ membersRequestPage(page);
+ membersCurrentPage = page;
+ return;
+ }
+ document.getElementById('members').innerHTML = membersPages[page].html
+
+ //Also; update the page
+
+ if (page != membersCurrentPage) {
+ membersRequestPage(page);
+ }
+ membersCurrentPage = page;
+}
+
+function membersPreparePage (page) {
+ if (typeof(membersPages) != 'object') {
+ membersPages = new Object;
+ membersPages[page] = new Object;
+ return false;
+ }
+ if (typeof(membersPages[page]) != 'object') {
+ membersPages[page] = new Object;
+ return false;
+ }
+ return true;
+}
+
+function membersUpdatePage(page, html) {
+ console.log("Updating Page", page);
+ membersPreparePage(page);
+ membersPages[page].html = html;
+ if (page == membersCurrentPage) {
+ membersShowPage(page);
+ }
+}
+
+function membersFormatPageNavi(JO) {
+ var r = '';
+ var showedPrevPage = true;
+ for (var i = 1; i <= JO.pageCount; i++) {
+ if (
+ (JO.page > i - 3 && JO.page < i + 3)
+ || (i == 1)
+ || (i == JO.pageCount)
+ || (i == JO.userPage)
+ ) {
+
+ if (!showedPrevPage)
+ r = r + ' ... ';
+ if (JO.page == i) {
+ r = r + " <b style='color:#aaaabb; font-size:150%;'>" + i + "</b>";
+ } else if (i == JO.userPage) {
+ r = r + " <a href='javascript:membersShowPage("+i+")' style='color:#99cc99;' title='You are on this page'><i>" + i + '</i></a>';
+ } else {
+ r = r + " <a href='javascript:membersShowPage("+i+")'>" + i + '</a>';
+ }
+ showedPrevPage = true;
+ } else {
+ showedPrevPage = false;
+ }
+ }
+
+ return r;
+}
+
+function membersFormatPage(JO) {
+ // console.log("Formating page");
+
+ var p = "<table class='score'>";
+ if (JO.pageCount > 1) {
+ var navi = membersFormatPageNavi(JO);
+ p = p+"<tr><td colspan='9' style='text-align:center;'>"+navi+"</td></tr>";
+ }
+
+ p = p+"<tr title='Updated "+JO.updateTime+"'>";
+ p = p+"<th>Rank</th>";
+ p = p+"<th style='width:125px; overflow:hidden; text-align:left; padding-left:42px;'>Name</th>";
+ p = p+"<th>Mazes</th>";
+ p = p+"<th>Moves</th>";
+ p = p+"<th>Past Week</th>";
+ p = p+"<th>Wins</th>";
+ p = p+"<th>Ties</th>";
+ p = p+"<th>Joined</th>";
+ p = p+"<th>Last Login</th>";
+ p = p+"</tr>";
+
+ var showedLastUser = true;
+ var x = 0;
+
+ var previousI = 0;
+
+ for (var i in JO.users) {
+ var u = JO.users[i];
+ var scoredLocalTime = new Date();
+ scoredLocalTime.setTime(scoredLocalTime.getTime() - u.secondsSinceScored * 1000);
+
+ var styleClass = '';
+
+ if (previousI != i + 1)
+ if (previousI < i - 1 && previousI != 0)
+ styleClass = 'border-top: 6px solid #777799;';
+
+ p = p+ "<tr style='"+styleClass+" background-color: "+u.background+"; color:"+u.displayColor+";' title='Scored "+scoredLocalTime.format("h:MM:ss TT")+"'>";
+ p = p+ "<td style='text-align:left;'>";
+ p = p+ i+ "</td>";
+ p = p+ "<td style='vertical-align: middle;'>";
+ p = p+ " <div class='grid_td' style='float:left; width:35px; height:35px; background:"+u.wallColor+" url(images/marks/"+u.wallEmblem+");'>";
+ p = p+ " <div style='background-color:transparent;' class='grid_td_inner grid_td_rocks'>";
+ p = p+ " </div>";
+ p = p+ " </div>";
+ p = p+ "";
+ p = p+ "<span class='scoreName'><a href='achievements?id="+u.ID+"' style='color:"+u.displayColor+"'>"+u.display+"</a></span>";
+ p = p+ "</td>";
+
+ p = p+ "<td style='text-align:right;'>"+u.totalMazes+"</td>";
+ p = p+ "<td style='text-align:right;'>"+u.totalMoves+"</td>";
+ p = p+ "<td style='text-align:right;'>"+u.totalMovesThisWeek+"</td>";
+ p = p+ "<td style='text-align:right;'>"+u.totalWins+"</td>";
+ p = p+ "<td style='text-align:right;'>"+u.totalTies+"</td>";
+ p = p+ "<td style='text-align:right;'>"+u.dateJoined+"</td>";
+ p = p+ "<td style='text-align:right;'>"+u.dateLogin+"</td>";
+ p = p+ "</tr>";
+
+ previousI = i;
+ }
+
+ //p = p+"<tr><th colspan='3' style='text-align:center;'>"+navi+"</th></tr>";
+ p = p+"</table>";
+
+ var nextPage = JO.page - 0 + 1;
+ var prevPage = JO.page - 1;
+
+ if (JO.pageCount > 1) {
+ if (JO.page < JO.pageCount) {
+ p = p+"<a href='javascript:membersShowPage("+nextPage+")' class='rightBtn scoreActive'>&gt;</a>";
+ } else
+ p = "<div class='rightBtn scoreDisabled'>&gt;</div>"+p;
+ if (JO.page > 1) {
+ p = "<a href='javascript:membersShowPage("+prevPage+")' class='leftBtn scoreActive'>&lt;</a>"+p;
+ } else
+ p = "<div class='leftBtn scoreDisabled'>&lt;</div>"+p;
+ }
+ p = "<div class='scoreContainer1'>"+p+"</div>";
+
+ //console.log(p);
+ //console.log('jo page', JO.page);
+ //console.log('jo pagecount', JO.pageCount);
+ //p = JO.navi+p;
+ return p;
+}
+
+
+
diff --git a/pages/challenge.php b/pages/challenge.php
index 2ab279d..8d312d1 100644
--- a/pages/challenge.php
+++ b/pages/challenge.php
@@ -1,5 +1,4 @@
<?php
-ob_start("ob_gzhandler");
htmlHeader(
array('tutorial', 'challenge'), 'Pathery Challenges',
'Challenges', array('scores', 'dateformat')
@@ -94,8 +93,11 @@ if($mapCode === NULL)
return;
}
+// TODO: !! Sanitize mapid
+$mapID = $_GET["mapID"];
+
$mapContent = displayMap(GenerateMapByCode($mapCode), $_GET["mapID"]);
-$challengeResultset = loadChallengesForMap($_GET["mapID"], $userID);
+$challengeResultset = loadChallengesForMap($mapID, $userID);
if($challengeResultset === NULL)
{
redirectToChallengeListing();
@@ -112,9 +114,6 @@ if($challengeResultset === NULL)
?>
</div>
-<div id="copy" style='width:100%;clear: both'>
- Copyright &copy; 2011-2012 pathery.com
-</div>
<script src="sounds/script/soundmanager.js"></script>
<script type="text/javascript">soundManagerInit();</script>
@@ -135,13 +134,15 @@ function displayChallenges($challengeResultset)
echo '<div id="challenges_listing"><ol>';
while($challenge = mysql_fetch_array($challengeResultset))
{
+ $mapID = $_GET["mapID"];
$challengeId = $challenge["challengeID"];
echo "<li>";
if($challenge["dateSolved"] !== NULL)
$cssClass = "challenge_complete";
else
$cssClass = "challenge_incomplete";
- echo "<span class='$cssClass' id='challenge_id_$challengeId'>" . getChallengeDisplayString($challenge) . "</span>";
+ $loadSolutionString = "<a href='javascript:requestChallengeSolution(\"$mapID\", \"$challengeId\");'> Load this solution</a>";
+ echo "<span class='$cssClass' id='challenge_id_$challengeId'>" . getChallengeDisplayString($challenge) . " $loadSolutionString </span>";
echo "</li>";
}
echo "</ol></div></div>";
@@ -157,7 +158,7 @@ function getChallengeDisplayString($challenge)
if($challenge["goal"] == 0)
$returnMe .= "Complete the maze";
else if ($challenge['inequality'] == "greater than")
- $returnMe .= "Get " . $challenge['goal'];
+ $returnMe .= "Get " . $challenge['goal'] . ' or more';
else if ($challenge['inequality'] == "less than")
$returnMe .= "Get LESS THAN " . $challenge['goal'];
else //inequality == "equal"
@@ -169,7 +170,7 @@ function getChallengeDisplayString($challenge)
//Wall-count restriction
if($challenge['restrictWallCount'] !== NULL)
{
- $restrictions[] = "at most " . $challenge['restrictWallCount'] . " wall" . ($challenge['restrictWallCount'] == 1 ? "" : "s");
+ $restrictions[] = "only " . $challenge['restrictWallCount'] . " wall" . ($challenge['restrictWallCount'] == 1 ? "" : "s");
$addUsingToText = true;
}
diff --git a/pages/challengelist.php b/pages/challengelist.php
index e3f057a..03dfdb3 100644
--- a/pages/challengelist.php
+++ b/pages/challengelist.php
@@ -1,5 +1,4 @@
<?php
-ob_start("ob_gzhandler");
htmlHeader(
array('tutorial', 'challenge'), 'Pathery Challenges',
'Challenges', array('scores', 'dateformat')
@@ -45,10 +44,6 @@ displayChallengeList($challengeListResultset);
?>
</div>
-<div id="copy" style='width:100%;clear: both'>
- Copyright &copy; 2011-2012 pathery.com
-</div>
-
<?php
htmlFooter();
?>
@@ -84,7 +79,7 @@ function displayChallengeList($challengeListResultset)
echo '</td></tr>';
}
$currentMap = $challenge["mapID"];
- $mapName = $challenge["challengeName"];
+ $mapName = $challenge["name"];
if($mapName == NULL || $mapName == "")
$mapName = "(unknown)";
echo "<tr><td class='challengelist_link'><a href='challenge?mapID=$currentMap'>$mapName</a></td>";
diff --git a/pages/faq.php b/pages/faq.php
index 7b3c09c..3df08eb 100644
--- a/pages/faq.php
+++ b/pages/faq.php
@@ -124,8 +124,8 @@ Likewise, the Red Path noted by red in the arrow may pass over Red Allow blocks:
<p>The pathing is very greedy. It's only looking at it's next target.
<b>It does not look at the big-picture</b>. You can use this to your advantage.
When there's more than one checkpoint, you can completely wall one off.
-<br />Not many maps contain will more than one of any checkpoint.
-<br />The below demo demonstrates it's greed. - The path will actually be shorter if you wall the bottom A.
+<br />Not many maps will contain more than one of any checkpoint.
+<br />The below demo demonstrates it's greed. - The path will actually be shorter if you wall the bottom A!
<h3>Demo 3</h3>
<? echo $demo3; ?>
diff --git a/pages/gallery.php b/pages/gallery.php
index 098cf74..9df059a 100644
--- a/pages/gallery.php
+++ b/pages/gallery.php
@@ -28,17 +28,171 @@ topbar($Links);
include('./includes/maps.php');
include('./includes/mapoftheday.php');
+//$map = getRandomSpecialMap();
+//$map = getRandomWeeklyMap();
+//$map = getRandomComplexMap();
+echo "<br />";
+echo soundManager2();
+
+
+$spin[] = 'ooooooooooooooo';
+$spin[] = 'oooooororoooooo';
+$spin[] = 'ooooooooooooooo';
+$spin[] = 'uoooroormoroooo';
+$spin[] = 'soooooratooooof';
+$spin[] = 'noooooororooooo';
+$spin[] = 'ooooorooooooooo';
+$spin[] = 'oooooooroororoo';
+$spin[] = 'ooooooooooooooo';
+
+
+$myparams['checkpoints'] = 3;
+$myparams['teleports'] = 1;
+$myparams['rockchance'] = 2000;
+$myparams['walls'] = 12;
+$myparams['name'] = 'Round and Round';
+
+$map = GenerateShapedMap($spin, $myparams);
+
+echo DisplayMap($map, 2);
+
+//addNewChallengeMap($map, 0, 0, 'Round and Round');
+
+//addNewChallenge(1194, "greater than", 163, 1, "Make it go around and around and around");
+//addNewChallenge(1194, "greater than", 161, 1, "Make it go around and around and around", 11);
+//addNewChallenge(1194, "greater than", 173, 1, "Make it go around and around and around");
+
+exit;
+
+
+//Add's a new custom challenge map - returns mapid
+function addNewChallengeMap($map, $tier, $subOrder, $name) {
+ $mapcode = GenerateMapCode($map);
+
+ $sql = "INSERT INTO `maps`
+ (`code`, `isChallenge`, `ChallengeTier`, `ChallengeSuborder`, `ChallengeName`)
+ VALUES
+ ('$mapcode', true, $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`,
+ `restrictWallCount`, `restrictWallPlacement`, `restrictTeleportCount`,
+ `restrictTeleportsUsed`, `restrictStartPoint`, `restrictEndPoint`
+ )
+ VALUES (
+ '$mapID', '$inequality', $goal, $ordering, '$hint',
+ '$restrictWallCount', '$restrictWallPlacement', '$restrictTeleportCount',
+ '$restrictTeleportsUsed', '$restrictStartPoint', '$restrictEndPoint'
+ )";
+
+ echo $sql;
+ mysql_query($sql);
+ $challengeID = mysql_insert_id();
+ return $challengeID;
+}
+
+
+$reversePath[] = 'fo????????????oS';
+$reversePath[] = 'fo????????????oS';
+$reversePath[] = 'fo????????????oS';
+$reversePath[] = 'fo????????????oS';
+$reversePath[] = 'fo????????????oS';
+$reversePath[] = 'fo????????????oS';
+$reversePath[] = 'fo????????????oS';
+
+$reversePath = insertPoint($reversePath, 'abc');
+
+$myparams['checkpoints'] = 3;
+$myparams['teleports'] = 0;
+$myparams['rockchance'] = 7;
+$myparams['walls'] = 12;
+$myparams['name'] = 'Dualing paths';
+
+//$map = GenerateShapedMap($reversePath, $myparams);
-$openmaps[] = 'Souxoooooooooooooooooooo';
-$openmaps[] = 'ooxoooXooooooooooooooooo';
-$openmaps[] = 'oxooooXoooooooooeocooooo';
-$openmaps[] = 'oxooooXooooooooooooooooo';
-$openmaps[] = 'oxooooXoooaoootooooooooo';
-$openmaps[] = 'oxooooXooooooooooooooooo';
-$openmaps[] = 'oxooooXooooooooooooooooo';
-$openmaps[] = 'oxooooXooooooooooooooooo';
-$openmaps[] = 'oxoooXbdoooooooooooooooo';
-$openmaps[] = 'fooooXooooooooooooooooos';
+$dualingPaths[] = 'so??????????????xf';
+$dualingPaths[] = 'so??????????????xf';
+$dualingPaths[] = 'so??????????????xf';
+$dualingPaths[] = 'so??????????????xf';
+$dualingPaths[] = 'Xo??????????????ox';
+$dualingPaths[] = 'fX??????????????oS';
+$dualingPaths[] = 'fX??????????????oS';
+$dualingPaths[] = 'fX??????????????oS';
+$dualingPaths[] = 'fX??????????????oS';
+
+$dualingPaths = insertPoint($dualingPaths, 'abc');
+$dualingPaths = insertPoint($dualingPaths, weight('x', 'xx', 'xxx').weight('X', 'XX', 'XXX'));
+
+$myparams['checkpoints'] = 3;
+$myparams['teleports'] = 0;
+$myparams['rockchance'] = 9;
+$myparams['walls'] = 12;
+$myparams['name'] = 'Dualing paths';
+
+$map = GenerateShapedMap($dualingPaths, $myparams);
+echo DisplayMap($map, 1);
+
+
+
+$unlimited[] = 'so?o?o?o?o?o?o?of';
+$unlimited[] = 's???????????????f';
+$unlimited[] = 'so?????????????of';
+$unlimited[] = 's???????????????f';
+$unlimited[] = 'so?????????????of';
+$unlimited[] = 's???????????????f';
+$unlimited[] = 'so?????????????of';
+$unlimited[] = 's???????????????f';
+$unlimited[] = 'so?o?o?o?o?o?o?of';
+
+$unlimited = insertPoint($unlimited, 'abc');
+$unlimited = insertPoint($unlimited, weight('tu', 'dtu'));
+
+$myparams['checkpoints'] = 3;
+$myparams['teleports'] = 1;
+$myparams['rockchance'] = 9;
+$myparams['walls'] = 999;
+$myparams['name'] = 'Unlimited';
+
+$map = GenerateShapedMap($unlimited, $myparams);
+
+
+echo "<br />";
+echo soundManager2();
+echo DisplayMap($map, 2);
+
+htmlfooter();
+exit;
+
+//$map = GenerateShapedMap($dualingPaths, $myparams);
+
+//$map = getRandomSpecialMap();
+//$map = getRandomComplexMap();
+
+ // DUALING PATHS MAP
+
+
+
+$openmaps[] = 'SouooooooXoooooooXooooxf';
+$openmaps[] = 'oooooooooXoooooooXooooox';
+$openmaps[] = 'oooooooooxooooooeXcooooo';
+$openmaps[] = 'oooooooooxoooooooXoooooo';
+$openmaps[] = 'oooooooooxaoootooXoooooo';
+$openmaps[] = 'oooooooooxxxxxxxxxoooooo';
+$openmaps[] = 'oooooooooooooooooooooooo';
+$openmaps[] = 'oooooooooooooooooooooooo';
+$openmaps[] = 'Xooooobdoooooooooooooooo';
+$openmaps[] = 'fXooooooooooooooooooooos';
$myparams['checkpoints'] = 5;
$myparams['teleports'] = 0;
@@ -46,9 +200,9 @@ $myparams['rockchance'] = 15;
$myparams['walls'] = 38;
$myparams['name'] = 'Dualing Starts';
-$map = GenerateShapedMap($openmaps, $myparams);
+//$map = GenerateShapedMap($openmaps, $myparams);
-echo DisplayMap($map, 1);
+//echo DisplayMap($map, 1);
?>
<script src="sounds/script/soundmanager.js"></script>
diff --git a/pages/home.php b/pages/home.php
index 7a197aa..37a94c3 100644
--- a/pages/home.php
+++ b/pages/home.php
@@ -124,6 +124,7 @@ Schick mir einfach eine Zeile auf der <a href="feedback">Feedback-Seite</a>.
<br />
+
<?
if ($accepted) {
if (!hasCompletedTutorial($userID)) {
@@ -164,15 +165,13 @@ if ($mapNames[4] == '') {
$mapNames[4] = 'Special';
}
-
-
-// $motd = MapOfTheDay(5);
-// $jmid[5] = $motd['id'];
-// $mapContent .= displayMaze($motd, 5);
-// $special2 = $motd['map'][0][6];
-// if ($special2 == '') {
- // $special2 = 'Special';
-// }
+$motd = MapOfTheDay(5);
+$jmid[5] = $motd['id'];
+$mapContent .= displayMaze($motd, 5);
+$mapNames[5] = $motd['map'][0][6];
+if ($mapNames[5] == '') {
+ $mapNames[5] = 'Special';
+}
echo ' <div id="difficulties">';
foreach ($mapNames as $key => $value) {
@@ -210,14 +209,14 @@ function displayMaze($motd, $mapType) {
";
$mysolution = '';
- $mymoves = '';
+ $mymoves = 0;
if ($accepted) {
$sol = getSolution($userID, $mapID);
$mysolution = $sol['solution'];
//TODO: implement mymoves
$mymoves = $sol['moves'];
}
- if (isset($_SESSION[$mapID.'sol']) && $mysolution == '') {
+ if (isset($_SESSION[$mapID.'sol']) && $_SESSION[$mapID.'moves'] > $mymoves) {
$mysolution = $_SESSION[$mapID.'sol'];
$mymoves = $_SESSION[$mapID.'moves'];
}
diff --git a/pages/tutorial.php b/pages/tutorial.php
index 6854be8..4d2446f 100644
--- a/pages/tutorial.php
+++ b/pages/tutorial.php
@@ -36,6 +36,7 @@ playerWallEmblem = '<?PHP echo isset($wallEmblem) ? $wallEmblem : ''; ?>';
<script>
isChallenge = true;
+isTutorial = true;
challengeID = 1;