diff options
Diffstat (limited to 'includes/datas.php')
-rw-r--r-- | includes/datas.php | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/includes/datas.php b/includes/datas.php index 62f664e..11a130c 100644 --- a/includes/datas.php +++ b/includes/datas.php @@ -3,6 +3,7 @@ // include_once('sqlEmbedded.php'); +include_once('constants.php'); //FirePHP stuff - TODO: Delete //require_once('includes/FirePHPCore/FirePHP.class.php'); @@ -114,7 +115,7 @@ function getNotified($userID) { $aTypeCurrency[1] = "total moves mazed"; $aTypeCurrency[2] = "mazes played"; $aTypeCurrency[3] = "mazes with (tied) top score"; - $aTypeCurrency[4] = "challenge points"; + $aTypeCurrency[4] = "champion points"; $aName = $aTypeNames[$aType]; $currency = $aTypeCurrency[$aType]; @@ -303,8 +304,6 @@ function applyCareerMazesAchievements($userID) { */ function getCompletedChallenges($userID, $mapID, $solution, $moves, $paths) { //mapID 5 is the tutorial, and is treated specially - //$firephp = FirePHP::getInstance(true); - //$firephp->log("In challenges"); if($mapID <= 10) { if ($mapID == 5 && $moves == 75) { onCompletedTutorial($userID); @@ -312,25 +311,17 @@ function getCompletedChallenges($userID, $mapID, $solution, $moves, $paths) { return; } - //$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"); //Skip checking challenges which have already been completed if($challenge["dateSolved"] !== NULL) { - //$firephp->log('Challenge was already completed'); $challengesCompleted[] = $challenge["challengeID"]; } else if(hasChallengeBeenCompleted($challenge, $solution, $moves, $paths)) { - //$firephp->log('Challenge was completed!'); setChallengeCompleted($challenge, $solution, $userID, $moves); $challengesCompleted[] = $challenge["challengeID"]; } @@ -517,9 +508,7 @@ function setChallengeCompleted($challenge, $solution, $userID, $moves) { mysql_query($sql); } - function isChallengeMap($mapID) { - include_once('./includes/sqlEmbedded.php'); $sql = "SELECT ID FROM `maps` WHERE @@ -529,6 +518,31 @@ function isChallengeMap($mapID) { return (mysql_num_rows($result) != 0); } +function getUserChallengeTier($userID) +{ + $userID = mysql_escape_string($userID); + + $sql = "SELECT challengeTier + FROM users + WHERE users.ID = '$userID'"; + + $result = mysql_query($sql); + $row = mysql_fetch_row($result); + return $row[0]; +} + +function setUserChallengeTier($userID, $challengeTier) +{ + $userID = mysql_escape_string($userID); + $challengeTier = mysql_escape_string($challengeTier); + + $sql = "UPDATE users + SET challengeTier = '$challengeTier' + WHERE users.ID = '$userID'"; + + mysql_query($sql); +} + function applyAchievements($userID, $aType) { $amount = getAchievementCurrency($userID, $aType); @@ -1079,9 +1093,10 @@ function loadChallengeListing($userIdUnsanitized) challengeSolutions.dateSolved, challengeSolutions.challengeID AS challengeID, maps.challengeSuborder, challenges.ordering FROM challenges - LEFT JOIN maps ON challenges.mapID = maps.ID + INNER JOIN maps ON challenges.mapID = maps.ID LEFT JOIN challengeSolutions ON challenges.ID = challengeSolutions.challengeID AND challengeSolutions.userID = '$userID' WHERE challenges.enabled = 1 + AND maps.challengeTier <= (SELECT challengeTier FROM users WHERE ID = '$userID') ORDER BY maps.challengeTier, maps.challengeSuborder, challenges.ordering"; $result = mysql_query($sql); |