home *** CD-ROM | disk | FTP | other *** search
- class Set
- {
- var arrPieces;
- var blnUsed;
- var numSelectedMinNext;
- var numSelectedMaxNext;
- function Set()
- {
- this.arrPieces = new Array();
- this.blnUsed = false;
- }
- function AddPiece(strIdentifier, numPercentChance, minNew, maxNew)
- {
- this.arrPieces.push({name:strIdentifier,chance:numPercentChance,minChance:0,maxChance:0,minNext:minNew,maxNext:maxNew});
- }
- function InUse()
- {
- this.blnUsed = true;
- }
- function Used()
- {
- return this.blnUsed;
- }
- function GetPiece()
- {
- var _loc3_ = 0;
- var _loc4_ = 0;
- var _loc7_ = 0;
- var _loc5_ = 0;
- var _loc2_ = 0;
- while(_loc2_ < this.arrPieces.length)
- {
- _loc7_ += this.arrPieces[_loc2_].chance;
- _loc2_ = _loc2_ + 1;
- }
- _loc5_ = Math.round(Math.random() * _loc7_);
- _loc2_ = 0;
- while(_loc2_ < this.arrPieces.length)
- {
- _loc4_ = _loc3_ + this.arrPieces[_loc2_].chance;
- this.arrPieces[_loc2_].minChance = _loc3_;
- this.arrPieces[_loc2_].maxChance = _loc4_;
- _loc3_ = _loc4_;
- _loc2_ = _loc2_ + 1;
- }
- var _loc6_ = -1;
- _loc2_ = 0;
- while(_loc2_ < this.arrPieces.length)
- {
- if(_loc5_ >= this.arrPieces[_loc2_].minChance && _loc5_ < this.arrPieces[_loc2_].maxChance)
- {
- _loc6_ = _loc2_;
- break;
- }
- _loc2_ = _loc2_ + 1;
- }
- if(_loc6_ == -1)
- {
- _loc6_ = this.arrPieces.length - 1;
- }
- this.numSelectedMinNext = this.arrPieces[_loc6_].minNext;
- this.numSelectedMaxNext = this.arrPieces[_loc6_].maxNext;
- return this.arrPieces[_loc6_].name;
- }
- function GetMinNext()
- {
- return this.numSelectedMinNext;
- }
- function GetMaxNext()
- {
- return this.numSelectedMaxNext;
- }
- function SetMinMax(myMin, myMax)
- {
- this.numSelectedMinNext = myMin;
- this.numSelectedMaxNext = myMax;
- }
- }
-