diff options
Diffstat (limited to 'pages/challengelist.php')
-rw-r--r-- | pages/challengelist.php | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/pages/challengelist.php b/pages/challengelist.php index d6e6d2f..ade47b6 100644 --- a/pages/challengelist.php +++ b/pages/challengelist.php @@ -26,8 +26,15 @@ if (!$accepted) { htmlFooter(); return; } + $userID = $_SESSION['userID']; +if (!hasCompletedTutorial($userID)) { + echo "<center>Please <a href='tutorial'>complete the tutorial</a> to unlock Challenge mode!</div>"; + htmlFooter(); + return; +} + //TODO: Uncomment //if (!hasCompletedTutorial($userID)) { // echo "<center>Please <a href='tutorial'>complete the tutorial</a> to unlock Challenge mode!</div>"; @@ -72,13 +79,14 @@ function getChallengeListHtml($challengeListResultset) { foreach ($challengeMap as $challengeSuborder => $challenge) { //Hack to get the first element of the array: $firstChallenge = $challenge[key($challenge)]; - $mapid = $firstChallenge['mapID']; + $challengeMapID = $firstChallenge['challengeMapID']; - $mapCode = getMapCode($mapid); + //$mapCode = getMapCode($mapid); + $mapCode = $firstChallenge['mapCode']; $map = new map($mapCode); $thumbnail = DisplayMapThumbnail($map); - $r .= "<div class='challengelist_map' onclick='document.location.href=\"challenge?mapID=$mapid\"'>"; + $r .= "<div class='challengelist_map' onclick='document.location.href=\"challenge?challengeMapID=$challengeMapID\"'>"; $r .= "$map->name"; $r .= $thumbnail; @@ -107,7 +115,7 @@ function getChallengeListHtml($challengeListResultset) { function getNextChallengeTierHtml($numCompletedChallenges) { - global $tierChallengeRequirements; + global $tierChallengeRequirements, $userID; for($nextTier = 0; $nextTier < count($tierChallengeRequirements); $nextTier++) { @@ -130,20 +138,24 @@ function getNextChallengeTierHtml($numCompletedChallenges) return "<div class='challengelist_nexttier>All tiers have been unlocked!</div>"; return "<div class='challengelist_nexttier'>Next tier unlocked in <span class='challengelist_nexttier_requirement'>$numChallengesForNextTier</span>" - . "<span class='challengelist_complete'></span>!</div>"; + . "<span class='challengelist_complete'></span></div>"; } function numChallengesRemainingForTier($tier, $numCompletedChallenges) { + global $tierChallengeRequirements; + if($tier >= maxTier()) return -1; if($tierChallengeRequirements[$tier] <= $numCompletedChallenges) return 0; - return ($numCompletedChallenges - $tierChallengeRequirements[$tier]); + return ($tierChallengeRequirements[$tier] - $numCompletedChallenges); } function maxTier() { + global $tierChallengeRequirements; + return (count($tierChallengeRequirements) - 1); } |