LootQuestScript.js (66259B)
1 /*(You can change the variables with a description 2 //By the way over 2000 lines of code (Way over by now!) 3 var block = 0; 4 var power = 0; 5 var gold = 0; 6 var sword = " "; 7 //change the variable below to give you higher damage (This one is he higher one) 8 var dam = 0; 9 //below is your starting hit points 10 var hp = 5; 11 var armor = "Meme Shirt"; 12 //DON'T CHANGE THE VARIABLE BELOW 13 var win = 0; 14 //Below is your total hit points (Change to give you health to survive!) 15 var totalhp = 5; 16 //below is also damage think of it like 'this weapon does 2 to 1 damage usually the lower one 17 var dam2 = 1; 18 //Below is your starting gold edit to over 9000 and you're rich 19 var totalg = 100;*/ 20 21 var level = 1; 22 23 let enemies = []; 24 25 var slaying = false; 26 27 //make player 28 let player = new Player(5, 100); 29 30 //make armor 31 let memeShirt = new Armor("Meme Shirt", 0, 1); 32 33 //make weapons 34 let woodenSword = new Weapon("Wooden Sword", 1, 3, 30); 35 36 /* name, level, hp, min attack, max attack, misschance% */ 37 let slime = new Enemy("Slime", 0, 3, 1, 2, 35); 38 let aslime = new Enemy("Angry Slime", 1, 2, 4, 0, 45); 39 40 function AddEnemy(e) { 41 enemies.push(e); 42 } 43 44 function SetSlaying(slaying) { 45 this.slaying = slaying; 46 } 47 48 StartGame(); 49 async function StartGame() { 50 console.println("Welcome to the game. Here is some free loot"); 51 await getUserInput(); 52 var gold = Math.floor(Math.random() * 20 + 5); 53 player.setGold(player.gold + gold); 54 player.equipWeapon(woodenSword); 55 player.equipArmor(memeShirt); 56 player.equip 57 console.println("You find a " + player.equip + ", a " + player.armor + " and " + gold + " gold"); 58 console.println(player.block); 59 await getUserInput(); 60 console.cls(); 61 StartLevel(GenLevel(window.level), GenEnemies(0, 1), window.level); 62 63 } 64 65 function GenLevel(levelNum) { 66 step = 4 + levelNum * 2; 67 var levelStr = ["["]; 68 for (var i = 0; i < step; i++) { 69 levelStr.push("_"); 70 } 71 levelStr.push("]"); 72 move = []; 73 for (var i = 0; i < step; i++) { 74 levelStrTemp = levelStr.slice(0); 75 levelStrTemp[i + 1] = "o/"; 76 stepStr = ""; 77 for (var j = 0; j < (levelStrTemp.length); j++) { 78 stepStr += levelStrTemp[j]; 79 } 80 move.push(stepStr); 81 } 82 return move 83 } 84 85 function GenEnemies(emin, emax) { 86 en = []; 87 for (let i = 0; i < enemies.length; i++) { 88 if (emin <= enemies[i].level <= (emax+1)) { 89 en.push(enemies[i]); 90 } 91 } 92 return en; 93 } 94 95 async function StartLevel(move, en, level) { 96 console.println("Welcome to the floor " + level + "!"); 97 await getUserInput(); 98 levelLoop: 99 for (var i = 0; i < (move.length); i++) { 100 console.println(move[i]); 101 await getUserInput(); 102 re = Math.floor((Math.random() * 5) + 1); 103 if (re > 3) { 104 console.println("Oh no a wild enemy!"); 105 await getUserInput(); 106 echoice = Math.floor(Math.random() * (en.length - 1)); 107 battle = false; 108 for (let j = 0; j < en.length; j++) { 109 if (echoice == j) { 110 battle = true; 111 console.println("Battle Start!"); 112 await Battle(move[i], Object.create(en[j])); 113 break; 114 } 115 } 116 if (!battle) { 117 console.println("Enemy got scared and ran away!"); 118 await getUserInput(); 119 } 120 } 121 console.cls(); 122 } 123 console.cls(); 124 console.println("Floor " + level + " complete!"); 125 await getUserInput(); 126 console.cls(); 127 } 128 129 async function Win(enemy) { 130 console.println("You did a killing headshot on the " + enemy.name); 131 await getUserInput(); 132 await Loot(); 133 } 134 135 async function GameOver() { 136 console.println("YOU DIED"); 137 await getUserInput(); 138 console.cls(); 139 throw "game end" 140 } 141 142 async function Loot() { 143 console.println("YOU WIN!"); 144 await getUserInput(); 145 console.println("Here is some loot..."); 146 //Random gold 147 gold = Math.floor(Math.random() * 50 + 5); 148 player.setGold(player.gold + gold); 149 console.println("Your gold: " + player.gold); 150 await getUserInput(); 151 randomh = Math.floor(Math.random() * 2); 152 //random heal 153 if (randomh) { 154 console.println("You heal!"); 155 player.setHp(player.hp + 2); 156 if (player.hp > player.totalhp) { 157 var hp = player.totalhp 158 console.println("You healed to full heath") 159 await getUserInput(); 160 } else { 161 console.println("You heal + 2") 162 console.println("Your heath: " + player.hp) 163 await getUserInput(); 164 } 165 } else { 166 console.println("No heal :("); 167 } 168 console.println("Time to move on..."); 169 await getUserInput(); 170 console.cls(); 171 } 172 173 async function Battle(step, enemy) { 174 //battle system 175 /*This is you! Slaying is the loop for the battle system. you = if you miss 176 round = damage of hardscope round1 = damage of noscope total = total damage*/ 177 slaying = true; 178 win = false; 179 180 while (slaying) { 181 console.cls(); 182 console.println(step); 183 console.println("Your Health: " + player.hp); 184 console.println(enemy.name + "'s Health: " + enemy.hp); 185 player.attack(enemy); 186 await getUserInput(); 187 if (!slaying) { 188 win = true; 189 break; 190 } 191 console.cls(); 192 console.println(step); 193 console.println("Your Health: " + player.hp); 194 console.println(enemy.name + "'s Health: " + enemy.hp); 195 enemy.attack(player); 196 await getUserInput(); 197 if (!slaying) { 198 win = false; 199 break; 200 } 201 } 202 203 if(win) { 204 await Win(enemy); 205 } else { 206 await GameOver(); 207 } 208 } 209 210 async function Game() { 211 /* This code was soooooooooooooooooooooooooo annoying (like feener grade) it 212 took me a while to figure out that I needed double break*/ 213 alert("Welcome to the random merchant!"); 214 var buyloop = true 215 while (buyloop) { 216 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 217 //Loops it 218 switch (buy) { 219 220 case "hp": 221 //checks your gold 222 if (totalg < 100) { 223 224 confirm("You can't buy that") 225 // if you want to leave or not (below) 226 var exit = prompt("Want to leave Y or N?").toLowerCase() 227 if (exit === "y") { 228 buyloop = false 229 break; 230 break 231 } else { 232 break 233 break 234 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 235 236 } 237 } else { 238 confirm("Here is your upgrade!") 239 confirm("You gained 2 hp") 240 totalg -= 100 241 totalhp += 2 242 console.println("Total gold: " + totalg) 243 var exit = prompt("Want to leave Y or N?").toLowerCase() 244 if (exit === "y") { 245 buyloop = false 246 break; 247 break 248 } else { 249 break 250 break 251 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 252 253 } 254 } 255 case "dam": 256 if (totalg < 100) { 257 confirm("You can't buy that") 258 var exit = prompt("Want to leave Y or N?").toLowerCase() 259 if (exit === "y") { 260 buyloop = false 261 break; 262 break 263 } else { 264 break 265 break 266 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 267 268 } 269 } else { 270 confirm("Here is your upgrade!") 271 confirm("You feel stronger!") 272 totalg -= 100 273 dam += 1 274 console.println("Total gold: " + totalg) 275 var exit = prompt("Want to leave Y or N?").toLowerCase() 276 if (exit === "y") { 277 buyloop = false 278 break; 279 break 280 } else { 281 break 282 break 283 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 284 285 } 286 } 287 288 case "heal": 289 290 if (totalg < 45) { 291 292 confirm("You can't buy that") 293 var exit = prompt("Want to leave Y or N?").toLowerCase() 294 if (exit === "y") { 295 buyloop = false 296 break; 297 break; 298 } else { 299 break 300 break 301 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 302 303 } 304 } else { 305 confirm("Here is your upgrade!") 306 confirm("You gained 2 hp") 307 totalg -= 45 308 var hp = totalhp; 309 console.println("Total gold: " + totalg) 310 var exit = prompt("Want to leave Y or N?").toLowerCase() 311 if (exit === "y") { 312 buyloop = false 313 break; 314 break 315 } else { 316 break 317 break 318 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 319 320 } 321 } 322 323 case "sw": 324 //Gambling OMG 325 confirm("Bid for steel sword!") 326 // The bids 327 var bid1 = Math.floor(Math.random() * 200 + 40) 328 var bid2 = Math.floor(Math.random() * 200 + 40) 329 var bid3 = Math.floor(Math.random() * 200 + 40) 330 var bid4 = Math.floor(Math.random() * 200 + 40) 331 console.println("Bids:") 332 console.println(bid1) 333 console.println(bid2) 334 console.println(bid3) 335 console.println(bid4) 336 await getUserInput(); 337 var bid = console.input("Your bid?") 338 if (bid > totalg) { 339 confirm("You can't buy that") 340 var exit = prompt("Want to leave Y or N?").toLowerCase() 341 if (exit === "y") { 342 buyloop = false 343 break; 344 break 345 } else { 346 break 347 break 348 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 349 350 } 351 } 352 if (bid < bid1) { 353 confirm("Not a high enough bid") 354 var exit = prompt("Want to leave Y or N?").toLowerCase() 355 if (exit === "y") { 356 buyloop = false 357 break; 358 break 359 } else { 360 break 361 break 362 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 363 364 } 365 } else if (bid < bid2) { 366 confirm("Not a high enough bid") 367 var exit = prompt("Want to leave Y or N?").toLowerCase() 368 if (exit === "y") { 369 buyloop = false 370 break; 371 break 372 } else { 373 break 374 break 375 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 376 377 } 378 } else if (bid < bid3) { 379 confirm("Not a high enough bid") 380 var exit = prompt("Want to leave Y or N?").toLowerCase() 381 if (exit === "y") { 382 buyloop = false 383 break; 384 break 385 } else { 386 break 387 break 388 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 389 390 } 391 } else if (bid < bid4) { 392 confirm("Not a high enough bid") 393 var exit = prompt("Want to leave Y or N?").toLowerCase() 394 if (exit === "y") { 395 buyloop = false 396 break; 397 break 398 } else { 399 break 400 break 401 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 402 403 } 404 } else if (sword === "Steel Sword") { 405 confirm("You already have that sword!") 406 var exit = prompt("Want to leave Y or N?").toLowerCase() 407 if (exit === "y") { 408 buyloop = false 409 break; 410 break 411 } else { 412 break 413 break 414 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 415 416 } 417 } else { 418 confirm("Here is your upgrade!") 419 confirm("You found a Steel Sword") 420 totalg -= bid 421 dam += 2 422 dam2 += 2 423 console.println("Total gold: " + totalg) 424 sword = "Steel Sword" 425 var exit = prompt("Want to leave Y or N?").toLowerCase() 426 if (exit === "y") { 427 buyloop = false 428 break; 429 break 430 } else { 431 break 432 break 433 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 434 435 } 436 } 437 438 439 440 case "1337": 441 if (totalg < 2001) { 442 confirm("You can't buy that") 443 var exit = prompt("Want to leave Y or N").toLowerCase() 444 if (exit === "y") { 445 buyloop = false 446 break; 447 break 448 } else { 449 break 450 break 451 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 452 453 } 454 } else { 455 confirm("Here is your upgrade!") 456 confirm("You found... what?... I dont even know what this is...") 457 totalg -= 2001 458 dam += 10 459 sword = "The Mlg" 460 console.println("Total gold: " + totalg) 461 var exit = prompt("Want to leave Y or N").toLowerCase() 462 if (exit === "y") { 463 buyloop = false 464 break; 465 break 466 } else { 467 break 468 break 469 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 470 471 } 472 } 473 474 475 default: 476 477 confirm("We don't sell anything like that.") 478 var exit = prompt("Want to leave Y or N").toLowerCase() 479 if (exit === "y") { 480 buyloop = false 481 break; 482 break 483 } else { 484 break 485 break 486 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 487 488 } 489 490 } 491 } 492 493 494 495 alert("Welcome to floor 2!") 496 for (var i = 0; i < 7; i++) { 497 var move = ["[o______]", "[_o_____]", "[__o____]", "[___o___]", "[____o__]", "[_____o_]", "[______o]"]; 498 var re = Math.floor(Math.random() * 5 + 1); 499 500 if (re > 3) { 501 alert("Oh no a wild enemy"); 502 var echoice = Math.floor(Math.random() * 3 + 1); 503 if (echoice <= 1) { 504 505 var em = Math.floor(Math.random() * 2); 506 var enemy = Math.floor(Math.random() * 4 - block + 1); 507 var ehp = 4; 508 var emn = "Slime"; 509 var etotal = 0; 510 511 } else if (echoice <= 2) { 512 var em = Math.floor(Math.random() * 3); 513 var enemy = Math.floor(Math.random() * 4 - block + 1); 514 var ehp = 3; 515 var emn = "Angry Slime"; 516 var etotal = 0; 517 518 } else { 519 var em = Math.floor(Math.random() * 2); 520 var enemy = Math.floor(Math.random() * 5 - block + 2); 521 var ehp = 3; 522 var emn = "Sparta"; 523 var etotal = 0; 524 525 } 526 527 //battle system 528 var slaying = true; 529 var you = Math.floor(Math.random() * 3); 530 var round = Math.floor(Math.random() * dam + dam2); 531 var round1 = Math.floor(Math.random() * 5 + 2); 532 var total = 0; 533 534 535 536 while (slaying) { 537 var clear = [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", ] 538 for (var j = 0; j < clear.length; j++) { 539 console.log(clear[j]) 540 } 541 console.log(move[i]) 542 console.log("Your Heath: " + hp); 543 console.log(emn + " Heath: " + ehp); 544 var block = 0; 545 var win = 0; 546 547 if (power > 2) { 548 549 550 var fight = prompt("Hardscope, Block or NoScope").toLowerCase(); 551 552 switch (fight) { 553 554 case "hardscope": 555 power += 1; 556 if (you) { 557 confirm("You hardscoped the slime with your " + sword + " and did " + round + " damage!"); 558 ehp -= round; 559 560 if (ehp <= 0) { 561 confirm("You did a killing headshot on the " + emn); 562 var win = 1 563 slaying = false; 564 break; 565 566 } else { 567 you = Math.floor(Math.random() * 3); 568 break; 569 } 570 571 } else { 572 573 confirm("You miss"); 574 you = Math.floor(Math.random() * 3); 575 break; 576 } 577 578 case "noscope": 579 power -= 2; 580 if (you) { 581 confirm("You noscoped the " + emn + " with your " + sword + " and did " + round1 + " damage!"); 582 ehp -= round1; 583 584 if (ehp <= 0) { 585 var win = 1; 586 confirm("You did a killing headshot on the " + emn); 587 slaying = false; 588 break; 589 590 591 } else { 592 593 you = Math.floor(Math.random() * 3); 594 break; 595 } 596 } else { 597 confirm("You miss") 598 you = Math.floor(Math.random() * 3); 599 break; 600 } 601 602 default: 603 var block = 1 604 power += 1; 605 break; 606 } 607 608 } else { 609 610 var fight = prompt("Hardscope or Block").toLowerCase(); 611 612 switch (fight) { 613 614 case "hardscope": 615 power += 1 616 if (you) { 617 confirm("You hardscoped the " + emn + " with your " + sword + " and did " + round + " damage!"); 618 ehp -= round; 619 620 if (ehp <= 0) { 621 var win = 1; 622 confirm("You did a killing headshot on the " + emn); 623 slaying = false; 624 break; 625 626 627 } else { 628 you = Math.floor(Math.random() * 3); 629 break; 630 } 631 632 } else { 633 confirm("You miss") 634 you = Math.floor(Math.random() * 3); 635 break; 636 } 637 default: 638 var block = 1 639 power += 1; 640 break; 641 } 642 643 } 644 if (win === 0) { 645 if (em) { 646 confirm("The " + emn + " hit you and did " + enemy + " damage!") 647 hp -= enemy 648 649 if (hp <= 0) { 650 var clear = [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", ] 651 for (var j = 0; j < clear.length; j++) { 652 console.log(clear[j]) 653 } 654 console.log(move[i]) 655 console.log("Your Heath: 0"); 656 console.log(emn + " Heath: " + ehp); 657 confirm("You died") 658 slaying = false 659 throw new Error("You Lose") 660 } else { 661 var em = Math.floor(Math.random() * 3); 662 663 } 664 } else { 665 confirm(emn + " missed!") 666 var em = Math.floor(Math.random() * 3); 667 668 } 669 } else { 670 var clear = [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", ] 671 for (var j = 0; j < clear.length; j++) { 672 console.log(clear[j]) 673 } 674 console.log(move[i]) 675 console.log("Your Heath: " + hp); 676 console.log(emn + " Heath: 0"); 677 alert("You win!") 678 alert("Here is some loot.") 679 680 var gold = Math.floor(Math.random() * 60 + 10); 681 totalg += gold; 682 alert("Your gold: " + totalg); 683 var randomh = Math.floor(Math.random() * 2); 684 var clear = [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", ] 685 for (var j = 0; j < clear.length; j++) { 686 console.log(clear[j]) 687 } 688 console.log(move[i]); 689 if (randomh) { 690 alert("You heal!") 691 hp += 2 692 if (hp > totalhp) { 693 var hp = totalhp 694 alert("You healed to full heath") 695 } else { 696 alert("You heal + 2") 697 alert("Your heath: " + hp) 698 } 699 } else {} 700 701 702 703 } 704 } 705 706 707 708 709 710 711 } else { 712 alert("Move"); 713 } 714 var clear = [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", ] 715 for (var j = 0; j < clear.length; j++) { 716 console.log(clear[j]) 717 } 718 console.log(move[i]); 719 } 720 721 alert("Welcome to the random merchant!"); 722 var buyloop = true 723 while (buyloop) { 724 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 725 726 switch (buy) { 727 728 case "hp": 729 730 if (totalg < 100) { 731 732 confirm("You can't buy that") 733 var exit = prompt("Want to leave Y or N?").toLowerCase() 734 if (exit === "y") { 735 buyloop = false 736 break; 737 break 738 } else { 739 break 740 break 741 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 742 743 } 744 } else { 745 confirm("Here is your upgrade!") 746 confirm("You gained 2 hp") 747 totalg -= 100 748 totalhp += 2 749 console.log("Total gold: " + totalg) 750 var exit = prompt("Want to leave Y or N?").toLowerCase() 751 if (exit === "y") { 752 buyloop = false 753 break; 754 break 755 } else { 756 break 757 break 758 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 759 760 } 761 } 762 case "dam": 763 if (totalg < 100) { 764 confirm("You can't buy that") 765 var exit = prompt("Want to leave Y or N?").toLowerCase() 766 if (exit === "y") { 767 buyloop = false 768 break; 769 break 770 } else { 771 break 772 break 773 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 774 775 } 776 } else { 777 confirm("Here is your upgrade!") 778 confirm("You feel stronger!") 779 totalg -= 100 780 dam += 1 781 console.log("Total gold: " + totalg) 782 var exit = prompt("Want to leave Y or N?").toLowerCase() 783 if (exit === "y") { 784 buyloop = false 785 break; 786 break 787 } else { 788 break 789 break 790 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 791 792 } 793 } 794 795 case "heal": 796 797 if (totalg < 45) { 798 799 confirm("You can't buy that") 800 var exit = prompt("Want to leave Y or N?").toLowerCase() 801 if (exit === "y") { 802 buyloop = false 803 break; 804 break; 805 } else { 806 break 807 break 808 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 809 810 } 811 } else { 812 confirm("Here is your upgrade!") 813 confirm("You gained 2 hp") 814 totalg -= 45 815 var hp = totalhp; 816 console.log("Total gold: " + totalg) 817 var exit = prompt("Want to leave Y or N?").toLowerCase() 818 if (exit === "y") { 819 buyloop = false 820 break; 821 break 822 } else { 823 break 824 break 825 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 826 827 } 828 } 829 830 case "sw": 831 confirm("Bid for Elastic Band Gun") 832 var bid1 = Math.floor(Math.random() * 300 + 40) 833 var bid2 = Math.floor(Math.random() * 300 + 40) 834 var bid3 = Math.floor(Math.random() * 300 + 40) 835 var bid4 = Math.floor(Math.random() * 167 + 40) 836 console.log("Bids:") 837 console.log(bid1) 838 console.log(bid2) 839 console.log(bid3) 840 console.log("Brett's bid: " + bid4) 841 var bid = prompt("Your bid?") 842 if (bid > totalg) { 843 confirm("You can't buy that") 844 var exit = prompt("Want to leave Y or N?").toLowerCase() 845 if (exit === "y") { 846 buyloop = false 847 break; 848 break 849 } else { 850 break 851 break 852 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 853 854 } 855 } 856 if (bid < bid1) { 857 confirm("Not a high enough bid") 858 var exit = prompt("Want to leave Y or N?").toLowerCase() 859 if (exit === "y") { 860 buyloop = false 861 break; 862 break 863 } else { 864 break 865 break 866 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 867 868 } 869 } else if (bid < bid2) { 870 confirm("Not a high enough bid") 871 var exit = prompt("Want to leave Y or N?").toLowerCase() 872 if (exit === "y") { 873 buyloop = false 874 break; 875 break 876 } else { 877 break 878 break 879 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 880 881 } 882 } else if (bid < bid3) { 883 confirm("Not a high enough bid") 884 var exit = prompt("Want to leave Y or N?").toLowerCase() 885 if (exit === "y") { 886 buyloop = false 887 break; 888 break 889 } else { 890 break 891 break 892 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 893 894 } 895 } else if (bid < bid4) { 896 confirm("Not a high enough bid") 897 var exit = prompt("Want to leave Y or N?").toLowerCase() 898 if (exit === "y") { 899 buyloop = false 900 break; 901 break 902 } else { 903 break 904 break 905 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 906 907 } 908 } else if (sword === "Elastic Band Gun") { 909 confirm("You already have that sword!") 910 var exit = prompt("Want to leave Y or N?").toLowerCase() 911 if (exit === "y") { 912 buyloop = false 913 break; 914 break 915 } else { 916 break 917 break 918 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 919 920 } 921 } else { 922 confirm("Here is your upgrade!") 923 confirm("You found a Elastic Band Gun") 924 totalg -= bid 925 if (sword === "Steel Sword") { 926 dam += 2 927 dam2 += 1 928 } else { 929 dam += 4 930 dam2 += 3 931 } 932 console.log("Total gold: " + totalg) 933 sword = "Elastic Band Gun" 934 var exit = prompt("Want to leave Y or N?").toLowerCase() 935 if (exit === "y") { 936 buyloop = false 937 break; 938 break 939 } else { 940 break 941 break 942 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 943 944 } 945 } 946 947 948 949 case "1337": 950 if (totalg < 2001) { 951 confirm("You can't buy that") 952 var exit = prompt("Want to leave Y or N").toLowerCase() 953 if (exit === "y") { 954 buyloop = false 955 break; 956 break 957 } else { 958 break 959 break 960 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 961 962 } 963 } else { 964 confirm("Here is your upgrade!") 965 confirm("You found... what?... I dont even know what this is...") 966 totalg -= 2001 967 dam += 10 968 dam2 += 2 969 sword = "The Mlg" 970 console.log("Total gold: " + totalg) 971 var exit = prompt("Want to leave Y or N").toLowerCase() 972 if (exit === "y") { 973 buyloop = false 974 break; 975 break 976 } else { 977 break 978 break 979 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 980 981 } 982 } 983 984 985 default: 986 987 confirm("We don't sell anything like that.") 988 var exit = prompt("Want to leave Y or N").toLowerCase() 989 if (exit === "y") { 990 buyloop = false 991 break; 992 break 993 } else { 994 break 995 break 996 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 997 998 } 999 1000 } 1001 } 1002 1003 1004 1005 1006 alert("Welcome to floor 3!") 1007 for (var i = 0; i < 8; i++) { 1008 var move = ["[o_______]", "[_o______]", "[__o_____]", "[___o____]", "[____o___]", "[_____o__]", "[______o_]", "[_______o]"]; 1009 var re = Math.floor(Math.random() * 5 + 1); 1010 1011 if (re > 3) { 1012 alert("Oh no a wild enemy"); 1013 var echoice = Math.floor(Math.random() * 6 + 1); 1014 if (echoice <= 1) { 1015 1016 var em = Math.floor(Math.random() * 2); 1017 var enemy = Math.floor(Math.random() * 4 - block + 1); 1018 var ehp = 4; 1019 var emn = "Slime"; 1020 var etotal = 0; 1021 1022 } else if (echoice <= 3) { 1023 var em = Math.floor(Math.random() * 3); 1024 var enemy = Math.floor(Math.random() * 4 - block + 1); 1025 var ehp = 3; 1026 var emn = "Angry Slime"; 1027 var etotal = 0; 1028 1029 } else { 1030 var em = Math.floor(Math.random() * 3); 1031 var enemy = Math.floor(Math.random() * 5 - block + 2); 1032 var ehp = 5; 1033 var emn = "Doge"; 1034 var etotal = 0; 1035 } 1036 1037 //battle system 1038 var slaying = true; 1039 var you = Math.floor(Math.random() * 3); 1040 var round = Math.floor(Math.random() * dam + dam2); 1041 var round1 = Math.floor(Math.random() * 5 + 2); 1042 var total = 0; 1043 1044 1045 1046 while (slaying) { 1047 var clear = [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", ] 1048 for (var j = 0; j < clear.length; j++) { 1049 console.log(clear[j]) 1050 } 1051 console.log(move[i]) 1052 console.log("Your Heath: " + hp); 1053 console.log(emn + " Heath: " + ehp); 1054 var block = 0; 1055 var win = 0; 1056 1057 if (power > 2) { 1058 1059 1060 var fight = prompt("Hardscope, Block or NoScope").toLowerCase(); 1061 1062 switch (fight) { 1063 1064 case "hardscope": 1065 power += 1; 1066 if (you) { 1067 confirm("You hardscoped the slime with your " + sword + " and did " + round + " damage!"); 1068 ehp -= round; 1069 1070 if (ehp <= 0) { 1071 confirm("You did a killing headshot on the " + emn); 1072 var win = 1 1073 slaying = false; 1074 break; 1075 1076 } else { 1077 you = Math.floor(Math.random() * 3); 1078 break; 1079 } 1080 1081 } else { 1082 1083 confirm("You miss"); 1084 you = Math.floor(Math.random() * 3); 1085 break; 1086 } 1087 1088 case "noscope": 1089 power -= 2; 1090 if (you) { 1091 confirm("You noscoped the " + emn + " with your " + sword + " and did " + round1 + " damage!"); 1092 ehp -= round1; 1093 1094 if (ehp <= 0) { 1095 var win = 1; 1096 confirm("You did a killing headshot on the " + emn); 1097 slaying = false; 1098 break; 1099 1100 1101 } else { 1102 1103 you = Math.floor(Math.random() * 3); 1104 break; 1105 } 1106 } else { 1107 confirm("You miss") 1108 you = Math.floor(Math.random() * 3); 1109 break; 1110 } 1111 1112 default: 1113 var block = 1 1114 power += 1; 1115 break; 1116 } 1117 1118 } else { 1119 1120 var fight = prompt("Hardscope or Block").toLowerCase(); 1121 1122 switch (fight) { 1123 1124 case "hardscope": 1125 power += 1 1126 if (you) { 1127 confirm("You hardscoped the " + emn + " with your " + sword + " and did " + round + " damage!"); 1128 ehp -= round; 1129 1130 if (ehp <= 0) { 1131 var win = 1; 1132 confirm("You did a killing headshot on the " + emn); 1133 slaying = false; 1134 break; 1135 1136 1137 } else { 1138 you = Math.floor(Math.random() * 3); 1139 break; 1140 } 1141 1142 } else { 1143 confirm("You miss") 1144 you = Math.floor(Math.random() * 3); 1145 break; 1146 } 1147 default: 1148 var block = 1 1149 power += 1; 1150 break; 1151 } 1152 1153 } 1154 if (win === 0) { 1155 if (em) { 1156 confirm("The " + emn + " hit you and did " + enemy + " damage!") 1157 hp -= enemy 1158 1159 if (hp <= 0) { 1160 var clear = [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", ] 1161 for (var j = 0; j < clear.length; j++) { 1162 console.log(clear[j]) 1163 } 1164 console.log(move[i]) 1165 console.log("Your Heath: 0"); 1166 console.log(emn + " Heath: " + ehp); 1167 confirm("You died") 1168 slaying = false 1169 throw new Error("You Lose") 1170 } else { 1171 var em = Math.floor(Math.random() * 3); 1172 1173 } 1174 } else { 1175 confirm(emn + " missed!") 1176 var em = Math.floor(Math.random() * 3); 1177 1178 } 1179 } else { 1180 var clear = [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", ] 1181 for (var j = 0; j < clear.length; j++) { 1182 console.log(clear[j]) 1183 } 1184 console.log(move[i]) 1185 console.log("Your Heath: " + hp); 1186 console.log(emn + " Heath: 0"); 1187 alert("You win!") 1188 alert("Here is some loot.") 1189 1190 var gold = Math.floor(Math.random() * 70 + 15); 1191 totalg += gold; 1192 alert("Your gold: " + totalg); 1193 var randomh = Math.floor(Math.random() * 2); 1194 var clear = [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", ] 1195 for (var j = 0; j < clear.length; j++) { 1196 console.log(clear[j]) 1197 } 1198 console.log(move[i]); 1199 if (randomh) { 1200 alert("You heal!") 1201 hp += 2 1202 if (hp > totalhp) { 1203 var hp = totalhp 1204 alert("You healed to full heath") 1205 } else { 1206 alert("You heal + 2") 1207 alert("Your heath: " + hp) 1208 } 1209 } else {} 1210 1211 1212 1213 } 1214 } 1215 1216 1217 1218 1219 1220 1221 } else { 1222 alert("Move"); 1223 } 1224 var clear = [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", ] 1225 for (var j = 0; j < clear.length; j++) { 1226 console.log(clear[j]) 1227 } 1228 console.log(move[i]); 1229 } 1230 1231 1232 1233 alert("Welcome to the random merchant!"); 1234 var buyloop = true 1235 while (buyloop) { 1236 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1237 1238 switch (buy) { 1239 1240 case "hp": 1241 1242 if (totalg < 100) { 1243 1244 confirm("You can't buy that") 1245 var exit = prompt("Want to leave Y or N?").toLowerCase() 1246 if (exit === "y") { 1247 buyloop = false 1248 break; 1249 break 1250 } else { 1251 break 1252 break 1253 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1254 1255 } 1256 } else { 1257 confirm("Here is your upgrade!") 1258 confirm("You gained 2 hp") 1259 totalg -= 100 1260 totalhp += 2 1261 console.log("Total gold: " + totalg) 1262 var exit = prompt("Want to leave Y or N?").toLowerCase() 1263 if (exit === "y") { 1264 buyloop = false 1265 break; 1266 break 1267 } else { 1268 break 1269 break 1270 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1271 1272 } 1273 } 1274 case "dam": 1275 if (totalg < 100) { 1276 confirm("You can't buy that") 1277 var exit = prompt("Want to leave Y or N?").toLowerCase() 1278 if (exit === "y") { 1279 buyloop = false 1280 break; 1281 break 1282 } else { 1283 break 1284 break 1285 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1286 1287 } 1288 } else { 1289 confirm("Here is your upgrade!") 1290 confirm("You feel stronger!") 1291 totalg -= 100 1292 dam += 1 1293 console.log("Total gold: " + totalg) 1294 var exit = prompt("Want to leave Y or N?").toLowerCase() 1295 if (exit === "y") { 1296 buyloop = false 1297 break; 1298 break 1299 } else { 1300 break 1301 break 1302 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1303 1304 } 1305 } 1306 1307 case "heal": 1308 1309 if (totalg < 45) { 1310 1311 confirm("You can't buy that") 1312 var exit = prompt("Want to leave Y or N?").toLowerCase() 1313 if (exit === "y") { 1314 buyloop = false 1315 break; 1316 break; 1317 } else { 1318 break 1319 break 1320 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1321 1322 } 1323 } else { 1324 confirm("Here is your upgrade!") 1325 confirm("You gained 2 hp") 1326 totalg -= 45 1327 var hp = totalhp; 1328 console.log("Total gold: " + totalg) 1329 var exit = prompt("Want to leave Y or N?").toLowerCase() 1330 if (exit === "y") { 1331 buyloop = false 1332 break; 1333 break 1334 } else { 1335 break 1336 break 1337 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1338 1339 } 1340 } 1341 1342 case "sw": 1343 confirm("Bid for Dlc Gun") 1344 var bid1 = Math.floor(Math.random() * 400 + 40) 1345 var bid2 = Math.floor(Math.random() * 400 + 40) 1346 var bid3 = Math.floor(Math.random() * 400 + 40) 1347 var bid4 = Math.floor(Math.random() * 167 + 40) 1348 console.log("Bids:") 1349 console.log(bid1) 1350 console.log(bid2) 1351 console.log(bid3) 1352 console.log("Brett's bid: " + bid4) 1353 var bid = prompt("Your bid?") 1354 if (bid > totalg) { 1355 confirm("You can't buy that") 1356 var exit = prompt("Want to leave Y or N?").toLowerCase() 1357 if (exit === "y") { 1358 buyloop = false 1359 break; 1360 break 1361 } else { 1362 break 1363 break 1364 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1365 1366 } 1367 } 1368 if (bid < bid1) { 1369 confirm("Not a high enough bid") 1370 var exit = prompt("Want to leave Y or N?").toLowerCase() 1371 if (exit === "y") { 1372 buyloop = false 1373 break; 1374 break 1375 } else { 1376 break 1377 break 1378 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1379 1380 } 1381 } else if (bid < bid2) { 1382 confirm("Not a high enough bid") 1383 var exit = prompt("Want to leave Y or N?").toLowerCase() 1384 if (exit === "y") { 1385 buyloop = false 1386 break; 1387 break 1388 } else { 1389 break 1390 break 1391 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1392 1393 } 1394 } else if (bid < bid3) { 1395 confirm("Not a high enough bid") 1396 var exit = prompt("Want to leave Y or N?").toLowerCase() 1397 if (exit === "y") { 1398 buyloop = false 1399 break; 1400 break 1401 } else { 1402 break 1403 break 1404 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1405 1406 } 1407 } else if (bid < bid4) { 1408 confirm("Not a high enough bid") 1409 var exit = prompt("Want to leave Y or N?").toLowerCase() 1410 if (exit === "y") { 1411 buyloop = false 1412 break; 1413 break 1414 } else { 1415 break 1416 break 1417 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1418 1419 } 1420 } else if (sword === "Dlc Gun") { 1421 confirm("You already have that sword!") 1422 var exit = prompt("Want to leave Y or N?").toLowerCase() 1423 if (exit === "y") { 1424 buyloop = false 1425 break; 1426 break 1427 } else { 1428 break 1429 break 1430 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1431 1432 } 1433 } else { 1434 confirm("Here is your upgrade!") 1435 confirm("You found a Dlc Gun") 1436 totalg -= bid 1437 if (sword === "Steel Sword") { 1438 dam += 2 1439 dam2 += 2 1440 } else if (sword === "Elastic Band Gun") { 1441 dam + 1 1442 dam2 + 1 1443 } else { 1444 dam += 6 1445 dam2 += 5 1446 } 1447 1448 console.log("Total gold: " + totalg) 1449 sword = "Dlc Gun" 1450 var exit = prompt("Want to leave Y or N?").toLowerCase() 1451 if (exit === "y") { 1452 buyloop = false 1453 break; 1454 break 1455 } else { 1456 break 1457 break 1458 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1459 1460 } 1461 } 1462 1463 1464 1465 case "1337": 1466 if (totalg < 2001) { 1467 confirm("You can't buy that") 1468 var exit = prompt("Want to leave Y or N").toLowerCase() 1469 if (exit === "y") { 1470 buyloop = false 1471 break; 1472 break 1473 } else { 1474 break 1475 break 1476 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1477 1478 } 1479 } else { 1480 confirm("Here is your upgrade!") 1481 confirm("You found... what?... I dont even know what this is...") 1482 totalg -= 2001 1483 dam += 10 1484 dam2 += 2 1485 sword = "The Mlg" 1486 console.log("Total gold: " + totalg) 1487 var exit = prompt("Want to leave Y or N").toLowerCase() 1488 if (exit === "y") { 1489 buyloop = false 1490 break; 1491 break 1492 } else { 1493 break 1494 break 1495 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1496 1497 } 1498 } 1499 1500 1501 default: 1502 1503 confirm("We don't sell anything like that.") 1504 var exit = prompt("Want to leave Y or N").toLowerCase() 1505 if (exit === "y") { 1506 buyloop = false 1507 break; 1508 break 1509 } else { 1510 break 1511 break 1512 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1513 1514 } 1515 1516 } 1517 } 1518 1519 1520 1521 1522 1523 1524 alert("Welcome to floor 4!") 1525 for (var i = 0; i < 9; i++) { 1526 var move = ["[o________]", "[_o_______]", "[__o______]", "[___o_____]", "[____o____]", "[_____o___]", "[______o__]", "[_______o_]", "[________o]"]; 1527 var re = Math.floor(Math.random() * 5 + 1); 1528 1529 if (re > 3) { 1530 alert("Oh no a wild enemy"); 1531 var echoice = Math.floor(Math.random() * 8 + 1); 1532 if (echoice <= 4) { 1533 var em = Math.floor(Math.random() * 3); 1534 var enemy = Math.floor(Math.random() * 6 - block + 3); 1535 var ehp = 7; 1536 var emn = "Pepe"; 1537 var etotal = 0; 1538 1539 1540 } else if (echoice <= 1) { 1541 var em = Math.floor(Math.random() * 3); 1542 var enemy = Math.floor(Math.random() * 4 - block + 1); 1543 var ehp = 3; 1544 var emn = "Angry Slime"; 1545 var etotal = 0; 1546 1547 } else if (echoice <= 6) { 1548 var em = Math.floor(Math.random() * 4); 1549 var enemy = Math.floor(Math.random() * 10 - block + 1); 1550 var ehp = 8; 1551 var emn = "Troll Face"; 1552 var etotal = 0; 1553 1554 } else { 1555 var em = Math.floor(Math.random() * 3); 1556 var enemy = Math.floor(Math.random() * 5 - block + 2); 1557 var ehp = 5; 1558 var emn = "Doge"; 1559 var etotal = 0; 1560 } 1561 1562 //battle system 1563 var slaying = true; 1564 var you = Math.floor(Math.random() * 3); 1565 var round = Math.floor(Math.random() * dam + dam2); 1566 var round1 = Math.floor(Math.random() * 5 + 2); 1567 var total = 0; 1568 1569 1570 1571 while (slaying) { 1572 var clear = [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", ] 1573 for (var j = 0; j < clear.length; j++) { 1574 console.log(clear[j]) 1575 } 1576 console.log(move[i]) 1577 console.log("Your Heath: " + hp); 1578 console.log(emn + " Heath: " + ehp); 1579 var block = 0; 1580 var win = 0; 1581 1582 if (power > 2) { 1583 1584 1585 var fight = prompt("Hardscope, Block or NoScope").toLowerCase(); 1586 1587 switch (fight) { 1588 1589 case "hardscope": 1590 power += 1; 1591 if (you) { 1592 confirm("You hardscoped the slime with your " + sword + " and did " + round + " damage!"); 1593 ehp -= round; 1594 1595 if (ehp <= 0) { 1596 confirm("You did a killing headshot on the " + emn); 1597 var win = 1 1598 slaying = false; 1599 break; 1600 1601 } else { 1602 you = Math.floor(Math.random() * 3); 1603 break; 1604 } 1605 1606 } else { 1607 1608 confirm("You miss"); 1609 you = Math.floor(Math.random() * 3); 1610 break; 1611 } 1612 1613 case "noscope": 1614 power -= 2; 1615 if (you) { 1616 confirm("You noscoped the " + emn + " with your " + sword + " and did " + round1 + " damage!"); 1617 ehp -= round1; 1618 1619 if (ehp <= 0) { 1620 var win = 1; 1621 confirm("You did a killing headshot on the " + emn); 1622 slaying = false; 1623 break; 1624 1625 1626 } else { 1627 1628 you = Math.floor(Math.random() * 3); 1629 break; 1630 } 1631 } else { 1632 confirm("You miss") 1633 you = Math.floor(Math.random() * 3); 1634 break; 1635 } 1636 1637 default: 1638 var block = 1 1639 power += 1; 1640 break; 1641 } 1642 1643 } else { 1644 1645 var fight = prompt("Hardscope or Block").toLowerCase(); 1646 1647 switch (fight) { 1648 1649 case "hardscope": 1650 power += 1 1651 if (you) { 1652 confirm("You hardscoped the " + emn + " with your " + sword + " and did " + round + " damage!"); 1653 ehp -= round; 1654 1655 if (ehp <= 0) { 1656 var win = 1; 1657 confirm("You did a killing headshot on the " + emn); 1658 slaying = false; 1659 break; 1660 1661 1662 } else { 1663 you = Math.floor(Math.random() * 3); 1664 break; 1665 } 1666 1667 } else { 1668 confirm("You miss") 1669 you = Math.floor(Math.random() * 3); 1670 break; 1671 } 1672 default: 1673 var block = 1 1674 power += 1; 1675 break; 1676 } 1677 1678 } 1679 if (win === 0) { 1680 if (em) { 1681 confirm("The " + emn + " hit you and did " + enemy + " damage!") 1682 hp -= enemy 1683 1684 if (hp <= 0) { 1685 var clear = [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", ] 1686 for (var j = 0; j < clear.length; j++) { 1687 console.log(clear[j]) 1688 } 1689 console.log(move[i]) 1690 console.log("Your Heath: 0"); 1691 console.log(emn + " Heath: " + ehp); 1692 confirm("You died") 1693 slaying = false 1694 throw new Error("You Lose") 1695 } else { 1696 var em = Math.floor(Math.random() * 3); 1697 1698 } 1699 } else { 1700 confirm(emn + " missed!") 1701 var em = Math.floor(Math.random() * 3); 1702 1703 } 1704 } else { 1705 var clear = [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", ] 1706 for (var j = 0; j < clear.length; j++) { 1707 console.log(clear[j]) 1708 } 1709 console.log(move[i]) 1710 console.log("Your Heath: " + hp); 1711 console.log(emn + " Heath: 0"); 1712 alert("You win!") 1713 alert("Here is some loot.") 1714 1715 var gold = Math.floor(Math.random() * 80 + 20); 1716 totalg += gold; 1717 alert("Your gold: " + totalg); 1718 var randomh = Math.floor(Math.random() * 2); 1719 var clear = [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", ] 1720 for (var j = 0; j < clear.length; j++) { 1721 console.log(clear[j]) 1722 } 1723 console.log(move[i]); 1724 if (randomh) { 1725 alert("You heal!") 1726 hp += 2 1727 if (hp > totalhp) { 1728 var hp = totalhp 1729 alert("You healed to full heath") 1730 } else { 1731 alert("You heal + 2") 1732 alert("Your heath: " + hp) 1733 } 1734 } else {} 1735 1736 1737 1738 } 1739 } 1740 1741 1742 1743 1744 1745 1746 } else { 1747 alert("Move"); 1748 } 1749 var clear = [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", ] 1750 for (var j = 0; j < clear.length; j++) { 1751 console.log(clear[j]) 1752 } 1753 console.log(move[i]); 1754 } 1755 1756 1757 alert("Welcome to the random merchant!"); 1758 var buyloop = true 1759 while (buyloop) { 1760 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1761 1762 switch (buy) { 1763 1764 case "hp": 1765 1766 if (totalg < 100) { 1767 1768 confirm("You can't buy that") 1769 var exit = prompt("Want to leave Y or N?").toLowerCase() 1770 if (exit === "y") { 1771 buyloop = false 1772 break; 1773 break 1774 } else { 1775 break 1776 break 1777 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1778 1779 } 1780 } else { 1781 confirm("Here is your upgrade!") 1782 confirm("You gained 2 hp") 1783 totalg -= 100 1784 totalhp += 2 1785 console.log("Total gold: " + totalg) 1786 var exit = prompt("Want to leave Y or N?").toLowerCase() 1787 if (exit === "y") { 1788 buyloop = false 1789 break; 1790 break 1791 } else { 1792 break 1793 break 1794 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1795 1796 } 1797 } 1798 case "dam": 1799 if (totalg < 100) { 1800 confirm("You can't buy that") 1801 var exit = prompt("Want to leave Y or N?").toLowerCase() 1802 if (exit === "y") { 1803 buyloop = false 1804 break; 1805 break 1806 } else { 1807 break 1808 break 1809 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1810 1811 } 1812 } else { 1813 confirm("Here is your upgrade!") 1814 confirm("You feel stronger!") 1815 totalg -= 100 1816 dam += 1 1817 console.log("Total gold: " + totalg) 1818 var exit = prompt("Want to leave Y or N?").toLowerCase() 1819 if (exit === "y") { 1820 buyloop = false 1821 break; 1822 break 1823 } else { 1824 break 1825 break 1826 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1827 1828 } 1829 } 1830 1831 case "heal": 1832 1833 if (totalg < 45) { 1834 1835 confirm("You can't buy that") 1836 var exit = prompt("Want to leave Y or N?").toLowerCase() 1837 if (exit === "y") { 1838 buyloop = false 1839 break; 1840 break; 1841 } else { 1842 break 1843 break 1844 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1845 1846 } 1847 } else { 1848 confirm("Here is your upgrade!") 1849 confirm("You gained 2 hp") 1850 totalg -= 45 1851 var hp = totalhp; 1852 console.log("Total gold: " + totalg) 1853 var exit = prompt("Want to leave Y or N?").toLowerCase() 1854 if (exit === "y") { 1855 buyloop = false 1856 break; 1857 break 1858 } else { 1859 break 1860 break 1861 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1862 1863 } 1864 } 1865 1866 case "sw": 1867 confirm("Bid for candy") 1868 var bid1 = Math.floor(Math.random() * 2 + 1) 1869 var bid2 = Math.floor(Math.random() * 2 + 1) 1870 var bid3 = Math.floor(Math.random() * 3 + 2) 1871 var bid4 = Math.floor(Math.random() * 1.67 + 1) 1872 console.log("Bids:") 1873 console.log(bid1) 1874 console.log(bid2) 1875 console.log(bid3) 1876 console.log("Brett's bid: " + bid4) 1877 var bid = prompt("Your bid?") 1878 if (bid > totalg) { 1879 confirm("You can't buy that") 1880 var exit = prompt("Want to leave Y or N?").toLowerCase() 1881 if (exit === "y") { 1882 buyloop = false 1883 break; 1884 break 1885 } else { 1886 break 1887 break 1888 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1889 1890 } 1891 } 1892 if (bid < bid1) { 1893 confirm("Not a high enough bid") 1894 var exit = prompt("Want to leave Y or N?").toLowerCase() 1895 if (exit === "y") { 1896 buyloop = false 1897 break; 1898 break 1899 } else { 1900 break 1901 break 1902 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1903 1904 } 1905 } else if (bid < bid2) { 1906 confirm("Not a high enough bid") 1907 var exit = prompt("Want to leave Y or N?").toLowerCase() 1908 if (exit === "y") { 1909 buyloop = false 1910 break; 1911 break 1912 } else { 1913 break 1914 break 1915 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1916 1917 } 1918 } else if (bid < bid3) { 1919 confirm("Not a high enough bid") 1920 var exit = prompt("Want to leave Y or N?").toLowerCase() 1921 if (exit === "y") { 1922 buyloop = false 1923 break; 1924 break 1925 } else { 1926 break 1927 break 1928 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1929 1930 } 1931 } else if (bid < bid4) { 1932 confirm("Not a high enough bid") 1933 var exit = prompt("Want to leave Y or N?").toLowerCase() 1934 if (exit === "y") { 1935 buyloop = false 1936 break; 1937 break 1938 } else { 1939 break 1940 break 1941 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1942 1943 } 1944 } else if (sword === "candy") { 1945 confirm("You already have that sword!") 1946 var exit = prompt("Want to leave Y or N?").toLowerCase() 1947 if (exit === "y") { 1948 buyloop = false 1949 break; 1950 break 1951 } else { 1952 break 1953 break 1954 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1955 1956 } 1957 } else { 1958 confirm("Here is your upgrade!") 1959 confirm("You found a candy") 1960 totalg -= bid 1961 dam += 0 1962 dam2 += 0 1963 console.log("Total gold: " + totalg) 1964 sword = "candy" 1965 var exit = prompt("Want to leave Y or N?").toLowerCase() 1966 if (exit === "y") { 1967 buyloop = false 1968 break; 1969 break 1970 } else { 1971 break 1972 break 1973 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1974 1975 } 1976 } 1977 1978 1979 1980 case "1337": 1981 if (totalg < 2001) { 1982 confirm("You can't buy that") 1983 var exit = prompt("Want to leave Y or N").toLowerCase() 1984 if (exit === "y") { 1985 buyloop = false 1986 break; 1987 break 1988 } else { 1989 break 1990 break 1991 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 1992 1993 } 1994 } else { 1995 confirm("Here is your upgrade!") 1996 confirm("You found... what?... I dont even know what this is...") 1997 totalg -= 2001 1998 dam += 10 1999 dam2 += 2 2000 sword = "The Mlg" 2001 console.log("Total gold: " + totalg) 2002 var exit = prompt("Want to leave Y or N").toLowerCase() 2003 if (exit === "y") { 2004 buyloop = false 2005 break; 2006 break 2007 } else { 2008 break 2009 break 2010 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 2011 2012 } 2013 } 2014 2015 2016 default: 2017 2018 confirm("We don't sell anything like that.") 2019 var exit = prompt("Want to leave Y or N").toLowerCase() 2020 if (exit === "y") { 2021 buyloop = false 2022 break; 2023 break 2024 } else { 2025 break 2026 break 2027 var buy = prompt("Type hp for heath upgrade $100 Type heal to heal wounds $45 Type dam for damage upgrade $100 Type sw to bid for a sword Type 1337 for a elite sword $2001 ").toLowerCase() 2028 2029 } 2030 2031 } 2032 } 2033 2034 2035 2036 var win = 0 2037 var clear = [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", ] 2038 for (var j = 0; j < clear.length; j++) { 2039 console.log(clear[j]) 2040 alert("Welcome to floor 5") 2041 alert("Hi there, take a look in the console!") 2042 console.log(" \ /\ ") 2043 console.log(" ) ( ') < Hello") 2044 console.log(" ( / ) ") 2045 console.log(" \(__)| ") 2046 alert("") 2047 2048 var clear = [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", ] 2049 for (var j = 0; j < clear.length; j++) { 2050 console.log(clear[j]) 2051 } 2052 2053 console.log(" \ /\ ") 2054 console.log(" ) ( ') < I am the boss of this tower!") 2055 console.log(" ( / ) ") 2056 console.log(" \(__)| ") 2057 alert("") 2058 2059 var clear = [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", ] 2060 for (var j = 0; j < clear.length; j++) { 2061 console.log(clear[j]) 2062 } 2063 2064 console.log(" \ /\ ") 2065 console.log(" ) ( ') < Well, I guess I'm gunna have to kill you...") 2066 console.log(" ( / ) ") 2067 console.log(" \(__)| ") 2068 alert("") 2069 2070 var clear = [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", ] 2071 for (var j = 0; j < clear.length; j++) { 2072 console.log(clear[j]) 2073 } 2074 2075 console.log(" \ /\ ") 2076 console.log(" ) ( ') < Prepare To get rekt!") 2077 console.log(" ( / ) ") 2078 console.log(" \(__)| ") 2079 alert("") 2080 2081 var clear = [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", ] 2082 for (var j = 0; j < clear.length; j++) { 2083 console.log(clear[j]) 2084 } 2085 2086 console.log(" \ /\ ") 2087 console.log(" ) ( ') < Welcome to die!") 2088 console.log(" ( / ) ") 2089 console.log(" \(__)| ") 2090 2091 var slaying = true; 2092 var you = Math.floor(Math.random() * 3); 2093 var round = Math.floor(Math.random() * dam + dam2); 2094 var round1 = Math.floor(Math.random() * 5 + 2); 2095 var total = 0; 2096 var em = Math.floor(Math.random() * 3); 2097 var enemy = Math.floor(Math.random() * 10 - block + 3); 2098 var ehp = 20; 2099 var emn = "1337 Boss"; 2100 var etotal = 0; 2101 2102 2103 while (slaying) { 2104 var clear = [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", ] 2105 for (var j = 0; j < clear.length; j++) { 2106 console.log(clear[j]) 2107 } 2108 block = 0 2109 2110 2111 if (power > 2) { 2112 2113 2114 var fight = prompt("Hardscope, Block or NoScope").toLowerCase(); 2115 2116 switch (fight) { 2117 2118 case "hardscope": 2119 power += 1; 2120 if (you) { 2121 confirm("You hardscoped the slime with your " + sword + " and did " + round + " damage!"); 2122 total += round; 2123 2124 if (total >= ehp) { 2125 confirm("You did a killing headshot on the " + emn); 2126 slaying = false; 2127 break; 2128 2129 } else { 2130 you = Math.floor(Math.random() * 3); 2131 break; 2132 } 2133 2134 } else { 2135 2136 confirm("You miss"); 2137 you = Math.floor(Math.random() * 3); 2138 break; 2139 } 2140 2141 case "noscope": 2142 power -= 2; 2143 if (you) { 2144 confirm("You noscoped the " + emn + " with your " + sword + " and did " + round + " damage!"); 2145 total += round1; 2146 2147 if (total >= ehp) { 2148 win += 1; 2149 confirm("You did a killing headshot on the " + emn); 2150 slaying = false; 2151 break; 2152 2153 2154 } else { 2155 2156 you = Math.floor(Math.random() * 3); 2157 break; 2158 } 2159 2160 } 2161 2162 2163 default: 2164 block += 1 2165 power += 1 2166 break; 2167 } 2168 2169 } else { 2170 2171 var fight = prompt("Hardscope or Block").toLowerCase(); 2172 2173 switch (fight) { 2174 2175 case "hardscope": 2176 power += 1 2177 if (you) { 2178 confirm("You hardscoped the " + emn + " with your " + sword + " and did " + round + " damage!"); 2179 total += round; 2180 2181 if (total >= ehp) { 2182 win += 1; 2183 confirm("You did a killing headshot on the " + emn); 2184 slaying = false; 2185 break; 2186 2187 2188 } else { 2189 you = Math.floor(Math.random() * 3); 2190 break; 2191 } 2192 2193 } else { 2194 confirm("You miss") 2195 you = Math.floor(Math.random() * 3); 2196 break; 2197 } 2198 default: 2199 block += 1 2200 power += 1 2201 break; 2202 } 2203 2204 } 2205 if (win === 0) { 2206 if (em) { 2207 confirm("The " + emn + " hit you and did " + enemy + " damage!") 2208 etotal += enemy 2209 2210 if (etotal >= hp) { 2211 confirm("You died") 2212 slaying = false 2213 throw new Error("You Lose") 2214 } else { 2215 var em = Math.floor(Math.random() * 3); 2216 2217 } 2218 } else { 2219 console.println(emn + " missed!") 2220 await getUserInput(); 2221 var em = Math.floor(Math.random() * 3); 2222 2223 } 2224 } else { 2225 slaying = false 2226 break; 2227 } 2228 } 2229 } 2230 } 2231 2232 function getUserInput() { 2233 document.getElementById("pause").focus(); 2234 return new Promise((resolve, reject) => { 2235 $('#pause').keydown(function (e) { 2236 if (e.keyCode == 13) { 2237 const inputVal = $(this).val(); 2238 resolve(inputVal); 2239 } 2240 }); 2241 }); 2242 };