mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-19 17: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,87 @@
|
||||
package currency
|
||||
{
|
||||
public class CombinedCurrencyItem
|
||||
{
|
||||
|
||||
private var _countData:Vector.<Object>;
|
||||
|
||||
private var _numCurrenciesInUse:int;
|
||||
|
||||
public function CombinedCurrencyItem(param1:String)
|
||||
{
|
||||
var _loc5_:Array = null;
|
||||
var _loc6_:Number = NaN;
|
||||
var _loc4_:int = 0;
|
||||
var _loc2_:Array = null;
|
||||
var _loc3_:int = 0;
|
||||
super();
|
||||
_numCurrenciesInUse = 0;
|
||||
if(param1 && param1 != "")
|
||||
{
|
||||
_countData = new Vector.<Object>(12);
|
||||
_loc5_ = param1.split(",");
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _loc5_.length)
|
||||
{
|
||||
_loc2_ = _loc5_[_loc3_].split("x");
|
||||
if(_loc2_.length < 2)
|
||||
{
|
||||
throw new Error("Unable to parse currency. String=" + _loc5_[_loc3_]);
|
||||
}
|
||||
_loc6_ = int(_loc2_[1]);
|
||||
_loc4_ = int(_loc2_[0]);
|
||||
_numCurrenciesInUse = _numCurrenciesInUse + 1;
|
||||
_countData[_loc4_] = {
|
||||
"count":_loc6_,
|
||||
"type":_loc4_,
|
||||
"name":typeToName(_loc4_)
|
||||
};
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get countData() : Vector.<Object>
|
||||
{
|
||||
return _countData;
|
||||
}
|
||||
|
||||
public function get numCurrenciesInUse() : int
|
||||
{
|
||||
return _numCurrenciesInUse;
|
||||
}
|
||||
|
||||
public function getCountDataObjectByType(param1:int) : Object
|
||||
{
|
||||
if(param1 < 0 || param1 >= _countData.length)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _countData[param1];
|
||||
}
|
||||
|
||||
private function typeToName(param1:int) : String
|
||||
{
|
||||
switch(param1 - 4)
|
||||
{
|
||||
case 0:
|
||||
return "straw";
|
||||
case 1:
|
||||
return "bamboo";
|
||||
case 2:
|
||||
return "wood";
|
||||
case 3:
|
||||
return "stone";
|
||||
case 4:
|
||||
return "silver";
|
||||
case 5:
|
||||
return "gold";
|
||||
case 6:
|
||||
return "gemstone";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,407 @@
|
||||
package currency
|
||||
{
|
||||
import diamond.DiamondItem;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import inventory.Iitem;
|
||||
import item.ItemXtCommManager;
|
||||
import loader.MediaHelper;
|
||||
|
||||
public class CurrencyItem implements Iitem
|
||||
{
|
||||
|
||||
public static const NORMAL_ITEM:int = 0;
|
||||
|
||||
public static const NEW_ITEM:int = 1;
|
||||
|
||||
public static const SALE_ITEM:int = 2;
|
||||
|
||||
public static const CLEARANCE_ITEM:int = 3;
|
||||
|
||||
public static const RARE_ITEM:int = 4;
|
||||
|
||||
private var _currencyExchangeDef:Object;
|
||||
|
||||
private var _defId:int;
|
||||
|
||||
private var _mediaId:int;
|
||||
|
||||
private var _result:int;
|
||||
|
||||
private var _resultType:int;
|
||||
|
||||
private var _value:int;
|
||||
|
||||
private var _currencyType:int;
|
||||
|
||||
private var _name:String;
|
||||
|
||||
private var _itemStatus:int;
|
||||
|
||||
private var _isMemberOnly:Boolean;
|
||||
|
||||
private var _enviroType:int;
|
||||
|
||||
private var _endTime:uint;
|
||||
|
||||
private var _mediaIdLarge:int;
|
||||
|
||||
private var _mediaHelper:MediaHelper;
|
||||
|
||||
private var _mediaHelperLarge:MediaHelper;
|
||||
|
||||
private var _waitForSmallIcon:Boolean;
|
||||
|
||||
private var _waitForLargeIcon:Boolean;
|
||||
|
||||
private var _icon:Sprite;
|
||||
|
||||
private var _largeIcon:Sprite;
|
||||
|
||||
private var _isIconLoaded:Boolean;
|
||||
|
||||
private var _imageLoadedCallback:Function;
|
||||
|
||||
public function CurrencyItem()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function init(param1:int) : void
|
||||
{
|
||||
_defId = param1;
|
||||
_currencyExchangeDef = ItemXtCommManager.getCurrencyExchangeDef(param1);
|
||||
_mediaId = _mediaIdLarge = _currencyExchangeDef.mediaId;
|
||||
_value = _currencyExchangeDef.value;
|
||||
_name = _currencyExchangeDef.name;
|
||||
_isMemberOnly = false;
|
||||
_enviroType = 0;
|
||||
_currencyType = _currencyExchangeDef.currencyType;
|
||||
_result = _currencyExchangeDef.result;
|
||||
_resultType = _currencyExchangeDef.resultType;
|
||||
_endTime = _currencyExchangeDef.availabilityEndTime;
|
||||
_icon = new Sprite();
|
||||
_largeIcon = new Sprite();
|
||||
_waitForSmallIcon = _waitForLargeIcon = true;
|
||||
makeIcons();
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
_icon = null;
|
||||
}
|
||||
|
||||
public function ifItemDiffers(param1:Iitem) : Boolean
|
||||
{
|
||||
var _loc2_:CurrencyItem = param1 as CurrencyItem;
|
||||
if(_loc2_)
|
||||
{
|
||||
if(_defId == param1.defId)
|
||||
{
|
||||
if(value != _loc2_.value || isNew != _loc2_.isNew || isOnSale != _loc2_.isOnSale || name != _loc2_.name || _endTime != _loc2_._endTime)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function clone() : Iitem
|
||||
{
|
||||
var _loc1_:CurrencyItem = new CurrencyItem();
|
||||
_loc1_.init(_defId);
|
||||
_loc1_.imageLoadedCallback = imageLoadedCallback;
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
private function makeIcons() : void
|
||||
{
|
||||
_mediaHelper = new MediaHelper();
|
||||
_mediaHelper.init(_mediaId,onIconLoaded,true);
|
||||
_mediaHelperLarge = new MediaHelper();
|
||||
_mediaHelperLarge.init(_mediaIdLarge,onLargeIconLoaded,true);
|
||||
}
|
||||
|
||||
private function onIconLoaded(param1:MovieClip) : void
|
||||
{
|
||||
if(_mediaId == param1.mediaHelper.id)
|
||||
{
|
||||
if(_icon)
|
||||
{
|
||||
_icon.addChild(param1);
|
||||
}
|
||||
}
|
||||
if(_imageLoadedCallback != null)
|
||||
{
|
||||
_imageLoadedCallback();
|
||||
}
|
||||
_isIconLoaded = true;
|
||||
}
|
||||
|
||||
private function onLargeIconLoaded(param1:MovieClip) : void
|
||||
{
|
||||
if(_mediaIdLarge == param1.mediaHelper.id)
|
||||
{
|
||||
if(_largeIcon)
|
||||
{
|
||||
_largeIcon.addChild(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get icon() : Sprite
|
||||
{
|
||||
return _icon;
|
||||
}
|
||||
|
||||
public function get largeIcon() : Sprite
|
||||
{
|
||||
return _largeIcon;
|
||||
}
|
||||
|
||||
public function get mediaId() : int
|
||||
{
|
||||
return _mediaId;
|
||||
}
|
||||
|
||||
public function get mediaIdLarge() : int
|
||||
{
|
||||
return _mediaIdLarge;
|
||||
}
|
||||
|
||||
public function get isMemberOnly() : Boolean
|
||||
{
|
||||
return _isMemberOnly;
|
||||
}
|
||||
|
||||
public function set isMemberOnly(param1:Boolean) : void
|
||||
{
|
||||
throw new Error("CurrencyItem does not implement changing member only value");
|
||||
}
|
||||
|
||||
public function get isOnSale() : Boolean
|
||||
{
|
||||
return _itemStatus == 2;
|
||||
}
|
||||
|
||||
public function get isOnClearance() : Boolean
|
||||
{
|
||||
return _itemStatus == 3;
|
||||
}
|
||||
|
||||
public function get isRare() : Boolean
|
||||
{
|
||||
return _itemStatus == 4;
|
||||
}
|
||||
|
||||
public function get isNew() : Boolean
|
||||
{
|
||||
return _itemStatus == 1;
|
||||
}
|
||||
|
||||
public function get isOcean() : Boolean
|
||||
{
|
||||
return _enviroType == 1;
|
||||
}
|
||||
|
||||
public function get isLand() : Boolean
|
||||
{
|
||||
return _enviroType == 0;
|
||||
}
|
||||
|
||||
public function get isLandAndOcean() : Boolean
|
||||
{
|
||||
return _enviroType == 3;
|
||||
}
|
||||
|
||||
public function get defId() : int
|
||||
{
|
||||
return _defId;
|
||||
}
|
||||
|
||||
public function set defId(param1:int) : void
|
||||
{
|
||||
_defId = param1;
|
||||
}
|
||||
|
||||
public function get itemStatus() : int
|
||||
{
|
||||
return _itemStatus;
|
||||
}
|
||||
|
||||
public function set itemStatus(param1:int) : void
|
||||
{
|
||||
_itemStatus = param1;
|
||||
}
|
||||
|
||||
public function get currencyType() : int
|
||||
{
|
||||
return _currencyType;
|
||||
}
|
||||
|
||||
public function set currencyType(param1:int) : void
|
||||
{
|
||||
_currencyType = param1;
|
||||
}
|
||||
|
||||
public function get value() : *
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
public function set value(param1:int) : void
|
||||
{
|
||||
_value = param1;
|
||||
}
|
||||
|
||||
public function get name() : String
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public function get endTime() : uint
|
||||
{
|
||||
return _endTime;
|
||||
}
|
||||
|
||||
public function set endTime(param1:uint) : void
|
||||
{
|
||||
_endTime = param1;
|
||||
}
|
||||
|
||||
public function get startTime() : uint
|
||||
{
|
||||
if(_currencyExchangeDef)
|
||||
{
|
||||
return _currencyExchangeDef.availabilityStartTime;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function get isIconLoaded() : Boolean
|
||||
{
|
||||
return _isIconLoaded;
|
||||
}
|
||||
|
||||
public function get imageLoadedCallback() : Function
|
||||
{
|
||||
return _imageLoadedCallback;
|
||||
}
|
||||
|
||||
public function set imageLoadedCallback(param1:Function) : void
|
||||
{
|
||||
_imageLoadedCallback = param1;
|
||||
}
|
||||
|
||||
public function get enviroType() : int
|
||||
{
|
||||
throw new Error("CurrencyItem does not contain a enviroType");
|
||||
}
|
||||
|
||||
public function get diamondDefId() : int
|
||||
{
|
||||
throw new Error("CurrencyItem does not contain diamondDefId");
|
||||
}
|
||||
|
||||
public function set diamondDefId(param1:int) : void
|
||||
{
|
||||
throw new Error("CurrencyItem does not support setting this value");
|
||||
}
|
||||
|
||||
public function get combinedCurrencyItem() : CombinedCurrencyItem
|
||||
{
|
||||
throw new Error("CurrencyItem does not contain combinedCurrencyItem");
|
||||
}
|
||||
|
||||
public function get isShopItem() : Boolean
|
||||
{
|
||||
throw new Error("CurrencyItem does not contain isShopItem");
|
||||
}
|
||||
|
||||
public function get layerId() : int
|
||||
{
|
||||
throw new Error("CurrencyItem does not contain layerId");
|
||||
}
|
||||
|
||||
public function get invIdx() : int
|
||||
{
|
||||
throw new Error("CurrencyItem does not contain invIdx");
|
||||
}
|
||||
|
||||
public function get recycleValue() : int
|
||||
{
|
||||
throw new Error("CurrencyItem does not contain recycleValue");
|
||||
}
|
||||
|
||||
public function get isDiamond() : Boolean
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function get isRareDiamond() : Boolean
|
||||
{
|
||||
return isRare && isDiamond;
|
||||
}
|
||||
|
||||
public function get isApproved() : Boolean
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function set isApproved(param1:Boolean) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function get isCustom() : Boolean
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function updateValueWithNewStatus(param1:int) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function get diamondItem() : DiamondItem
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function set diamondItem(param1:DiamondItem) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function get isAvailable() : Boolean
|
||||
{
|
||||
if(_currencyExchangeDef == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return Utility.isAvailable(_currencyExchangeDef.availabilityStartTime,_currencyExchangeDef.availabilityEndTime);
|
||||
}
|
||||
|
||||
public function get isInDenShop() : Boolean
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function get itemType() : int
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
public function get denStoreInvId() : int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function set denStoreInvId(param1:int) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function set asShopItemSized(param1:Boolean) : void
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
package currency
|
||||
{
|
||||
public class UserCurrency
|
||||
{
|
||||
|
||||
private static var _gems:int;
|
||||
|
||||
private static var _tickets:int;
|
||||
|
||||
private static var _diamonds:int;
|
||||
|
||||
private static var _crystals:int;
|
||||
|
||||
private static var _craftValues:String;
|
||||
|
||||
private static var _craftValuesParsed:Vector.<int>;
|
||||
|
||||
private static var _currency:Vector.<int>;
|
||||
|
||||
public function UserCurrency()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function initCurrency() : void
|
||||
{
|
||||
_currency = new Vector.<int>(12);
|
||||
}
|
||||
|
||||
public static function setCurrency(param1:*, param2:int) : Boolean
|
||||
{
|
||||
var _loc6_:Array = null;
|
||||
var _loc4_:int = 0;
|
||||
var _loc5_:int = 0;
|
||||
var _loc3_:Array = null;
|
||||
var _loc7_:int = 0;
|
||||
if(param2 != 100 && (param2 < 0 || param2 >= 12))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(param2 == 100)
|
||||
{
|
||||
_loc6_ = param1.split(",");
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _loc6_.length)
|
||||
{
|
||||
_loc3_ = _loc6_[_loc7_].split("x");
|
||||
if(_loc3_.length <= 1)
|
||||
{
|
||||
throw new Error("Failed to parse craft values where value=" + _craftValues);
|
||||
}
|
||||
_loc5_ = int(_loc3_[0]);
|
||||
_loc4_ = int(_loc3_[1]);
|
||||
_currency[_loc5_] = _loc4_;
|
||||
_loc7_++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_currency[param2] = param1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function getCurrency(param1:int) : int
|
||||
{
|
||||
if(param1 < 0 || param1 >= _currency.length)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return _currency[param1];
|
||||
}
|
||||
|
||||
public static function hasEnoughCurrency(param1:int, param2:*, param3:int = -1) : Boolean
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc7_:Object = null;
|
||||
var _loc5_:Boolean = false;
|
||||
var _loc6_:int = 0;
|
||||
if(param1 == 100)
|
||||
{
|
||||
if(param3 != -1)
|
||||
{
|
||||
if(param2 is CombinedCurrencyItem)
|
||||
{
|
||||
_loc7_ = param2.getCountDataObjectByType(param3);
|
||||
if(_loc7_ == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return _currency[param3] >= _loc7_.count;
|
||||
}
|
||||
return _currency[param3] >= param2;
|
||||
}
|
||||
_loc5_ = param2 is CombinedCurrencyItem;
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _currency.length)
|
||||
{
|
||||
if(_loc5_)
|
||||
{
|
||||
_loc7_ = param2.getCountDataObjectByType(_loc6_);
|
||||
if(_loc7_ != null)
|
||||
{
|
||||
if(_currency[_loc6_] < _loc7_.count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_currency[_loc6_] < param2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_loc6_++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return getCurrency(param1) >= param2;
|
||||
}
|
||||
|
||||
public static function get usableCraftTypes() : Array
|
||||
{
|
||||
return [4,5,6,7,8,9,10];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user