home *** CD-ROM | disk | FTP | other *** search
- class WorldInstruction
- {
- var minChance;
- var maxChance;
- var chance;
- var iterator;
- var subInstructions;
- var enemyType;
- var enemyNum;
- var eof;
- function WorldInstruction(myChance)
- {
- this.minChance = 0;
- this.maxChance = 0;
- this.chance = myChance;
- this.iterator = -1;
- this.subInstructions = new Array();
- this.enemyType = "";
- this.enemyNum = 0;
- this.eof = true;
- }
- function SetRange(loChance, hiChance)
- {
- this.minChance = loChance;
- this.maxChance = hiChance;
- }
- function GetNumInstructions()
- {
- return this.subInstructions.length;
- }
- function AddInstruction(enemyType, minNum, maxNum)
- {
- var _loc2_ = Math.round(Math.random() * (maxNum - minNum)) + minNum;
- this.subInstructions.push({linkage:enemyType,numAmount:_loc2_});
- if(this.iterator == this.subInstructions.length)
- {
- this.eof = true;
- }
- else
- {
- this.eof = false;
- }
- }
- function Begin()
- {
- this.iterator = 0;
- if(this.iterator == this.subInstructions.length)
- {
- this.eof = true;
- }
- this.enemyType = this.subInstructions[this.iterator].linkage;
- this.enemyNum = this.subInstructions[this.iterator].numAmount;
- }
- function Next()
- {
- this.iterator = this.iterator + 1;
- if(this.iterator == this.subInstructions.length)
- {
- this.iterator = this.iterator - 1;
- this.eof = true;
- }
- this.enemyType = this.subInstructions[this.iterator].linkage;
- this.enemyNum = this.subInstructions[this.iterator].numAmount;
- }
- }
-