(moveType: TheCaveMoveType = null)
| 105 | } |
| 106 | |
| 107 | private createWay(moveType: TheCaveMoveType = null): void{ |
| 108 | // A variable used in the loop choosing the new pattern |
| 109 | var cont: number; |
| 110 | |
| 111 | // Reset the additional characters array |
| 112 | this.additionalCharacters = []; |
| 113 | |
| 114 | // Set the first sentence |
| 115 | switch(moveType){ |
| 116 | case TheCaveMoveType.STRAIGHT: this.firstSentence = "theCaveFirstSentenceWentStraight"; break; |
| 117 | case TheCaveMoveType.LEFT: this.firstSentence = "theCaveFirstSentenceWentLeft"; break; |
| 118 | case TheCaveMoveType.RIGHT: this.firstSentence = "theCaveFirstSentenceWentRight"; break; |
| 119 | case null: this.firstSentence = "theCaveFirstSentenceYouAre"; break; |
| 120 | } |
| 121 | |
| 122 | // If there's a pattern, we possibly set it to null |
| 123 | if(this.pattern != null){ |
| 124 | // If this pattern should end, there's no pattern anymore |
| 125 | if(this.pattern.ended()){ |
| 126 | this.pattern = null; |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | // If there's no pattern (and we moved at least once) |
| 131 | if(this.pattern == null && this.lastMoves.length > 0){ |
| 132 | // One chance out of two to use a new one |
| 133 | if(Random.flipACoin()){ |
| 134 | cont = 10; |
| 135 | while(cont > 0 && this.pattern == null){ |
| 136 | cont -= 1; |
| 137 | switch(Random.upTo(4)){ |
| 138 | case 0: |
| 139 | if(Saving.loadBool("gridItemPossessedHeartPlug") == false) |
| 140 | this.pattern = new TheCavePattern_ArrowsToHeartPlug(this); |
| 141 | break; |
| 142 | case 1: |
| 143 | if(Saving.loadBool("TheCavePattern_ChocolateBarNowGotTheBar") == false) |
| 144 | this.pattern = new TheCavePattern_ChocolateBarNow(this); |
| 145 | break; |
| 146 | case 2: |
| 147 | if(Saving.loadBool("TheCavePattern_TreasureMapFoundTreasure") == false) |
| 148 | this.pattern = new TheCavePattern_TreasureMap(this); |
| 149 | break; |
| 150 | case 3: |
| 151 | this.pattern = new TheCavePattern_MonkeyWizard(this); |
| 152 | break; |
| 153 | case 4: |
| 154 | this.pattern = new TheCavePattern_OctopusKing(this); |
| 155 | break; |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | // Add some additional characters |
| 162 | for(var i = 0; i < 10; i++){ |
| 163 | this.additionalCharacters.push(new TheCaveAdditionalCharacter(this)); |
| 164 | } |
no test coverage detected