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. --- includes/datas.php | 92 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 63 insertions(+), 29 deletions(-) (limited to 'includes/datas.php') diff --git a/includes/datas.php b/includes/datas.php index 74487fd..7e64732 100644 --- a/includes/datas.php +++ b/includes/datas.php @@ -19,7 +19,7 @@ function getNotified($userID) { FROM `achievements` WHERE `notified` = false AND userID = '$userID' - LIMIT 25"; + LIMIT 5"; $resultA = mysql_query($sql); if (mysql_num_rows($resultA) <= 0) @@ -54,20 +54,7 @@ function getNotified($userID) { if (mysql_num_rows($result) >= 1) { $unlocked = "You've unlocked: "; while (list($uType, $uName, $uValue) = mysql_fetch_row($result)) { - switch ($uType) { - case 1: - $unlocked .= "$uName Wall Color!"; - $unlocked .= "
"; - break; - case 2: - $unlocked .= "$uName Emblem!"; - $unlocked .= "
"; - $unlocked .= "
"; - break; - case 3: - $unlocked .= "
$uName Username color!
"; - break; - } + $unlocked .= displayUnlock($uType, $uValue, $uName); } } // ---------- Prepare response @@ -110,6 +97,32 @@ function getNotified($userID) { // ---------- Done! } +function displayUnlock($uType, $uValue, $uName) { + switch ($uType) { + case UNLOCK_WALL_COLOR: + $r .= "$uName Wall Color!"; + $r .= "
"; + break; + + case UNLOCK_WALL_EMBLEM: + $r .= "$uName Emblem!"; + $r .= "
"; + //$r .= "
"; + $r .= "
"; + break; + + case UNLOCK_DISPLAY_COLOR: + $r .= "
$uName Username color!"; + break; + + case UNLOCK_EXTRAS: + $r .= "Extras: $uName"; + break; + } + return $r; +} + + //Returns true when an achievement is applied. // Usage example: applyCareerAchievement($userID); // TODO: DEPRECIATED @@ -531,13 +544,25 @@ function getAchievementCurrency($userID, $aType) { $sql = "SELECT championPoints FROM `users` WHERE `ID` = '$userID'"; + break; + case 5: + $sql = "SELECT count(*) + FROM solutions + INNER JOIN mapOfTheDay ON solutions.mapID = mapOfTheDay.mapID + WHERE mapOfTheDay.mapType + IN ( 1, 2, 3, 4 ) + AND solutions.userID = '$userID' + GROUP BY solutions.userID, mapOfTheDay.mapDate + HAVING COUNT( isTiedForHighScore ) = 4"; + $result = mysql_query($sql) OR die("SQL query failed; $sql"); + return mysql_num_rows($result); break; } - if ($sql == '') - return false; + if ($sql == '') return false; $result = mysql_query($sql) OR die("SQL query failed; $sql"); - if (mysql_num_rows($result) == 1) + if (mysql_num_rows($result) == 1) { list($r) = mysql_fetch_row($result); + } return $r; } @@ -552,22 +577,20 @@ function getAchievementLevel($userID, $aType) { ORDER BY `level` DESC LIMIT 1"; $result = mysql_query($sql); - if (mysql_num_rows($result) == 1) + if (mysql_num_rows($result) == 1) { list($r) = mysql_fetch_row($result); + } return $r; } function getAchievementsArray($type) { - if ($type == 1) - return getCareerPathArray(); - if ($type == 2) - return getCareerMazesArray(); - if ($type == 3) - return getMazeMasteryArray(); - if ($type == 4) - return getChampionPointsArray(); + if ($type == ACHIEVEMENT_MOVES_CAREER) return getCareerPathArray(); + if ($type == ACHIEVEMENT_MAZE_CAREER) return getCareerMazesArray(); + if ($type == ACHIEVEMENT_MAZE_MASTERY) return getMazeMasteryArray(); + if ($type == ACHIEVEMENT_CHAMPION_POINTS) return getChampionPointsArray(); + if ($type == ACHIEVEMENT_PERFECT_DAY) return getPerfectDayArray(); //Tutorial - if ($type == 32) { + if ($type == ACHIEVEMENT_TUTORIAL) { $r[1] = array(1, 1, '#4444ff', 'Blue'); return $r; } @@ -655,11 +678,22 @@ function getChampionPointsArray() { $r[7] = array(8000, 2, 'CrossXLDonut_B_I.png', 'Inverted Dark Large Intersection', 0); $r[8] = array(16000, 2, 'DiamondLarge_B.png', 'Dark Large Diamond', 0); $r[9] = array(32000, 1, '#22ff22', 'Neon Lime', 1); - //$r[7] = array(75, 2, 'CircleSmall_W_I.png', 'Inverted Bright Small Circle', 0); return $r; } +//TYPE 5 +function getPerfectDayArray() { + //$cp[0] = array(requiredpoints, type, 'value', 'name'); + $r[1] = array(1, UNLOCK_EXTRAS, MISC_UNLOCK_INSANE_SPEED, 'Insane Speed'); + //These numbers temporarly unreasonable + $r[2] = array(9275, UNLOCK_WALL_EMBLEM, 'CircleSmall_W_I.png', 'Inverted Bright Small Circle', 0); + $r[3] = array(10000, UNLOCK_WALL_EMBLEM, 'DiamondLarge_W_I.png', 'Inverted Light Large Diamond', 0); + + return $r; +} + + //Select Members function getMembers($pageNumber = 1, $pageDivide = 50, $order = 'DESC', $orderBy = 'dateJoined') { -- cgit v1.2.3 From d26206b8dfb2f6c9775c0a7f111e0d4caed53fe7 Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Wed, 13 Mar 2013 02:57:50 -0700 Subject: Insane speed achievement front end. --- includes/datas.php | 17 ++++++++++++++++- includes/header.php | 15 ++++++++++++--- js/mapspecs.js | 2 +- 3 files changed, 29 insertions(+), 5 deletions(-) (limited to 'includes/datas.php') diff --git a/includes/datas.php b/includes/datas.php index 7e64732..83399c7 100644 --- a/includes/datas.php +++ b/includes/datas.php @@ -684,8 +684,9 @@ function getChampionPointsArray() { //TYPE 5 function getPerfectDayArray() { + //($required, $unlockType, $unlockValue, $unlockName, $unlockSubtype) //$cp[0] = array(requiredpoints, type, 'value', 'name'); - $r[1] = array(1, UNLOCK_EXTRAS, MISC_UNLOCK_INSANE_SPEED, 'Insane Speed'); + $r[1] = array(1, UNLOCK_EXTRAS, '5', 'Insane Speed', MISC_UNLOCK_INSANE_SPEED); //These numbers temporarly unreasonable $r[2] = array(9275, UNLOCK_WALL_EMBLEM, 'CircleSmall_W_I.png', 'Inverted Bright Small Circle', 0); $r[3] = array(10000, UNLOCK_WALL_EMBLEM, 'DiamondLarge_W_I.png', 'Inverted Light Large Diamond', 0); @@ -941,6 +942,20 @@ function hasCompletedTutorial($userID) { return (mysql_num_rows($result) >= 1); } +function hasExtrasUnlock($userID, $unlockType, $unlockSubtype) { + $userID = mysql_escape_string($userID); + $unlockType = mysql_escape_string($unlockType); + $unlockSubtype = mysql_escape_string($unlockSubtype); + + $sql = "SELECT `value` FROM `unlocks` + WHERE `userID` = '$userID' + AND `type` = '$unlockType' + AND `subtype` = '$unlockSubtype' + LIMIT 1"; + $result = mysql_query($sql); + return (mysql_num_rows($result) >= 1); +} + /** * Returns a MySQL resultset for all challenges for the given mapID * @param $mapIdUnsanitized The mapID to load. Assumed to be unsanitized. diff --git a/includes/header.php b/includes/header.php index cf427e4..5f0f679 100644 --- a/includes/header.php +++ b/includes/header.php @@ -203,11 +203,20 @@ function userDataToJS() { global $wallColor, $wallEmblem, $accepted; if (!$accepted) { $r = 'var userObj = {"wallColor":false,"wallEmblem":false,'; - $r .= '"ID":"-1","accepted":false};'; + $r .= '"ID":"-1","accepted":false,"hasInsaneSpeed":false};'; } else { $userID = $_SESSION['userID']; - $r = 'var userObj = {"wallColor":"'.$wallColor.'","wallEmblem":"'.$wallEmblem.'",'; - $r .= '"ID":"'.$userID.'","accepted":true};'; + $hasInsaneSpeed = hasExtrasUnlock($userID, UNLOCK_EXTRAS, MISC_UNLOCK_INSANE_SPEED); + $r .= 'hasInsaneSpeed":'.$hasInsaneSpeed.'};'."\n"; + $json = array('ID' => 'fat'); + $json['ID'] = $userID; + $json['wallColor'] = $wallColor; + $json['wallEmblem'] = $wallEmblem; + $json['hasInsaneSpeed'] = $hasInsaneSpeed; + $json['accepted'] = 'true'; + + $encoded = json_encode($json); + $r = 'var userObj = decryptJSON(\''.json_encode($json).'\');'."\n"; } return $r; } diff --git a/js/mapspecs.js b/js/mapspecs.js index dbb1c60..5a124b1 100644 --- a/js/mapspecs.js +++ b/js/mapspecs.js @@ -1013,7 +1013,7 @@ function getSpeedOptions(mapID) { listObj[2] = 'Med'; listObj[3] = 'Fast'; listObj[4] = 'Ultra'; - listObj[5] = 'Insane'; + if (userObj.hasInsaneSpeed) listObj[5] = 'Insane'; var r = ''; r += " $item[name] "; + $r .= ""; + break; case UNLOCK_EXTRAS: $r .= "$item[name]"; @@ -424,16 +464,17 @@ if (isset($unlocks)) { echo "

Unlocks

"; //Define some names - $uTypeNames[1] = "Wall Colors"; - $uTypeNames[2] = "Emblems"; - $uTypeNames[3] = "Username Colors"; + $uTypeNames[UNLOCK_WALL_COLOR] = "Wall Colors"; + $uTypeNames[UNLOCK_WALL_EMBLEM] = "Emblems"; + $uTypeNames[UNLOCK_DISPLAY_COLOR] = "Username Colors"; + $uTypeNames[UNLOCK_WALL_ORIENTATION] = "Emblem Rotations"; $uTypeNames[UNLOCK_EXTRAS] = "Extras"; - $uSubtypeNames[1][0] = "Darker"; - $uSubtypeNames[1][1] = "Brighter"; + $uSubtypeNames[UNLOCK_WALL_COLOR][0] = "Darker"; + $uSubtypeNames[UNLOCK_WALL_COLOR][1] = "Brighter"; - $uSubtypeNames[2][0] = "Simple"; - $uSubtypeNames[2][1] = "Complicated"; + $uSubtypeNames[UNLOCK_WALL_EMBLEM][0] = "Simple"; + $uSubtypeNames[UNLOCK_WALL_EMBLEM][1] = "Complicated"; //For every unlock type that the user has. foreach ($unlocks as $uType => $unlock) { @@ -463,6 +504,7 @@ echo "
"; if (!$viewer) { + //TODO add wall orientation echo "
@@ -470,6 +512,8 @@ if (!$viewer) { + + diff --git a/pages/chat.php b/pages/chat.php index 5be6689..68a0abf 100644 --- a/pages/chat.php +++ b/pages/chat.php @@ -101,7 +101,7 @@ function getChatDone(data) { p = ''; p = p+ "
"; p = p+ " ["+timestamp+"]"; - p = p+ "
"; + p = p+ "
"; p = p+ "
"; p = p+ "
"; p = p+ "
"; -- cgit v1.2.3