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(-) 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 += "