diff options
author | BlueRaja <BlueRaja.admin@gmail.com> | 2013-01-25 19:27:51 -0600 |
---|---|---|
committer | BlueRaja <BlueRaja.admin@gmail.com> | 2013-01-25 19:27:51 -0600 |
commit | aeacdd6ac410d4b576cf9e804d709cd64fa00384 (patch) | |
tree | 44fd65a626b44eb5e099e2cf2525ef11cef20def /includes | |
parent | fed89ebc174dda0963856f992f6f9a26bbe1b182 (diff) | |
download | pathery-aeacdd6ac410d4b576cf9e804d709cd64fa00384.tar.xz |
Tiers are now unlocked as the user players through challenges; challenges left to next tier displayed on challengelist page
(untested)
Diffstat (limited to 'includes')
-rw-r--r-- | includes/constants.php | 6 | ||||
-rw-r--r-- | includes/datas.php | 43 |
2 files changed, 35 insertions, 14 deletions
diff --git a/includes/constants.php b/includes/constants.php index 0658725..7774aa4 100644 --- a/includes/constants.php +++ b/includes/constants.php @@ -68,4 +68,10 @@ class MapType const Special = 4; const Weekly = 5; } + +/** + * Required number of challenges beaten to move up to each tier. + * Make sure the first one is always 0... + */ +$tierChallengeRequirements = array(0, 5, 10, 15, 20, 25, 30); ?> 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); |