home *** CD-ROM | disk | FTP | other *** search
/ Champak 66 / Vol 66.iso / games / bluep.swf / scripts / __Packages / DataObject.as < prev    next >
Encoding:
Text File  |  2013-04-24  |  4.6 KB  |  168 lines

  1. class DataObject
  2. {
  3.    var arrElements;
  4.    var indexOne;
  5.    var indexTwo;
  6.    function DataObject()
  7.    {
  8.       var _loc3_ = this.RandNum(55,66);
  9.       this.arrElements = new Array(_loc3_);
  10.       var _loc2_ = 0;
  11.       while(_loc2_ < _loc3_)
  12.       {
  13.          this.arrElements[_loc2_] = 0;
  14.          _loc2_ = _loc2_ + 1;
  15.       }
  16.       this.indexOne = -1;
  17.       this.indexTwo = -1;
  18.    }
  19.    function Set(dataValue)
  20.    {
  21.       var _loc6_ = Math.round(Math.random() * dataValue);
  22.       var _loc7_ = dataValue - _loc6_;
  23.       this.indexOne = this.RandNum(0,this.arrElements.length - 4);
  24.       this.indexTwo = this.RandNum(0,this.arrElements.length - 4);
  25.       if(this.indexOne == this.indexTwo)
  26.       {
  27.          if(this.indexOne == this.arrElements.length - 1)
  28.          {
  29.             this.indexTwo = this.indexOne - 1;
  30.          }
  31.          else
  32.          {
  33.             this.indexTwo = this.indexOne + 1;
  34.          }
  35.       }
  36.       var _loc5_ = dataValue / (this.arrElements.length - 2);
  37.       var _loc4_ = dataValue;
  38.       var _loc9_ = this.arrElements.length;
  39.       var _loc2_ = 0;
  40.       while(_loc2_ < this.arrElements.length)
  41.       {
  42.          if(_loc2_ == this.indexOne)
  43.          {
  44.             this.arrElements[_loc2_] = _loc6_;
  45.          }
  46.          else if(_loc2_ == this.indexTwo)
  47.          {
  48.             this.arrElements[_loc2_] = _loc7_;
  49.          }
  50.          else
  51.          {
  52.             var _loc3_ = 0;
  53.             if(_loc4_ > 0)
  54.             {
  55.                _loc3_ = Math.round(Math.random() * _loc5_ + _loc5_ * 0.5);
  56.                if(_loc3_ > _loc4_)
  57.                {
  58.                   _loc3_ = _loc4_;
  59.                }
  60.                if(_loc2_ == this.arrElements.length - 1)
  61.                {
  62.                   _loc3_ = _loc4_;
  63.                }
  64.                _loc4_ -= _loc3_;
  65.             }
  66.             this.arrElements[_loc2_] = _loc3_;
  67.          }
  68.          _loc2_ = _loc2_ + 1;
  69.       }
  70.    }
  71.    function mSet(dataValue)
  72.    {
  73.       var _loc7_ = 0;
  74.       while(_loc7_ < 10)
  75.       {
  76.          var _loc5_ = Math.round(Math.random() * dataValue);
  77.          var _loc8_ = dataValue - _loc5_;
  78.          this.indexOne = this.RandNum(0,this.arrElements.length - 4);
  79.          this.indexTwo = this.RandNum(0,this.arrElements.length - 4);
  80.          if(this.indexOne == this.indexTwo)
  81.          {
  82.             if(this.indexOne == this.arrElements.length - 1)
  83.             {
  84.                this.indexTwo = this.indexOne - 1;
  85.             }
  86.             else
  87.             {
  88.                this.indexTwo = this.indexOne + 1;
  89.             }
  90.          }
  91.          var _loc4_ = dataValue / (this.arrElements.length - 2);
  92.          var _loc10_ = dataValue;
  93.          var _loc9_ = this.arrElements.length;
  94.          var _loc2_ = 0;
  95.          while(_loc2_ < this.arrElements.length)
  96.          {
  97.             if(_loc2_ == this.indexOne)
  98.             {
  99.                this.arrElements[_loc2_] = _loc5_;
  100.             }
  101.             else if(_loc2_ == this.indexTwo)
  102.             {
  103.                this.arrElements[_loc2_] = _loc8_;
  104.             }
  105.             else
  106.             {
  107.                var _loc3_ = 0;
  108.                _loc3_ = Math.round(Math.random() * (_loc4_ * 1.23) + _loc4_ * 0.75);
  109.                this.arrElements[_loc2_] = _loc3_;
  110.             }
  111.             _loc2_ = _loc2_ + 1;
  112.          }
  113.          if(this.Get() == -1)
  114.          {
  115.             break;
  116.          }
  117.          _loc7_ = _loc7_ + 1;
  118.       }
  119.    }
  120.    function Get()
  121.    {
  122.       var _loc3_ = 0;
  123.       var _loc4_ = 0;
  124.       var _loc2_ = 0;
  125.       while(_loc2_ < this.arrElements.length)
  126.       {
  127.          if(_loc2_ == this.indexOne)
  128.          {
  129.             _loc3_ += this.arrElements[_loc2_];
  130.          }
  131.          else if(_loc2_ == this.indexTwo)
  132.          {
  133.             _loc3_ += this.arrElements[_loc2_];
  134.          }
  135.          else
  136.          {
  137.             _loc4_ += this.arrElements[_loc2_];
  138.          }
  139.          _loc2_ = _loc2_ + 1;
  140.       }
  141.       if(_loc3_ == _loc4_)
  142.       {
  143.          return _loc3_;
  144.       }
  145.       return -1;
  146.    }
  147.    function Store()
  148.    {
  149.       var _loc2_ = this.arrElements.slice();
  150.       _loc2_.splice(2,0,this.indexOne);
  151.       _loc2_.splice(7,0,this.indexTwo);
  152.       return _loc2_;
  153.    }
  154.    function Load(originalArray)
  155.    {
  156.       this.indexOne = originalArray[2];
  157.       this.indexTwo = originalArray[7];
  158.       delete this.arrElements;
  159.       this.arrElements = originalArray.slice();
  160.       this.arrElements.splice(7,1);
  161.       this.arrElements.splice(2,1);
  162.    }
  163.    function RandNum(minVal, maxVal)
  164.    {
  165.       return Math.round(Math.random() * (maxVal - minVal)) + minVal;
  166.    }
  167. }
  168.