diff options
Diffstat (limited to 'pages')
-rw-r--r-- | pages/challenge.php | 24 | ||||
-rw-r--r-- | pages/challengelist.php | 103 |
2 files changed, 121 insertions, 6 deletions
diff --git a/pages/challenge.php b/pages/challenge.php index 6990644..2ab279d 100644 --- a/pages/challenge.php +++ b/pages/challenge.php @@ -53,6 +53,11 @@ if (getCookie('pref_mute') != 'true') { var isChallenge = true;
playerWallColor = '<?PHP echo isset($wallColor) ? $wallColor : ''; ?>';
playerWallEmblem = '<?PHP echo isset($wallEmblem) ? $wallEmblem : ''; ?>';
+
+//Legacy functions
+function challengeLoad() {}
+function challengeWall() {}
+function challengeGo() {}
</script>
<?php
@@ -78,22 +83,22 @@ if (!$accepted) { if(!isset($_GET["mapID"]))
{
- //TODO: Redirect to challenge listing
+ redirectToChallengeListing();
return;
}
$mapCode = loadMapCode($_GET["mapID"]);
if($mapCode === NULL)
{
- //TODO: Redirect to challenge listing also
+ redirectToChallengeListing();
return;
}
-$mapContent = displayMap(GenerateMapByCode($mapCode), 1);
+$mapContent = displayMap(GenerateMapByCode($mapCode), $_GET["mapID"]);
$challengeResultset = loadChallengesForMap($_GET["mapID"], $userID);
if($challengeResultset === NULL)
{
- //TODO: Redirect to challenge listing also
+ redirectToChallengeListing();
return;
}
@@ -130,12 +135,13 @@ function displayChallenges($challengeResultset) echo '<div id="challenges_listing"><ol>';
while($challenge = mysql_fetch_array($challengeResultset))
{
+ $challengeId = $challenge["challengeID"];
echo "<li>";
- if($challenge["dateCompleted"] !== NULL)
+ if($challenge["dateSolved"] !== NULL)
$cssClass = "challenge_complete";
else
$cssClass = "challenge_incomplete";
- echo "<span class='$cssClass'>" . getChallengeDisplayString($challenge) . "</span>";
+ echo "<span class='$cssClass' id='challenge_id_$challengeId'>" . getChallengeDisplayString($challenge) . "</span>";
echo "</li>";
}
echo "</ol></div></div>";
@@ -228,4 +234,10 @@ function getChallengeDisplayString($challenge) $returnMe .= ".";
return $returnMe;
}
+
+function redirectToChallengeListing()
+{
+ header("Location: /challengelist");
+ die();
+}
?>
\ No newline at end of file diff --git a/pages/challengelist.php b/pages/challengelist.php new file mode 100644 index 0000000..e3f057a --- /dev/null +++ b/pages/challengelist.php @@ -0,0 +1,103 @@ +<?php +ob_start("ob_gzhandler"); +htmlHeader( + array('tutorial', 'challenge'), 'Pathery Challenges', + 'Challenges', array('scores', 'dateformat') +); + +include_once ('./includes/maps.php'); +include_once ('./includes/mapoftheday.php'); +include_once ('./includes/db.inc.php'); +include_once ('./includes/datas.php'); + +topbar($Links); +?> + +<div id="challengelist_wrapper" class="wrapper"> + +<? + +//Check that the user is allowed to do the challenges +if (!$accepted) { + echo "<center>Please <a href='login'>login</a> to do the challenges!</div>"; + htmlFooter(); + return; +} +$userID = $_SESSION['userID']; + +//TODO: Uncomment +//if (!hasCompletedTutorial($userID)) { +// echo "<center>Please <a href='tutorial'>complete the tutorial</a> to unlock Challenge mode!</div>"; +// htmlFooter(); +// return; +//} + +?> + <noscript>Sorry, this game requires scripts to run. Please enable javascript and <a href='home'>Reload this site</a> + <br />This game is best viewed in <a href='http://www.google.com/chrome'>Google Chrome</a> + </noscript> +<? + +//Display the actual challenge list +$challengeListResultset = loadChallengeListing($userID); +displayChallengeList($challengeListResultset); + +?> +</div> + +<div id="copy" style='width:100%;clear: both'> + Copyright © 2011-2012 pathery.com +</div> + +<?php +htmlFooter(); +?> + +<?php +/** + * Outputs the list of all challenges to the page + */ +function displayChallengeList($challengeListResultset) +{ + echo '<div id="challengelist">'; + $currentTier = -1; + $currentMap = -1; + while($challenge = mysql_fetch_array($challengeListResultset)) + { + //Each challenge gets its own header/table + if($challenge["challengeTier"] != $currentTier) + { + if($currentTier >= 0) + { + echo '</table>'; + } + $currentTier = $challenge["challengeTier"]; + echo "<div class='challengelist_tier'>Tier $currentTier</div>"; + echo "<table class='challengelist_table'>"; + } + + //Each map gets it own row + if($challenge["mapID"] != $currentMap) + { + if($currentMap >= 0) + { + echo '</td></tr>'; + } + $currentMap = $challenge["mapID"]; + $mapName = $challenge["challengeName"]; + if($mapName == NULL || $mapName == "") + $mapName = "(unknown)"; + echo "<tr><td class='challengelist_link'><a href='challenge?mapID=$currentMap'>$mapName</a></td>"; + echo "<td class='challengelist_stars'>"; + } + + //Each challenge gets its own star + if($challenge["dateSolved"] !== NULL) + $cssClass = "challengelist_complete"; + else + $cssClass = "challengelist_incomplete"; + echo "<div class='$cssClass'></div>"; + } + echo "</td></tr></table>"; +} +?>
\ No newline at end of file |