mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-21 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,87 @@
|
||||
package currency
|
||||
{
|
||||
public class CombinedCurrencyItem
|
||||
{
|
||||
|
||||
private var _countData:Vector.<Object>;
|
||||
|
||||
private var _numCurrenciesInUse:int;
|
||||
|
||||
public function CombinedCurrencyItem(param1:String)
|
||||
{
|
||||
var _loc2_:Array = null;
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc4_:int = 0;
|
||||
var _loc5_:Array = null;
|
||||
var _loc6_:int = 0;
|
||||
super();
|
||||
_numCurrenciesInUse = 0;
|
||||
if(param1 && param1 != "")
|
||||
{
|
||||
_countData = new Vector.<Object>(11);
|
||||
_loc2_ = param1.split(",");
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _loc2_.length)
|
||||
{
|
||||
_loc5_ = _loc2_[_loc6_].split("x");
|
||||
if(_loc5_.length < 2)
|
||||
{
|
||||
throw new Error("Unable to parse currency. String=" + _loc2_[_loc6_]);
|
||||
}
|
||||
_loc3_ = int(_loc5_[1]);
|
||||
_loc4_ = int(_loc5_[0]);
|
||||
_numCurrenciesInUse = _numCurrenciesInUse + 1;
|
||||
_countData[_loc4_] = {
|
||||
"count":_loc3_,
|
||||
"type":_loc4_,
|
||||
"name":typeToName(_loc4_)
|
||||
};
|
||||
_loc6_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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,221 @@
|
||||
package currency
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import loader.MediaHelper;
|
||||
|
||||
public class CurrencyItem
|
||||
{
|
||||
|
||||
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 _itemDefId: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;
|
||||
|
||||
public var isIconLoaded:Boolean;
|
||||
|
||||
public var imageLoadedCallback:Function;
|
||||
|
||||
public function CurrencyItem()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function init(param1:int, param2:int, param3:int, param4:int, param5:int, param6:int, param7:String, param8:uint = 0) : void
|
||||
{
|
||||
_itemDefId = param1;
|
||||
_mediaId = _mediaIdLarge = param2;
|
||||
_value = param5;
|
||||
_name = param7;
|
||||
_isMemberOnly = false;
|
||||
_enviroType = 0;
|
||||
_currencyType = param6;
|
||||
_result = param3;
|
||||
_resultType = param4;
|
||||
_endTime = param8;
|
||||
_icon = new Sprite();
|
||||
_largeIcon = new Sprite();
|
||||
_waitForSmallIcon = _waitForLargeIcon = true;
|
||||
makeIcons();
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
_icon = null;
|
||||
}
|
||||
|
||||
public function clone() : CurrencyItem
|
||||
{
|
||||
var _loc1_:CurrencyItem = new CurrencyItem();
|
||||
_loc1_.init(_itemDefId,_mediaId,_result,_resultType,_value,_currencyType,_name,_endTime);
|
||||
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 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 itemDefId() : int
|
||||
{
|
||||
return _itemDefId;
|
||||
}
|
||||
|
||||
public function get itemStatus() : int
|
||||
{
|
||||
return _itemStatus;
|
||||
}
|
||||
|
||||
public function get currencyType() : int
|
||||
{
|
||||
return _currencyType;
|
||||
}
|
||||
|
||||
public function get value() : int
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
public function get name() : String
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public function get endTime() : uint
|
||||
{
|
||||
return _endTime;
|
||||
}
|
||||
|
||||
public function set endTime(param1:uint) : void
|
||||
{
|
||||
_endTime = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>(11);
|
||||
}
|
||||
|
||||
public static function setCurrency(param1:*, param2:int) : Boolean
|
||||
{
|
||||
var _loc4_:Array = null;
|
||||
var _loc3_:int = 0;
|
||||
var _loc6_:int = 0;
|
||||
var _loc5_:Array = null;
|
||||
var _loc7_:int = 0;
|
||||
if(param2 != 100 && (param2 < 0 || param2 >= 11))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(param2 == 100)
|
||||
{
|
||||
_loc4_ = param1.split(",");
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _loc4_.length)
|
||||
{
|
||||
_loc5_ = _loc4_[_loc7_].split("x");
|
||||
if(_loc5_.length <= 1)
|
||||
{
|
||||
throw new Error("Failed to parse craft values where value=" + _craftValues);
|
||||
}
|
||||
_loc6_ = int(_loc5_[0]);
|
||||
_loc3_ = int(_loc5_[1]);
|
||||
_currency[_loc6_] = _loc3_;
|
||||
_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 _loc6_:int = 0;
|
||||
var _loc5_:Object = null;
|
||||
var _loc4_:Boolean = false;
|
||||
var _loc7_:int = 0;
|
||||
if(param1 == 100)
|
||||
{
|
||||
if(param3 != -1)
|
||||
{
|
||||
if(param2 is CombinedCurrencyItem)
|
||||
{
|
||||
_loc5_ = param2.getCountDataObjectByType(param3);
|
||||
if(_loc5_ == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return _currency[param3] >= _loc5_.count;
|
||||
}
|
||||
return _currency[param3] >= param2;
|
||||
}
|
||||
_loc4_ = param2 is CombinedCurrencyItem;
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _currency.length)
|
||||
{
|
||||
if(_loc4_)
|
||||
{
|
||||
_loc5_ = param2.getCountDataObjectByType(_loc7_);
|
||||
if(_loc5_ != null)
|
||||
{
|
||||
if(_currency[_loc7_] < _loc5_.count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_currency[_loc7_] < param2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_loc7_++;
|
||||
}
|
||||
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