summaryrefslogtreecommitdiffstats
path: root/pages
diff options
context:
space:
mode:
authorBlueRaja <BlueRaja.admin@gmail.com>2013-01-25 20:31:34 -0600
committerBlueRaja <BlueRaja.admin@gmail.com>2013-01-25 20:31:34 -0600
commit1e65273d68ffdec07f49c14e929499af21f7776a (patch)
treeb96bc71d1645a66cc2754996fcecba71dfcd596c /pages
parentf20d2221d1da6f7e1d3b7126261ee320ed0158b2 (diff)
parent8a276a1857bc28677ac43c083d44a0ce5bf63343 (diff)
downloadpathery-1e65273d68ffdec07f49c14e929499af21f7776a.tar.xz
Merge branch 'doin_shit_on_laptop'
Conflicts: includes/datas.php also fixed some stuffs
Diffstat (limited to 'pages')
-rw-r--r--pages/challenge.php14
-rw-r--r--pages/challengelist.php66
-rw-r--r--pages/chat.php9
3 files changed, 76 insertions, 13 deletions
diff --git a/pages/challenge.php b/pages/challenge.php
index 4e5c50c..84b401b 100644
--- a/pages/challenge.php
+++ b/pages/challenge.php
@@ -69,16 +69,16 @@ topbar($Links);
//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>";
+ echo "<center>Please <a href='login'>login</a> to do the challenges!</center></div>";
+ htmlFooter();
+ return;
+}
+
+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>";
-// htmlFooter();
-// return;
-//}
if(!isset($_GET["challengeMapID"]) OR !is_int($_GET["challengeMapID"] + 0))
{
diff --git a/pages/challengelist.php b/pages/challengelist.php
index 364209f..ade47b6 100644
--- a/pages/challengelist.php
+++ b/pages/challengelist.php
@@ -9,6 +9,7 @@ include_once ('./includes/mapoftheday.php');
include_once ('./includes/sqlEmbedded.php');
include_once ('./includes/datas.php');
include_once ('./includes/mapclass.php');
+include_once ('./includes/constants.php');
topbar($Links);
?>
@@ -25,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>";
@@ -43,7 +51,7 @@ $userID = $_SESSION['userID'];
//Display the actual challenge list
$challengeListResultset = loadChallengeListing($userID);
//displayChallengeList($challengeListResultset);
-echo ChallengeList($challengeListResultset);
+echo getChallengeListHtml($challengeListResultset);
?>
@@ -55,7 +63,7 @@ htmlFooter();
<?php
-function ChallengeList($challengeListResultset) {
+function getChallengeListHtml($challengeListResultset) {
//First gather data to a more useful form.
$r = '';
while($data = mysql_fetch_array($challengeListResultset)) {
@@ -65,6 +73,7 @@ function ChallengeList($challengeListResultset) {
$challenges[$tier][$challengeSuborder][$ordering] = $data;
}
+ $numCompletedChallenges = 0;
foreach ($challenges as $tier => $challengeMap) {
$r .= "<b>Section $tier</b> levels:<div class='challengelist_tier' style='border: 1px solid yellow; overflow: auto;'>";
foreach ($challengeMap as $challengeSuborder => $challenge) {
@@ -84,9 +93,14 @@ function ChallengeList($challengeListResultset) {
foreach ($challenge as $ordering => $content) {
//Each challenge gets its own star
if($content["dateSolved"] !== NULL)
+ {
$cssClass = "challengelist_complete";
+ $numCompletedChallenges++;
+ }
else
+ {
$cssClass = "challengelist_incomplete";
+ }
$r .= "<div class='$cssClass'></div>";
}
$r .= "</div>";
@@ -94,9 +108,57 @@ function ChallengeList($challengeListResultset) {
}
$r .= "</div>";
}
+
+ $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 "<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>";
+}
+
+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
diff --git a/pages/chat.php b/pages/chat.php
index 094f86a..5ecbaab 100644
--- a/pages/chat.php
+++ b/pages/chat.php
@@ -247,10 +247,11 @@ function htmlEncode(value){
<div class='chatContainer2'>
<form id='sendChat' onsubmit="return false">
- <input type="hidden" name="stuff" value="1724">
- <input class='chatButton' type="button" class="send" id='chatSendBtn' value='Send' onClick="sendChat();">
- <input class='chatInputMessage' type="text" name="message" id="message" value="" maxlength="255" autocomplete="off" >
-
+ <? if($accepted) { /*Only show the chat button if we're logged in*/ ?>
+ <input type="hidden" name="stuff" value="1724">
+ <input class='chatButton' type="button" class="send" id='chatSendBtn' value='Send' onClick="sendChat();">
+ <input class='chatInputMessage' type="text" name="message" id="message" value="" maxlength="255" autocomplete="off" >
+ <? } ?>
</form>
<div id='chatContainer'>