Challenges

Greetings tester of test-needed things.

Challenges

Daily Maps

Coming Soon

Please login to do the challenges!"; echo "

"; htmlFooter(); return; } $userID = $_SESSION['userID']; if (!hasCompletedTutorial($userID)) { echo "
Please complete the tutorial to unlock Challenge mode!"; htmlFooter(); return; } //TODO: Uncomment //if (!hasCompletedTutorial($userID)) { // echo "
Please complete the tutorial to unlock Challenge mode!"; // htmlFooter(); // return; //} ?> $challengeMap) { $r .= "Section $tier levels:
"; foreach ($challengeMap as $challengeSuborder => $challenge) { //Hack to get the first element of the array: $firstChallenge = $challenge[key($challenge)]; $challengeMapID = $firstChallenge['challengeMapID']; //$mapCode = getMapCode($mapid); //$mapCode = $firstChallenge['mapCode']; //$map = new map($mapCode); //$thumbnail = DisplayMapThumbnail($map); $r .= "
"; //$r .= "$map->name"; //$r .= $thumbnail; $r .= "
\n"; $r .= "
\n"; $r .= ""; foreach ($challenge as $ordering => $content) { //Each challenge gets its own star if($content["dateSolved"] !== NULL) { $cssClass = "challengelist_complete"; $numCompletedChallenges++; } else { $cssClass = "challengelist_incomplete"; } $r .= "
"; } $r .= "
"; //$r .= "END MAP"; } $r .= "
"; } $r .= getNextChallengeTierHtml($numCompletedChallenges); return $r; } function getNextChallengeTierHtml($numCompletedChallenges) { global $tierChallengeRequirements, $userID; for($nextTier = 0; $nextTier < count($tierChallengeRequirements); $nextTier++) { $numChallengesForNextTier = numChallengesRemainingForTier($nextTier, $numCompletedChallenges); if($numChallengesForNextTier > 0) break; } //We've found the tier they're at - verify this matches up with what's in the DB //This probably belongs somewhere else, but whatever $userCurrentTier = getUserChallengeTier($userID); if($userCurrentTier != $nextTier - 1) { //TODO: Display some sort of "tier XY unlocked" or something setUserChallengeTier($userID, $nextTier -1); } //Return the tiers-left html if($numChallengesForNextTier == 0) return "
Next tier unlocked in $numChallengesForNextTier" . "
"; } function numChallengesRemainingForTier($tier, $numCompletedChallenges) { global $tierChallengeRequirements; if($tier >= maxTier()) return -1; if($tierChallengeRequirements[$tier] <= $numCompletedChallenges) return 0; return ($tierChallengeRequirements[$tier] - $numCompletedChallenges); } function maxTier() { global $tierChallengeRequirements; return (count($tierChallengeRequirements) - 1); } // TODO: !! Depreciate /** * Outputs the list of all challenges to the page */ function displayChallengeList($challengeListResultset) { echo '
'; $currentTier = -1; $currentMap = -1; while($challenge = mysql_fetch_array($challengeListResultset)) { //Each challenge gets its own header/table // echo "
L: $currentTier
N: "; // echo $challenge["challengeTier"]; // echo "
"; if($challenge["challengeTier"] != $currentTier) { if($currentTier >= 0) { echo '
'; } $currentTier = $challenge["challengeTier"]; echo "
Tier $currentTier
"; echo "
\n"; } //Each map gets it own row if($challenge["mapID"] != $currentMap) { if($currentMap >= 0) { echo '
'; } $currentMap = $challenge["mapID"]; $mapCode = getMapCode($currentMap); $map = new map($mapCode); $thumbnail = DisplayMapThumbnail($map); $mapName = $map->name; if($mapName == NULL || $mapName == "") $mapName = "(unknown)"; echo "
"; echo "
"; } //Each challenge gets its own star if($challenge["dateSolved"] !== NULL) $cssClass = "challengelist_complete"; else $cssClass = "challengelist_incomplete"; echo "
"; } echo "
"; echo ""; } ?>