Guest User

Untitled

a guest
Feb 18th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package Zliver
  2. {
  3.     public class ResourceBuff extends Zliver.BuffZliver
  4.     {
  5.         public function ResourceBuff(arg1:String)
  6.         {
  7.             m_resourceModifiers = new Array();
  8.             super(arg1);
  9.             return;
  10.         }
  11.  
  12.         protected function loadModifiersXML(arg1:XML):void
  13.         {
  14.             var loc3:*;
  15.             loc3 = null;
  16.             var loc4:*;
  17.             loc4 = null;
  18.             var loc1:*;
  19.             loc1 = MULTIPLIER_SUFFIX.length;
  20.             var loc2:*;
  21.             loc2 = ADDITION_SUFFIX.length;
  22.             var loc5:*;
  23.             loc5 = 0;
  24.             var loc6:*;
  25.             loc6 = arg1.attributes();
  26.             for each (loc3 in loc6)
  27.             {
  28.                 if ((loc4 = loc3.name().toString()).substr(0 - loc1) == MULTIPLIER_SUFFIX)
  29.                 {
  30.                     setMultiplier(loc4.substr(0, loc4.length - loc1), Number(loc3));
  31.                     continue;
  32.                 }
  33.                 if (loc4.substr(0 - loc2) != ADDITION_SUFFIX)
  34.                 {
  35.                     continue;
  36.                 }
  37.                 setAddition(loc4.substr(0, loc4.length - loc2), Number(loc3));
  38.             }
  39.             return;
  40.         }
  41.  
  42.         protected function restoreModifiers(arg1:Object):void
  43.         {
  44.             var loc1:*;
  45.             loc1 = null;
  46.             var loc2:*;
  47.             loc2 = 0;
  48.             var loc3:*;
  49.             loc3 = arg1;
  50.             for (loc1 in loc3)
  51.             {
  52.                 m_resourceModifiers[loc1] = new Array();
  53.                 m_resourceModifiers[loc1]["addition"] = int(arg1[loc1].@addition);
  54.                 m_resourceModifiers[loc1]["multiplier"] = int(arg1[loc1].@multiplier);
  55.             }
  56.             return;
  57.         }
  58.  
  59.         public function setMultiplier(arg1:String, arg2:Number):void
  60.         {
  61.             if (!(m_resourceModifiers[arg1] as Array))
  62.             {
  63.                 m_resourceModifiers[arg1] = new Array();
  64.             }
  65.             m_resourceModifiers[arg1]["multiplier"] = arg2;
  66.             return;
  67.         }
  68.  
  69.         public override function resourceAdjustment(arg1:Object, arg2:Object):void
  70.         {
  71.             if (m_resourceModifiers[arg1.resourceName])
  72.             {
  73.                 arg2.multiplier = arg2.multiplier + (m_resourceModifiers[arg1.resourceName]["multiplier"] ? m_resourceModifiers[arg1.resourceName]["multiplier"] : 0);
  74.                 arg2.addition = arg2.addition + (m_resourceModifiers[arg1.resourceName]["addition"] ? m_resourceModifiers[arg1.resourceName]["addition"] : 0);
  75.             }
  76.             return;
  77.         }
  78.  
  79.         public function setAddition(arg1:String, arg2:Number):void
  80.         {
  81.             if (!(m_resourceModifiers[arg1] as Array))
  82.             {
  83.                 m_resourceModifiers[arg1] = new Array();
  84.             }
  85.             m_resourceModifiers[arg1]["addition"] = arg2;
  86.             return;
  87.         }
  88.  
  89.         public static function createFromXML(arg1:XML):Zliver.ResourceBuff
  90.         {
  91.             var loc1:*;
  92.             loc1 = new ResourceBuff(arg1.name);
  93.             loc1.loadModifiersXML(arg1);
  94.             return loc1;
  95.         }
  96.  
  97.         public static function createFromName(arg1:String):Zliver.ResourceBuff
  98.         {
  99.             var buffXML:XML;
  100.             var name:String;
  101.  
  102.             var loc1:*;
  103.             buffXML = null;
  104.             name = arg1;
  105.             var loc3:*;
  106.             loc3 = 0;
  107.             var loc4:*;
  108.             loc4 = Global.gameSettings.getXML().newBuffs.buff;
  109.             var loc2:*;
  110.             loc2 = new XMLList("");
  111.             for each (loc3 in loc4)
  112.             {
  113.                 if (loc3.@name == name)
  114.                 {
  115.                     buffXML = loc3;
  116.                     break;
  117.                 }
  118.             }
  119.             //buffXML = loc2[0];
  120.             if (buffXML)
  121.             {
  122.                 return createFromXML(buffXML);
  123.             }
  124.             return null;
  125.         }
  126.  
  127.         public static function restoreCreate(arg1:Object):Zliver.ResourceBuff
  128.         {
  129.             var loc1:*;
  130.             loc1 = new ResourceBuff(arg1.data.name);
  131.             loc1.restoreModifiers(arg1.data.modifiers);
  132.             return loc1;
  133.         }
  134.  
  135.         protected static const ADDITION_SUFFIX:String="_addition";
  136.  
  137.         protected static const multLen:int=MULTIPLIER_SUFFIX.length;
  138.  
  139.         protected static const addLen:int=ADDITION_SUFFIX.length;
  140.  
  141.         protected static const MULTIPLIER_SUFFIX:String="_multiplier";
  142.  
  143.         protected var m_resourceModifiers:Array;
  144.     }
  145. }
Add Comment
Please, Sign In to add comment