mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-19 09:37:50 -05:00
Brought up to date with the private repository (feea4c7)
This commit is contained in:
1 parent
1aa738d692
commit
1b1df1ae48
7925 files changed
+2617237
-20
No files matched your search
@@ -0,0 +1,278 @@
|
||||
package achievement
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import loader.MediaHelper;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class Achievement
|
||||
{
|
||||
|
||||
public static var GEMS_EARNED:int = 1;
|
||||
|
||||
public static var GEMS_SPENT:int = 2;
|
||||
|
||||
public static var SHOP_DEN_ITEM:int = 3;
|
||||
|
||||
public static var SHOP_ACCESSORY:int = 4;
|
||||
|
||||
public static var MAIL_SEND:int = 38;
|
||||
|
||||
public static var MAIL_GIFT:int = 39;
|
||||
|
||||
public static var BUDDY_ADDED:int = 40;
|
||||
|
||||
public static var MEMBER_NEW:int = 66;
|
||||
|
||||
public static var HOLIDAY_BANNER:int = 409;
|
||||
|
||||
public static var BASE_MEDAL_ID:int = 289;
|
||||
|
||||
public static var BASE_RIBBON_ID:int = 290;
|
||||
|
||||
public static var BASE_TROPHY_ID:int = 291;
|
||||
|
||||
private var _invId:int;
|
||||
|
||||
private var _baseImageMediaId:int;
|
||||
|
||||
private var _iconMediaId:int;
|
||||
|
||||
private var _name:String;
|
||||
|
||||
private var _descr:String;
|
||||
|
||||
private var _mediaText:String;
|
||||
|
||||
private var _nameId:int;
|
||||
|
||||
private var _descId:int;
|
||||
|
||||
private var _type:int;
|
||||
|
||||
private var _defId:int;
|
||||
|
||||
private var _userVarId:int;
|
||||
|
||||
private var _baseImage:Sprite;
|
||||
|
||||
private var _baseImageHelper:MediaHelper;
|
||||
|
||||
private var _icon:Sprite;
|
||||
|
||||
private var _iconHelper:MediaHelper;
|
||||
|
||||
private var _baseImageReceived:Boolean;
|
||||
|
||||
private var _iconReceived:Boolean;
|
||||
|
||||
private var _shouldUseFullScale:Boolean;
|
||||
|
||||
private var _scalePercent:Number = 1;
|
||||
|
||||
private var _xPos:Number = 0;
|
||||
|
||||
private var _yPos:Number = 0;
|
||||
|
||||
public function Achievement()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function init(param1:int, param2:int, param3:Boolean = false) : void
|
||||
{
|
||||
var _loc4_:Array = null;
|
||||
_invId = param1;
|
||||
_defId = param2;
|
||||
var _loc5_:Object = AchievementManager.getAchievementDef(_defId);
|
||||
if(_loc5_)
|
||||
{
|
||||
_userVarId = _loc5_.userVarRef;
|
||||
_baseImageMediaId = _loc5_.baseMediaRef;
|
||||
_iconMediaId = _loc5_.iconMediaRef;
|
||||
_nameId = _loc5_.titleStrRef;
|
||||
_name = LocalizationManager.translateIdOnly(_nameId);
|
||||
_mediaText = _loc5_.extraText;
|
||||
if(_mediaText != "")
|
||||
{
|
||||
_loc4_ = _mediaText.split(",");
|
||||
if(_loc4_.length > 1)
|
||||
{
|
||||
_mediaText = Utility.convertNumberToString(int(_loc4_.join("")));
|
||||
}
|
||||
}
|
||||
_descId = _loc5_.descStrRef;
|
||||
_descr = LocalizationManager.translateIdOnly(_descId);
|
||||
_type = _loc5_.type;
|
||||
_shouldUseFullScale = param3;
|
||||
_baseImage = new Sprite();
|
||||
_baseImageHelper = new MediaHelper();
|
||||
_baseImageHelper.init(_baseImageMediaId,baseImageReceived);
|
||||
_icon = new Sprite();
|
||||
_iconHelper = new MediaHelper();
|
||||
_iconHelper.init(_iconMediaId,iconReceived);
|
||||
return;
|
||||
}
|
||||
throw new Error("Could not find achievement def");
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
if(_iconHelper)
|
||||
{
|
||||
_iconHelper.destroy();
|
||||
}
|
||||
if(_baseImageHelper)
|
||||
{
|
||||
_baseImageHelper.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
public function clone() : Achievement
|
||||
{
|
||||
var _loc1_:Achievement = null;
|
||||
_loc1_ = new Achievement();
|
||||
_loc1_.init(_invId,_defId,_shouldUseFullScale);
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public function setScale(param1:Number) : void
|
||||
{
|
||||
_scalePercent = param1;
|
||||
if(_iconReceived && _baseImageReceived)
|
||||
{
|
||||
_baseImage.scaleX = _scalePercent;
|
||||
_baseImage.scaleY = _scalePercent;
|
||||
}
|
||||
}
|
||||
|
||||
public function setPosition(param1:Number, param2:Number) : void
|
||||
{
|
||||
_xPos = param1;
|
||||
_yPos = param2;
|
||||
if(_iconReceived && _baseImageReceived)
|
||||
{
|
||||
_baseImage.x = -_baseImage.width * _xPos;
|
||||
_baseImage.y = -_baseImage.height * _yPos;
|
||||
}
|
||||
}
|
||||
|
||||
private function baseImageReceived(param1:MovieClip) : void
|
||||
{
|
||||
var _loc2_:Number = NaN;
|
||||
if(param1)
|
||||
{
|
||||
param1 = MovieClip(param1.getChildAt(0));
|
||||
_baseImage.addChild(param1);
|
||||
if(_iconReceived)
|
||||
{
|
||||
param1.itemBlock.addChild(_icon);
|
||||
allImagesLoaded();
|
||||
}
|
||||
if(_mediaText == "")
|
||||
{
|
||||
param1.num.visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
param1.num.txt.text = _mediaText;
|
||||
_loc2_ = Number(param1.num.txt.textWidth);
|
||||
if(_loc2_ > 15)
|
||||
{
|
||||
if(_loc2_ > 25)
|
||||
{
|
||||
param1.num.gotoAndStop(3);
|
||||
}
|
||||
else
|
||||
{
|
||||
param1.num.gotoAndStop(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
_baseImageHelper.destroy();
|
||||
_baseImageHelper = null;
|
||||
_baseImageReceived = true;
|
||||
}
|
||||
}
|
||||
|
||||
private function iconReceived(param1:MovieClip) : void
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
_icon.addChild(param1);
|
||||
if(_baseImageReceived)
|
||||
{
|
||||
MovieClip(_baseImage.getChildAt(0)).itemBlock.addChild(_icon);
|
||||
allImagesLoaded();
|
||||
}
|
||||
_iconHelper.destroy();
|
||||
_iconHelper = null;
|
||||
_iconReceived = true;
|
||||
}
|
||||
}
|
||||
|
||||
private function allImagesLoaded() : void
|
||||
{
|
||||
var _loc1_:Number = 0.9;
|
||||
if(_shouldUseFullScale)
|
||||
{
|
||||
_loc1_ = 1;
|
||||
}
|
||||
_baseImage.scaleX = _loc1_ * _scalePercent;
|
||||
_baseImage.scaleY = _loc1_ * _scalePercent;
|
||||
_baseImage.x = -_baseImage.width * _xPos;
|
||||
_baseImage.y = -_baseImage.height * _yPos;
|
||||
}
|
||||
|
||||
public function get invId() : int
|
||||
{
|
||||
return _invId;
|
||||
}
|
||||
|
||||
public function get baseImageMediaId() : int
|
||||
{
|
||||
return _baseImageMediaId;
|
||||
}
|
||||
|
||||
public function get iconMediaId() : int
|
||||
{
|
||||
return _iconMediaId;
|
||||
}
|
||||
|
||||
public function get name() : String
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public function get descr() : String
|
||||
{
|
||||
return _descr;
|
||||
}
|
||||
|
||||
public function get mediaText() : String
|
||||
{
|
||||
return _mediaText;
|
||||
}
|
||||
|
||||
public function get image() : Sprite
|
||||
{
|
||||
return _baseImage;
|
||||
}
|
||||
|
||||
public function get type() : int
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
public function get defId() : int
|
||||
{
|
||||
return _defId;
|
||||
}
|
||||
|
||||
public function get userVarId() : int
|
||||
{
|
||||
return _userVarId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,280 @@
|
||||
package achievement
|
||||
{
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.utils.Timer;
|
||||
import loader.MediaHelper;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class AchievementManager
|
||||
{
|
||||
|
||||
private static const ACHIEVEMENT_POPUP_MEDIA_ID:int = 2721;
|
||||
|
||||
private static const STATE_IDLE:int = 0;
|
||||
|
||||
private static const STATE_DISPLAYING:int = 1;
|
||||
|
||||
private static var _newAchievements:Array;
|
||||
|
||||
private static var _finishedCallbacks:Array;
|
||||
|
||||
private static var _achievementDefs:Object;
|
||||
|
||||
private static var _achievementDefsIndexed:Object;
|
||||
|
||||
private static var _sortedTypeNames:Array;
|
||||
|
||||
private static var _allAchievementsIndexed:Object;
|
||||
|
||||
private static var _popupMediaHelper:MediaHelper;
|
||||
|
||||
private static var _achievementPopup:MovieClip;
|
||||
|
||||
private static var _achievementImg:Sprite;
|
||||
|
||||
private static var _popupDisplayTimer:Timer;
|
||||
|
||||
private static var _popupDelayTimer:Timer;
|
||||
|
||||
private static var _state:int;
|
||||
|
||||
private static var _fpsLayer:DisplayObjectContainer;
|
||||
|
||||
public function AchievementManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init(param1:DisplayObjectContainer) : void
|
||||
{
|
||||
_fpsLayer = param1;
|
||||
_finishedCallbacks = [];
|
||||
_newAchievements = [];
|
||||
_popupDisplayTimer = new Timer(3000);
|
||||
_popupDelayTimer = new Timer(500);
|
||||
_state = 0;
|
||||
}
|
||||
|
||||
public static function destroy() : void
|
||||
{
|
||||
_newAchievements.splice(0,_newAchievements.length);
|
||||
_newAchievements = null;
|
||||
_finishedCallbacks.splice(0,_finishedCallbacks.length);
|
||||
_finishedCallbacks = null;
|
||||
if(_popupDisplayTimer)
|
||||
{
|
||||
_popupDisplayTimer.stop();
|
||||
_popupDisplayTimer = null;
|
||||
}
|
||||
if(_popupDelayTimer)
|
||||
{
|
||||
_popupDelayTimer.stop();
|
||||
_popupDelayTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static function hasAchievement() : Boolean
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function displayNewAchievements(param1:Function = null) : void
|
||||
{
|
||||
if(param1 != null)
|
||||
{
|
||||
if(_finishedCallbacks.indexOf(param1) < 0 && _newAchievements.length > 0)
|
||||
{
|
||||
_finishedCallbacks.push(param1);
|
||||
}
|
||||
else
|
||||
{
|
||||
param1();
|
||||
}
|
||||
}
|
||||
if(_state == 0 && _newAchievements.length > 0)
|
||||
{
|
||||
_state = 1;
|
||||
displayNextAchievement();
|
||||
}
|
||||
}
|
||||
|
||||
public static function set achievementDefs(param1:Object) : void
|
||||
{
|
||||
_achievementDefs = param1;
|
||||
}
|
||||
|
||||
public static function set achievementDefsIndexed(param1:Object) : void
|
||||
{
|
||||
_achievementDefsIndexed = param1;
|
||||
for each(var _loc2_:Array in _achievementDefsIndexed)
|
||||
{
|
||||
_loc2_.sortOn(["sortIndex"],16);
|
||||
}
|
||||
}
|
||||
|
||||
public static function get achievementDefs() : Object
|
||||
{
|
||||
return _achievementDefs;
|
||||
}
|
||||
|
||||
public static function get achievementDefsIndexed() : Object
|
||||
{
|
||||
return _achievementDefsIndexed;
|
||||
}
|
||||
|
||||
public static function getAchievementDef(param1:int) : Object
|
||||
{
|
||||
return _achievementDefs[param1];
|
||||
}
|
||||
|
||||
public static function getAchievementDefsByType(param1:int) : Object
|
||||
{
|
||||
return _achievementDefsIndexed[param1];
|
||||
}
|
||||
|
||||
public static function get typeNamesTranslatedAndSorted() : Array
|
||||
{
|
||||
var _loc1_:Array = null;
|
||||
var _loc2_:int = 0;
|
||||
if(_sortedTypeNames == null)
|
||||
{
|
||||
_sortedTypeNames = [];
|
||||
_loc1_ = SbiConstants.ACHIEVEMENT_TYPE_NAMES;
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _loc1_.length)
|
||||
{
|
||||
_sortedTypeNames.push({
|
||||
"typeIndex":_loc2_,
|
||||
"name":LocalizationManager.translateIdOnly(_loc1_[_loc2_])
|
||||
});
|
||||
_loc2_++;
|
||||
}
|
||||
_sortedTypeNames.sortOn(["name"],[2,1]);
|
||||
}
|
||||
return _sortedTypeNames;
|
||||
}
|
||||
|
||||
public static function getAllAchievementsIndexed() : Object
|
||||
{
|
||||
var _loc1_:Achievement = null;
|
||||
var _loc3_:Object = null;
|
||||
var _loc2_:int = 0;
|
||||
var _loc4_:int = 0;
|
||||
if(_allAchievementsIndexed == null)
|
||||
{
|
||||
_allAchievementsIndexed = [];
|
||||
for each(var _loc5_:Array in _achievementDefsIndexed)
|
||||
{
|
||||
_allAchievementsIndexed.push([]);
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < _loc5_.length)
|
||||
{
|
||||
_loc3_ = _loc5_[_loc4_];
|
||||
if(_loc3_.iconMediaRef != 0 && _loc3_.descStrRef != 0 && _loc3_.descStrRef != 15476)
|
||||
{
|
||||
_loc1_ = new Achievement();
|
||||
_loc1_.init(0,_loc3_.id,true);
|
||||
_allAchievementsIndexed[_loc2_].push(_loc1_);
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
return _allAchievementsIndexed;
|
||||
}
|
||||
|
||||
private static function finishedDisplayingNewAchievements() : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc1_:int = int(_finishedCallbacks.length);
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _loc1_)
|
||||
{
|
||||
_finishedCallbacks[_loc2_]();
|
||||
_loc2_++;
|
||||
}
|
||||
_finishedCallbacks.splice(0,_finishedCallbacks.length);
|
||||
}
|
||||
|
||||
private static function displayNextAchievement() : void
|
||||
{
|
||||
var _loc1_:Achievement = _newAchievements[0];
|
||||
_achievementImg = _loc1_.image;
|
||||
_loc1_.setScale(2);
|
||||
_loc1_.setPosition(0.5,0.5);
|
||||
if(_achievementPopup)
|
||||
{
|
||||
_achievementPopup.achievementWindow.itemBlock.addChild(_achievementImg);
|
||||
LocalizationManager.updateToFit(_achievementPopup.achievementWindow.acmtNameTxt,_loc1_.name,false,false,false);
|
||||
_fpsLayer.addChild(_achievementPopup);
|
||||
_achievementPopup.gotoAndPlay(1);
|
||||
_achievementPopup.achievementWindow.gotoAndPlay(1);
|
||||
AJAudio.playAchievementSound();
|
||||
_popupDisplayTimer.start();
|
||||
_popupDisplayTimer.addEventListener("timer",onDisplayTimerFinished,false,0,true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_popupMediaHelper = new MediaHelper();
|
||||
_popupMediaHelper.init(2721,popupHelperCallback);
|
||||
}
|
||||
}
|
||||
|
||||
private static function onDisplayTimerFinished(param1:TimerEvent) : void
|
||||
{
|
||||
_popupDisplayTimer.stop();
|
||||
_fpsLayer.removeChild(_achievementPopup);
|
||||
_achievementPopup.achievementWindow.itemBlock.removeChild(_achievementImg);
|
||||
_newAchievements.splice(0,1);
|
||||
if(_newAchievements.length > 0)
|
||||
{
|
||||
_popupDelayTimer.start();
|
||||
_popupDelayTimer.addEventListener("timer",onDelayTimerFinished,false,0,true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_state = 0;
|
||||
finishedDisplayingNewAchievements();
|
||||
}
|
||||
}
|
||||
|
||||
private static function onDelayTimerFinished(param1:TimerEvent) : void
|
||||
{
|
||||
_popupDelayTimer.stop();
|
||||
displayNextAchievement();
|
||||
}
|
||||
|
||||
private static function popupHelperCallback(param1:MovieClip) : void
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
_achievementPopup = new MovieClip();
|
||||
_achievementPopup = param1;
|
||||
_achievementPopup.visible = true;
|
||||
_achievementPopup.addEventListener("mouseDown",onPopupDown,false,0,true);
|
||||
_popupMediaHelper.destroy();
|
||||
_popupMediaHelper = null;
|
||||
displayNextAchievement();
|
||||
}
|
||||
}
|
||||
|
||||
private static function onPopupDown(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
}
|
||||
|
||||
public static function addAchievement(param1:Achievement) : void
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
_newAchievements.push(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,349 @@
|
||||
package achievement
|
||||
{
|
||||
import avatar.AvatarManager;
|
||||
import avatar.UserInfo;
|
||||
import com.sbi.client.SFEvent;
|
||||
import gui.MySettings;
|
||||
import loader.DefPacksDefHelper;
|
||||
|
||||
public class AchievementXtCommManager
|
||||
{
|
||||
|
||||
public static const UV_JAMAA_JOURNAL_TIMESTAMP:int = 112;
|
||||
|
||||
public static const UV_JAMAA_JOURNAL_TIMESTAMP_STARTUP:int = 158;
|
||||
|
||||
public static const UV_BRADY_BARR_COUNT:int = 128;
|
||||
|
||||
public static const UV_TRADING:int = 129;
|
||||
|
||||
public static const UV_PET_COUNTER:int = 212;
|
||||
|
||||
public static const UV_DAILY_GEM_BONUS:int = 214;
|
||||
|
||||
public static const UV_AVT_VIEWABLE_FLAG:int = 287;
|
||||
|
||||
public static const UV_TIERNEY_THYS_COUNT:int = 297;
|
||||
|
||||
public static const UV_PLAYER_WALL_COUNT:int = 414;
|
||||
|
||||
public static const UV_PET_INVENTORY_MAX:int = 338;
|
||||
|
||||
public static const UV_SETTINGS:int = 363;
|
||||
|
||||
public static const UV_PARTY_JB_ENTER:int = 366;
|
||||
|
||||
public static const UV_TUTORIALS:int = 379;
|
||||
|
||||
public static const UV_CUSTOM_AVT_VIEWABLE_FLAG:int = 410;
|
||||
|
||||
public static const UV_COLOR_ME_RAD:int = 146;
|
||||
|
||||
public static const UV_WALL_FLOORING_FIRST_BUY:int = 420;
|
||||
|
||||
public static const UV_DEN_ITEM_BUY_COUNT:int = 3;
|
||||
|
||||
public static const UV_NUM_ACQUIRED_ADOPT_A_PETS:int = 426;
|
||||
|
||||
public static const UV_PLATFORM_LEVEL_COMPLETED:int = 435;
|
||||
|
||||
public static const UV_GABBY_WILD_COUNT:int = 436;
|
||||
|
||||
public static const UV_CHAT_CORRECTION:int = 442;
|
||||
|
||||
public static const UV_HAS_SET_CHAT_SETTING:int = 452;
|
||||
|
||||
public static const UV_LAST_SEEN_NEWSPAPER:int = 455;
|
||||
|
||||
public static const UV_REFERRAL_1:int = 461;
|
||||
|
||||
public static const UV_REFERRAL_2TO4:int = 462;
|
||||
|
||||
public static const UV_ECO_GIFT:int = 465;
|
||||
|
||||
public static const ACHIEVEMENT_REQUEST_INTERVAL:int = 10000;
|
||||
|
||||
private static var _zaCallback:Function;
|
||||
|
||||
private static var _inMinigame:Function;
|
||||
|
||||
private static var _onUserVarsReceived:Function;
|
||||
|
||||
private static var _setGemBonusValues:Function;
|
||||
|
||||
private static var _bMyUserVarsReceived:Boolean;
|
||||
|
||||
private static var _zsCallbacks:Object;
|
||||
|
||||
private static var _achievementRequestUsername:String;
|
||||
|
||||
public static const UV_PARTY_JB_ENTER_BIT_ARRAY:Array = [27,48];
|
||||
|
||||
public function AchievementXtCommManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init(param1:Function, param2:Function, param3:Function) : void
|
||||
{
|
||||
_inMinigame = param1;
|
||||
_onUserVarsReceived = param2;
|
||||
_setGemBonusValues = param3;
|
||||
_zsCallbacks = {};
|
||||
}
|
||||
|
||||
public static function destroy() : void
|
||||
{
|
||||
_zsCallbacks = null;
|
||||
}
|
||||
|
||||
public static function requestAchievements(param1:String, param2:Function = null) : void
|
||||
{
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc4_:UserInfo = gMainFrame.userInfo.getUserInfoByUserName(param1);
|
||||
if(_loc4_)
|
||||
{
|
||||
_loc3_ = _loc4_.getTimeOfLastAchievementRequest();
|
||||
_loc5_ = new Date().getTime();
|
||||
if(_loc5_ - _loc3_ > 10000)
|
||||
{
|
||||
_zaCallback = param2;
|
||||
_loc4_.setTimeOfLastAchievementRequest(_loc5_);
|
||||
if(_loc3_ == 0)
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("za",[param1,-1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("za",[param1,int((_loc5_ - _loc3_) / 1000)]);
|
||||
}
|
||||
}
|
||||
else if(param2 != null)
|
||||
{
|
||||
param2(_loc4_.achievements,_loc4_.achievementsIndexed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function requestSetUserVar(param1:int, param2:int, param3:Function = null, param4:Boolean = true) : void
|
||||
{
|
||||
if(!gMainFrame.clientInfo.invisMode)
|
||||
{
|
||||
if(param1 <= 0)
|
||||
{
|
||||
trace("ERROR: Illegal userVarId=" + param1);
|
||||
return;
|
||||
}
|
||||
if(param3 != null)
|
||||
{
|
||||
_zsCallbacks[param1] = {
|
||||
"uv":param1,
|
||||
"c":param3
|
||||
};
|
||||
}
|
||||
gMainFrame.server.setXtObject_Str("zs",[param1,param2,param4 ? 1 : 0]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function requestAllUserVars() : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("zg",[]);
|
||||
}
|
||||
|
||||
public static function requestDeleteAllAchievementsAndUserVars() : void
|
||||
{
|
||||
}
|
||||
|
||||
public static function handleXtReply(param1:SFEvent) : void
|
||||
{
|
||||
var _loc2_:Object = param1.obj;
|
||||
switch(_loc2_[0])
|
||||
{
|
||||
case "za":
|
||||
getAchievementsResponse(_loc2_);
|
||||
break;
|
||||
case "zs":
|
||||
setUserVarResponse(_loc2_);
|
||||
break;
|
||||
case "zg":
|
||||
getUserVarsResponse(_loc2_);
|
||||
break;
|
||||
default:
|
||||
throw new Error("Did not expect ext cmd=" + _loc2_[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function onAchievementDefPacksResponse(param1:DefPacksDefHelper) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
DefPacksDefHelper.mediaArray[1042] = null;
|
||||
var _loc4_:Object = param1.def;
|
||||
var _loc5_:Object = {};
|
||||
var _loc3_:Object = {};
|
||||
for each(var _loc6_:Object in _loc4_)
|
||||
{
|
||||
_loc5_[int(_loc6_.id)] = {
|
||||
"id":int(_loc6_.id),
|
||||
"baseMediaRef":int(_loc6_.baseMediaRef),
|
||||
"descStrRef":int(_loc6_.descStrRef),
|
||||
"extraText":_loc6_.extraText,
|
||||
"iconMediaRef":int(_loc6_.iconMediaRef),
|
||||
"titleStrRef":int(_loc6_.titleStrRef),
|
||||
"type":int(_loc6_.type),
|
||||
"triggeredAmount":int(_loc6_.triggerAmount),
|
||||
"userVarRef":int(_loc6_.userVarRef),
|
||||
"sortIndex":int(_loc6_.name.split("_")[0])
|
||||
};
|
||||
if(_loc3_[int(_loc6_.type)])
|
||||
{
|
||||
_loc3_[int(_loc6_.type)].push(_loc5_[int(_loc6_.id)]);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_[int(_loc6_.type)] = [_loc5_[int(_loc6_.id)]];
|
||||
}
|
||||
}
|
||||
AchievementManager.achievementDefs = _loc5_;
|
||||
AchievementManager.achievementDefsIndexed = _loc3_;
|
||||
}
|
||||
|
||||
private static function setUserVarResponse(param1:Object) : void
|
||||
{
|
||||
var _loc5_:int = 0;
|
||||
var _loc7_:int = 0;
|
||||
var _loc11_:Number = NaN;
|
||||
var _loc12_:Boolean = false;
|
||||
var _loc6_:Array = null;
|
||||
var _loc3_:Achievement = null;
|
||||
var _loc8_:* = null;
|
||||
var _loc9_:int = 2;
|
||||
var _loc10_:int = 1;
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _loc10_)
|
||||
{
|
||||
_loc5_ = int(param1[_loc9_++]);
|
||||
_loc11_ = Number(param1[_loc9_++]);
|
||||
gMainFrame.userInfo.userVarCache.updateUserVar(_loc5_,_loc11_);
|
||||
if(_loc5_ == 214)
|
||||
{
|
||||
_setGemBonusValues(_loc11_);
|
||||
}
|
||||
if(_loc5_ == 363 && (_loc11_ == 1 << MySettings.SETTINGS_USERNAME_BADGE || _loc11_ == 0))
|
||||
{
|
||||
AvatarManager.updateAvatarNameBarNames();
|
||||
}
|
||||
_loc7_++;
|
||||
}
|
||||
var _loc2_:int = int(param1[_loc9_++]);
|
||||
if(_loc2_ > 0)
|
||||
{
|
||||
_loc6_ = [];
|
||||
if(!gMainFrame.userInfo.playerUserInfo.achievements)
|
||||
{
|
||||
_loc12_ = true;
|
||||
}
|
||||
_loc7_ = _loc2_ - 1;
|
||||
while(_loc7_ >= 0)
|
||||
{
|
||||
_loc3_ = new Achievement();
|
||||
_loc3_.init(int(param1[_loc9_++]),int(param1[_loc9_++]),true);
|
||||
_loc6_[_loc7_] = _loc3_;
|
||||
AchievementManager.addAchievement(_loc3_.clone());
|
||||
_loc7_--;
|
||||
}
|
||||
}
|
||||
if(_loc12_)
|
||||
{
|
||||
requestAchievements(gMainFrame.userInfo.playerUserInfo.userName);
|
||||
}
|
||||
else if(_loc6_)
|
||||
{
|
||||
gMainFrame.userInfo.playerUserInfo.addAchievementsTolist(_loc6_);
|
||||
}
|
||||
if(!_inMinigame())
|
||||
{
|
||||
AchievementManager.displayNewAchievements();
|
||||
}
|
||||
var _loc4_:Object = _zsCallbacks[_loc5_];
|
||||
if(_loc4_)
|
||||
{
|
||||
_loc4_.c(_loc5_,_loc11_);
|
||||
delete _zsCallbacks[_loc5_];
|
||||
}
|
||||
}
|
||||
|
||||
private static function getUserVarsResponse(param1:Object) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:int = 2;
|
||||
var _loc5_:int = int(param1[_loc4_++]);
|
||||
var _loc2_:Object = {};
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _loc5_)
|
||||
{
|
||||
_loc2_[int(param1[_loc4_++])] = {
|
||||
"type":int(param1[_loc4_++]),
|
||||
"value":Number(param1[_loc4_++])
|
||||
};
|
||||
_loc3_++;
|
||||
}
|
||||
gMainFrame.userInfo.userVarCache.playerUserVars = _loc2_;
|
||||
if(!_bMyUserVarsReceived)
|
||||
{
|
||||
_onUserVarsReceived();
|
||||
}
|
||||
}
|
||||
|
||||
private static function getAchievementsResponse(param1:Object) : void
|
||||
{
|
||||
var _loc4_:Array = null;
|
||||
var _loc5_:int = 0;
|
||||
var _loc2_:Achievement = null;
|
||||
var _loc6_:int = 2;
|
||||
var _loc8_:String = param1[_loc6_++];
|
||||
var _loc7_:int = int(param1[_loc6_++]);
|
||||
var _loc3_:UserInfo = gMainFrame.userInfo.getUserInfoByUserName(_loc8_);
|
||||
if(_loc7_ > 0)
|
||||
{
|
||||
_loc4_ = new Array(_loc7_);
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _loc7_)
|
||||
{
|
||||
_loc2_ = new Achievement();
|
||||
_loc2_.init(int(param1[_loc6_++]),int(param1[_loc6_++]),_loc8_.toLowerCase() == gMainFrame.userInfo.playerUserInfo.userName.toLowerCase());
|
||||
_loc4_[_loc5_] = _loc2_;
|
||||
_loc5_++;
|
||||
}
|
||||
_loc4_.sortOn("invId",0x10 | 2);
|
||||
if(_loc3_)
|
||||
{
|
||||
_loc3_.addAchievementsTolist(_loc4_);
|
||||
}
|
||||
}
|
||||
if(_zaCallback != null)
|
||||
{
|
||||
if(_loc8_.toLowerCase() == gMainFrame.userInfo.myUserName.toLowerCase())
|
||||
{
|
||||
if(_loc3_)
|
||||
{
|
||||
_zaCallback(_loc3_.achievements,_loc3_.achievementsIndexed);
|
||||
}
|
||||
else
|
||||
{
|
||||
_zaCallback(null,null);
|
||||
}
|
||||
}
|
||||
else if(_loc3_)
|
||||
{
|
||||
_zaCallback(_loc3_.achievements,_loc3_.achievementsIndexed,_loc7_ == -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_zaCallback(null,null,_loc7_ == -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user