1var hell = { 2 3 // Variables 4 5 size : 45, 6 lavaLakeStep : 0, 7 buffers : [[], [], [], [], [], [], []], // The three things buffers 8 bufferPosition : 1, // On which buffer is the character (at first in the middle buffer) 9 timeSpent : 0, // Increase each cycle 10 addRockStep : 0, 11 monstersGap : 7, // Gap between the devil and appearing monsters 12 step : 0, 13 14 // Functions 15 16 onload : function(){ 17 land.addLand("Hell", this.size, 6, this.load.bind(this), this.getText.bind(this), this.move.bind(this)); 18 }, 19 20 move : function(){ 21 // We increase the lava lake step 22 this.lavaLakeStep += 1; 23 if(this.lavaLakeStep == 12){ 24 this.lavaLakeStep = 0; 25 } 26 27 // We make things move 28 for(var i = 0; i < 7; i++){ 29 if(i != this.bufferPosition){ 30 if(this.buffers[i][0].type == "mob") this.buffers[i][0] = quest.makeNoneThing(); 31 for(var j = 1; j < this.size - 1; j++){ 32 if(this.buffers[i][j].type == "mob" && this.buffers[i][j-1].type == "none" && this.buffers[i][j].text != " * " && this.buffers[i][j].text != "|-|"){ 33 this.buffers[i][j-1] = this.buffers[i][j]; 34 this.buffers[i][j] = quest.makeNoneThing(); 35 } 36 } 37 // Clone 38 for(var j = this.size-2; j >= 0; j--){ 39 if(this.buffers[i][j].text == "\\o/" && this.buffers[i][j].type == "ally" && this.buffers[i][j+1].type == "none" && this.buffers[i][j].text != " * " && this.buffers[i][j].text != "|-|"){ 40 this.buffers[i][j+1] = this.buffers[i][j]; 41 this.buffers[i][j] = quest.makeNoneThing(); 42 } 43 } 44 } 45 else{ 46 if(quest.things[0].type == "mob") quest.things[0] = quest.makeNoneThing(); 47 for(var j = 1; j < this.size - 1; j++){ 48 if(quest.things[j].type == "mob" && quest.things[j-1].type == "none" && quest.things[j].text != " * " && quest.things[j].text != "|-|"){ 49 quest.things[j-1] = quest.things[j]; 50 quest.things[j] = quest.makeNoneThing(); 51 } 52 } 53 } 54 } 55 56 // We check the steps 57 switch(this.step){ 58 case 0: this.checkStep1(); break; 59 case 1: this.checkStep2(); break; 60 case 2: this.checkStep3(); break; 61 case 3: this.checkStep4(); break; 62 } 63 64 // We add ennemies in the middle buffers 65 for(var i = 2; i < 5; i++){ 66 if(i != this.bufferPosition && this.buffers[i][this.size-this.monstersGap].type == "none"){ 67 this.buffers[i][this.size-this.monstersGap] = this.makeMiddleCreature(); 68 } 69 else if(i == this.bufferPosition && quest.things[this.size-this.monstersGap].type == "none"){ 70 quest.things[this.size-this.monstersGap] = this.makeMiddleCreature(); 71 } 72 } 73 74 // Idem in the side buffers 75 for(var i = 0; i < 2; i++){ 76 if(i != this.bufferPosition && this.buffers[i][this.size-this.monstersGap].type == "none"){ 77 this.buffers[i][this.size-this.monstersGap] = this.makeSideCreature(); 78 } 79 else if(i == this.bufferPosition && quest.things[this.size-this.monstersGap].type == "none"){ 80 quest.things[this.size-this.monstersGap] = this.makeSideCreature(); 81 } 82 } 83 84 for(var i = 5; i < 7; i++){ 85 if(i != this.bufferPosition && this.buffers[i][this.size-this.monstersGap].type == "none"){ 86 this.buffers[i][this.size-this.monstersGap] = this.makeSideCreature(); 87 } 88 else if(i == this.bufferPosition && quest.things[this.size-this.monstersGap].type == "none"){ 89 quest.things[this.size-this.monstersGap] = this.makeSideCreature(); 90 } 91 } 92 93 // We increase the time spent 94 this.timeSpent += 1; 95 }, 96 97 load : function(){ 98 // We set the first buffer position 99 this.bufferPosition = 3; 100 101 // We fill buffers 102 for(var i = 0; i < 7; i++){ 103 if(i != this.bufferPosition){ 104 this.buffers[i] = quest.fillWithNoneThings(); 105 } 106 } 107 108 // We add the devil 109 quest.things[this.size - 1] = this.makeDevil(); 110 111 // We add first doors 112 quest.things[this.size - 4] = this.makeDoor(); 113 for(var i = 0; i < 7; i++){ 114 if(i != 3) this.buffers[i][this.size - 4] = this.makeDoor(); 115 } 116 117 // We add second doors
118 quest.things[this.size - 6] = this.makeSpikyDoor(); 119 for(var i = 0; i < 7; i++){ 120 if(i != 3 && i != 5) this.buffers[i][this.size - 6] = this.makeSpikyDoor(); 121 } 122 this.buffers[5][this.size - 6] = this.makeDoor(); 123 124 // We add teleporting gates 125 quest.things[this.size - 3] = this.makeTeleportingGate(); 126 quest.things[this.size - 5] = this.makeTeleportingGate(); 127 for(var i = 0; i < 7; i++){ 128 if(i != 3){ 129 this.buffers[i][this.size - 3] = this.makeTeleportingGate(); 130 this.buffers[i][this.size - 5] = this.makeTeleportingGate(); 131 } 132 } 133 134 // We set the steps 135 this.addRockStep = 0; 136 this.step = 0; 137 138 // We set the time spent 139 this.timeSpent = 0; 140 }, 141 142 teleportCharacter : function(gatesIndex){ 143 var index = quest.getCharacterIndex(); 144 145 quest.things[0] = quest.things[index]; 146 quest.things[index] = quest.makeNoneThing(); 147 148 quest.things[gatesIndex] = quest.makeNoneThing(); 149 for(var i = 0; i < 7; i++){ 150 if(i != this.bufferPosition){ 151 this.buffers[i][gatesIndex] = quest.makeNoneThing(); 152 } 153 } 154 }, 155 156 checkStep1 : function(){ 157 var index = quest.getCharacterIndex(); 158 159 if(index >= this.size - 7) this.step = 1; 160 }, 161 162 checkStep2 : function(){ 163 for(var i = 0; i < 7; i++){ 164 if((i != this.bufferPosition && this.buffers[i][this.size-5].text != " * ") || (i == this.bufferPosition && quest.things[this.size-5].text != " * ")){ 165 this.teleportCharacter(this.size-5); 166 this.step = 2; 167 break; 168 } 169 } 170 }, 171 172 checkStep3 : function(){ 173 var index = quest.getCharacterIndex(); 174 175 if(index >= this.size - 5) this.step = 3; 176 }, 177 178 checkStep4 : function(){ 179 for(var i = 0; i < 7; i++){ 180 if((i != this.bufferPosition && this.buffers[i][this.size-3].text != " * ") || (i == this.bufferPosition && quest.things[this.size-3].text != " * ")){ 181 this.teleportCharacter(this.size-3); 182 this.step = 4; 183 this.timeSpent = 0; 184 break; 185 } 186 } 187 }, 188 189 goDown : function(){ 190 var pos = this.bufferPosition; 191 192 // If we're questing the hell 193 if(quest.weAreQuestingRightNow && land.getLandIndexFromName("Hell") == quest.currentLandIndex){ 194 // If we're not already at the buffer 2 195 if(this.bufferPosition != 6){ 196 // If we were able to swap, change the buffer position 197 if(this.swapBufferAndQuestThings(pos, pos + 1)){ 198 this.bufferPosition += 1; 199 this.checkDevil(); 200 quest.updateOnPage(); 201 } 202 } 203 } 204 }, 205 206 goUp : function(){ 207 var pos = this.bufferPosition; 208 209 // If we're questing the hell 210 if(quest.weAreQuestingRightNow && land.getLandIndexFromName("Hell") == quest.currentLandIndex){ 211 // If we're not already at the buffer 0 212 if(this.bufferPosition != 0){ 213 // If we were able to swap, change the buffer position 214 if(this.swapBufferAndQuestThings(pos, pos - 1)){ 215 this.bufferPosition -= 1; 216 this.checkDevil(); 217 quest.updateOnPage(); 218 } 219 } 220 } 221 }, 222 223 swapBufferAndQuestThings : function(now, after){ 224 var index = quest.getCharacterIndex(); 225 var character = quest.things[index]; 226 227 // If we will be able to move on the "after" buffer, we swap (if we have some hp, too) 228 if(this.buffers[after][index].type == "none" && character.hp > 0){ 229 // We save the quest things in the old buffer 230 this.buffers[now] = quest.things.slice(0); 231 // We delete the character from the old buffer 232 this.buffers[now][index] = quest.makeNoneThing(); 233 // We put the new buffer into the quest things 234 quest.things = this.buffers[after].slice(0); 235 // We add the character 236 quest.things[index] = character; 237 // We return true 238 return true; 239 } 240 241 // Else we return false 242 return false;
243 }, 244 245 checkDevil : function(){ 246 // If the devil isn't on the line of the character 247 if(quest.things[this.size-1].text != "DEV"){ 248 // We move it 249 for(var i = 0; i < 7; i++){ 250 if(i != this.bufferPosition && this.buffers[i][this.size-1].text == "DEV"){ 251 quest.things[this.size-1] = this.buffers[i][this.size-1]; 252 this.buffers[i][this.size-1] = quest.makeNoneThing(); 253 break; 254 } 255 } 256 } 257 }, 258 259 makeDevil : function(){ 260 return land.createMob("DEV", 250, 250, "religion", "It's the devil itself !", [drops.createDrop("candies", 100000)]); 261 }, 262 263 makeTeleportingGate : function(){ 264 return land.createMob(" * ", 120, 120, "none", "A teleporting gate, made by the devil itself.", []); 265 }, 266 267 makeMiddleCreature : function(){ 268 switch(this.step){ 269 case 0: 270 if(random.oneChanceOutOf(3)){ 271 return this.makeDemon(); 272 } 273 break; 274 case 2: 275 if(random.oneChanceOutOf(4)){ 276 return this.makeBanshee(); 277 } 278 break; 279 case 3: 280 if(random.oneChanceOutOf(3)){ 281 return castleKeep.makeFireball(); 282 } 283 break; 284 case 4: 285 if(this.timeSpent < 50 && this.timeSpent % 2 == 0){ 286 return castleStairs.makeGhost(); 287 } 288 else if(this.timeSpent < 70){ 289 // nothing 290 } 291 else if(this.timeSpent < 90){ 292 if(random.oneChanceOutOf(5)){ 293 return castleKeep.makeFireball(); 294 } 295 } 296 else if(this.timeSpent < 110){ 297 if(random.oneChanceOutOf(4)){ 298 return castleKeep.makeFireball(); 299 } 300 } 301 else if(this.timeSpent < 130){ 302 if(random.oneChanceOutOf(3)){ 303 return castleKeep.makeFireball(); 304 } 305 } 306 else if(this.timeSpent < 170){ 307 if(random.oneChanceOutOf(2)){ 308 return castleKeep.makeFireball(); 309 } 310 } 311 else{ 312 return castleKeep.makeFireball(); 313 } 314 break; 315 } 316 317 return quest.makeNoneThing(); 318 }, 319 320 makeSideCreature : function(){ 321 switch(this.step){ 322 case 0: 323 return this.makeMiddleCreature(); 324 break; 325 case 2: 326 if(random.oneChanceOutOf(5)){ 327 return castleStairs.makeGhost(); 328 } 329 break; 330 case 3: 331 if(random.oneChanceOutOf(4)){} // nothing 332 else{ 333 return castleStairs.makeGhost(); 334 } 335 break; 336 case 4: 337 return this.makeMiddleCreature(); 338 break; 339 } 340 341 return quest.makeNoneThing(); 342 }, 343 344 makeDemon : function(){ 345 return land.createMob("DEM", 90, 90, "demon claws", "A demon.", []); 346 }, 347 348 makeBanshee : function(){ 349 return land.createMob("BSH", 160, 160, "?", "A banshee, omen of death.", []); 350 }, 351 352 makeDoor : function(){ 353 return land.createMob("|-|", 300, 300, "none", "A strong door. Hard to break.", []); 354 }, 355 356 makeSpikyDoor : function(){ 357 return land.createMob("|-|", 300, 300, "spikes", "A strong door. Hard to break. There are spikes on it, it hurts !", []); 358 }, 359 360 getText : function(){ 361 // Create the text var 362 var text = ""; 363 364 // Add the i & k instructions 365 text += "<span style=\"color:red;\"><b>
365Press i to go up and k to go down.</b></span> (if it doesn't work, click on the page to gain focus)"; 366 367 text += "\n"; 368 369 // Open the span 370 text += "<span style=\"font-size:10px;\">"; 371 372 text += "\n"; 373 374 // We add buffers 375 for(var i = 0; i < 7; i++){ 376 if(i != this.bufferPosition){ 377 for(var j = 0; j < this.size; j++){ 378 if(this.buffers[i][j].type != "none"){ 379 text += this.buffers[i][j].text; 380 } 381 else text += " "; 382 } 383 } 384 else{ 385 for(var j = 0; j < this.size; j++){ 386 if(quest.things[j].type != "none"){ 387 text += quest.things[j].text; 388 } 389 else text += " "; 390 } 391 } 392 393 text += "\n"; 394 } 395 396 // We make the lava lake 397 for(var i = 0; i < Math.floor(this.size/2); i++){ 398 switch(this.lavaLakeStep){ 399 case 0: case 1: text += "_.-'-."; break; 400 case 2: case 3: text += "._.-'-"; break; 401 case 4: case 5: text += "-._.-'"; break; 402 case 6: case 7: text += "'-._.-"; break; 403 case 8: case 9: text += "-'-._."; break; 404 case 10: case 11: text += ".-'-._"; break; 405 } 406 } 407 408 // Close the span 409 text += "</span>" 410 411 return text; 412 } 413 414};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.