From 32cce4bee8a242f7a2e6d6a9e1c9e77b4af87728 Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Wed, 13 Mar 2013 02:26:09 -0700 Subject: Achievement back-end for Insane Speed - and any other 'Extra' unlocks like it. --- pages/achievements.php | 80 ++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 42 deletions(-) (limited to 'pages') diff --git a/pages/achievements.php b/pages/achievements.php index 249077c..a5e56ed 100644 --- a/pages/achievements.php +++ b/pages/achievements.php @@ -20,8 +20,9 @@ else // $userID = 3; $viewer = true; -if ($userID == $_SESSION['userID']) +if ($userID == $_SESSION['userID']) { $viewer = false; +} if ($_GET['apply'] == 'true') { applyCareerMazesAchievements($userID); @@ -69,9 +70,9 @@ echo ""; $debug = false; -if ($_GET['debuglevels'] == 'yes') +if ($_GET['debuglevels'] == 'yes') { $debug = true; - +} if ($_GET['showemblems'] == 'all') { @@ -147,10 +148,11 @@ return("#".substr("000000".dechex($n),-6)); //Self-healing code for unlocks. if (!$viewer) { - applyAchievements($userID, 1); - applyAchievements($userID, 2); - applyAchievements($userID, 3); - applyAchievements($userID, 4); + applyAchievements($userID, ACHIEVEMENT_MOVES_CAREER); + applyAchievements($userID, ACHIEVEMENT_MAZE_CAREER); + applyAchievements($userID, ACHIEVEMENT_MAZE_MASTERY); + applyAchievements($userID, ACHIEVEMENT_CHAMPION_POINTS); + applyAchievements($userID, ACHIEVEMENT_PERFECT_DAY); } ?> @@ -307,8 +309,9 @@ order by maxLevel.type"; $result = mysql_query($sql); if ($result) { - while ($row = mysql_fetch_assoc($result)) + while ($row = mysql_fetch_assoc($result)) { $achievements[$row['type']] = $row; + } } @@ -358,35 +361,41 @@ echo "
$UDisplay"; -function displayUnlockItem($uType, $item) { +function unlockItemAsTD($uType, $item) { $aLevel = $item['aLevel']; $aCompleted = $item['dateUnlocked']; - $aTypeNames[1] = "Path Career Level $aLevel"; - $aTypeNames[2] = "Mazes Career Level $aLevel"; - $aTypeNames[3] = "Maze Mastery Level $aLevel"; - $aTypeNames[4] = "Champion Level $aLevel"; - $aTypeNames[32] = 'Completing Tutorial'; + $aTypeNames[ACHIEVEMENT_MOVES_CAREER] = "Path Career Level $aLevel"; + $aTypeNames[ACHIEVEMENT_MAZE_CAREER] = "Mazes Career Level $aLevel"; + $aTypeNames[ACHIEVEMENT_MAZE_MASTERY] = "Maze Mastery Level $aLevel"; + $aTypeNames[ACHIEVEMENT_CHAMPION_POINTS] = "Champion Level $aLevel"; + $aTypeNames[ACHIEVEMENT_PERFECT_DAY] = "Perfect Days $aLevel"; + $aTypeNames[ACHIEVEMENT_TUTORIAL] = 'Completing Tutorial'; $by = $aTypeNames[$item['aType']]; $on = relative_date(strtotime($aCompleted)); $unlockTitle = "$item[name]. From $by $on"; - if ($item['aType'] == -1) + if ($item['aType'] == -1) { $unlockTitle = "$item[name]"; + } $border = 'border: 1px solid #000; border-width: 2px 0px 2px 0px;'; $border = 'border: 1px solid #000;'; $class = 'grid_td_walls'; + //$r .= displayUnlock($uType, $item[value], $unlockTitle); + //return $r; + switch ($uType) { - case 1: + case 1: if ($GLOBALS['wallColor'] == $item[value]) { $class = 'grid_td_active'; $border = 'border: 1px solid #26b;'; } $r .= ""; break; - case 2: + + case 2: if ($GLOBALS['wallEmblem'] == $item[value]) { $class = 'grid_td_active'; $border = 'border: 1px solid #26b;'; @@ -394,13 +403,18 @@ function displayUnlockItem($uType, $item) { $r .= "
"; break; - case 3: + + case 3: if ($GLOBALS['nameColor'] == $item[value]) $border = 'border: 1px solid #26b;'; $r .= ""; $r .= " $item[name] "; $r .= ""; break; + + case UNLOCK_EXTRAS: + $r .= "$item[name]"; + break; } return $r; } @@ -408,11 +422,12 @@ function displayUnlockItem($uType, $item) { if (isset($unlocks)) { echo "

Unlocks

"; - + //Define some names $uTypeNames[1] = "Wall Colors"; $uTypeNames[2] = "Emblems"; $uTypeNames[3] = "Username Colors"; + $uTypeNames[UNLOCK_EXTRAS] = "Extras"; $uSubtypeNames[1][0] = "Darker"; $uSubtypeNames[1][1] = "Brighter"; @@ -426,7 +441,7 @@ if (isset($unlocks)) { echo "

$uTypeNames[$uType] unlocked:

"; foreach ($unlock as $item) { - $subtype[$item['subtype']][] = displayUnlockItem($uType, $item); + $subtype[$item['subtype']][] = unlockItemAsTD($uType, $item); if ((sizeof($subtype[$item['subtype']]) + 1) % 14 == 0) $subtype[$item['subtype']][] = ''; } @@ -487,13 +502,14 @@ foreach($achievements as $aType => $a) { $aTypeNames[1] = "Path Career Level $aLevel!"; $aTypeNames[2] = "Mazes Career Level $aLevel!"; $aTypeNames[3] = "Maze Mastery Level $aLevel!"; - $aTypeNames[4] = "Champion Level $aLevel!"; + $aTypeNames[ACHIEVEMENT_CHAMPION_POINTS] = "Champion Level $aLevel!"; + $aTypeNames[ACHIEVEMENT_PERFECT_DAY] = "Perfect Day level $aLevel!"; $aTypeNames[32] = 'Tutorial Complete!'; $aTypeCurrency[1] = "total moves mazed"; $aTypeCurrency[2] = "mazes played"; $aTypeCurrency[3] = "mazes with (tied) top score"; - $aTypeCurrency[4] = "champion points"; + $aTypeCurrency[ACHIEVEMENT_CHAMPION_POINTS] = "champion points"; $name = $aTypeNames[$aType]; $currency = $aTypeCurrency[$aType]; @@ -543,26 +559,6 @@ foreach($achievements as $aType => $a) { } -function displayUnlock($uType, $uValue, $uName) { - switch ($uType) { - case 1: - $r .= "$uName Wall Color!"; - $r .= "
"; - break; - case 2: - $r .= "$uName Emblem!"; - $r .= "
"; - //$r .= "
"; - $r .= "
"; - break; - case 3: - $r .= "
$uName Username color!"; - break; - } - return $r; -} - - ?> -- cgit v1.2.3