var initprompt = prompt("enter your username"); if (initprompt !== null) { if(initprompt === "") { initprompt = "random un-named person"; } var gameversion = "Beta 0.7" var debugpassword = "ZGVidWdsb2w="//you can try using this but it wont work lol B) var x = 0; var y = 0; var health = 10; var maxhealth = 10; var defense = 0; var baseattack = 2; var gold = 0; var equipmentdictionary = { "Weapon": "Nothing", "Armour": "Nothing", "Rings": [] }; var consumablearray = []; var weapondictionary = { "Nothing": 2, "Dagger": 4, "Sword": 9, "Enchanted Sword": 15, "Dual Enchanted Swords": 30, "Glock": 50, "Glizzy": 75, "Comically Large Spoon": 125, "British Shank": 300 }; var armourdictionary = { "Nothing": 0, "Leather": 0.1, "ChainMail": 0.15, "Iron Plated": 0.3, "Military Gear": 0.5, "Bandana": 0.75, "Yanke With No Brim":0.8 }; var ringdictionary = { "Silver": {"healthadd":5}, "Smooth Silver": {"healthadd":10}, "Gold": {"healthadd":15}, "Diamond": {"healthadd":40}, "Platinum": {"healthadd":100}, "Obamium": {"healthadd":250}, "Steel": {"attackadd":1}, "Enchanted Steel": {"attackadd":2}, "Saphire":{"attackadd":10}, "Ruby":{"attackadd":25}, "Vbuckite":{"attackadd":50}, "Emerald":{"healthmulti":0.1}, "Red Diamond":{"attackmulti":0.1}, "Master":{"healthadd":300,"attackadd":80}, "Debug":{"healthadd":10000,"attackadd":500} }; var shopdictionary = { "beginner magic shop":{ "Novice Health Potion":["Consumable",3], "Enchanted Steel":["Ring",20] }, "beginner market":{ "Pork Chop":["Consumable",7.5], "Smooth Silver":["Ring",20] } }; var loopvar = true; var atshop = false; var shopname = ""; var riddlesolved = false; var enemypresent = false; var enemyclass = ""; var enemyhealth = 0; var enemymaxhealth = 0; var enemyattack = 0; var enemyname = ""; var enemydropchance = 0; var enemydrops = []; var enemygolddrop = 0; var countsinceenemy = 10; var BossesAlive = { "gnome":true, "goblin chieftan":true } var gnomealive = true; var chiefgoblinalive = true; alert("Hello, "+ initprompt); function checkcoords(tx,ty){ if (x === tx && y === ty) { return true } } function checkheal(healamount){ let healthdif = 0; if (health > maxhealth) { healthdif = health-maxhealth; } health = health + healamount; if (health > maxhealth) { health = maxhealth+healthdif; } } function updatestats(){ let healthdifference = maxhealth - health; maxhealth = 10; let healthmultip = 1; let attackmultip = 1; for(var key in equipmentdictionary) { let value = equipmentdictionary[key]; if (key === "Weapon") { for(var key2 in weapondictionary) { let value2 = weapondictionary[key2]; if(value === key2) { baseattack = value2; } } }else if(key === "Armour") { for(var key3 in armourdictionary) { let value3 = armourdictionary[key3]; if(value === key3) { defense = value3; } } }else if(key === "Rings") { for(const ring of equipmentdictionary["Rings"]) { for(var key4 in ringdictionary) { let ringstatdictionary = ringdictionary[key4]; if(ring === key4) { for(var statname in ringstatdictionary) { let statvalue = ringstatdictionary[statname]; if(statname === "healthadd") { maxhealth = maxhealth + statvalue; }else if(statname === "attackadd"){ baseattack = baseattack + statvalue; }else if(statname === "healthmulti"){ healthmultip = healthmultip + statvalue; }else if(statname === "attackmulti") { attackmultip = attackmultip + statvalue; } } } } } } maxhealth = maxhealth * healthmultip; baseattack = baseattack * attackmultip; health = maxhealth; health = health - healthdifference; } } updatestats(); function moneyround(roundingnumber){ return Math.round(roundingnumber*100)/100 } var gsh1 = true; var gsh2 = true; var hf = true; var bms = true; var gm = true; function move(movevaru,combatvar){ let movevar = movevaru.toLowerCase(); let words = movevar.split(' '); if(movevar==="up"||movevar === "u"){ if(combatvar === true){ let movealert = alert("You cant move while in combat."); }else{ y = y + 1; return y } }else if(movevar === "down"||movevar === "d") { if(combatvar === true){ let movealert = alert("You cant move while in combat."); }else{ y = y - 1; return y } }else if(movevar === "right"||movevar === "r") { if(combatvar === true){ let movealert = alert("You cant move while in combat."); }else{ x = x + 1; return y } }else if(movevar === "left"||movevar === "l") { if(combatvar === true){ let movealert = alert("You cant move while in combat."); }else{ x = x - 1; return y } }else if(movevar === "stats"||movevar === "s") { let statalert = alert("Your health: "+health+"\nYour max health: "+maxhealth+"\nYour damage: "+baseattack+"\nYour defense: "+defense); }else if(movevar ==="cmds") { let cmdalert = alert("Commands:\nright\nleft\nup\ndown\nstats\nattack\ninventory\nsteal\nshoplist\nbuy\ninfo\ncmds\nSome commands have one letter alliases."); }else if(movevar === "attack") { if(enemypresent === true) { enemyhealth = enemyhealth - baseattack; let attackalert = alert("Pow! you did "+baseattack+" damage. the enemies health is now "+enemyhealth); }else { let attackalert = alert("There isnt anything to attack."); } }else if(words[0] === "use") { let secondword = ""; for (const word of words) { if (words.indexOf(word) !== 0) { if (words.indexOf(word) === 1) { secondword = secondword + word; }else{ secondword = secondword +" "+word; } } } if (consumablearray.map((a) => { return a.toLowerCase() }).includes(secondword)) { let itemtext = ""; let defaultalertenabled = true; let notreuseable = true; if (secondword === "novice health potion") { itemtext = "Novice Health Potion" checkheal(10) }else if(secondword === "pork chop") { itemtext = "Pork Chop" checkheal(25) }else if(secondword === "benus milk"){ }else if(secondword === "gnome trophie"){ defaultalertenabled = false; notreuseable = false; let gtalert = alert("The gnome trophie shines brightly."); }else if(secondword === "boss health potion"){ itemtext = "Boss Health Potion"; defaultalertenabled = false; health = health + maxhealth; let bhpalert = alert("You pour the glistening golden syrup down your throat. Instantly, all of your injuries are healed, from minor scrapes to crippling wounds. A strange energy flows through your veins, protecting you. "); } if (notreuseable) { let index = consumablearray.indexOf(itemtext); if (index > -1) { consumablearray.splice(index, 1); } } if (defaultalertenabled) { let consumptionalert = alert("You consumed/used the "+itemtext); } }else { let usealert = alert("You dont have that item, or it doesnt exist."); } }else if(movevar === "inventory"||movevar === "i") { let textthing = "Your armour: "+equipmentdictionary["Armour"]+"\nYour weapon: "+equipmentdictionary["Weapon"]+"\nYour rings: "; let conindex2 = 1; for(const ring of equipmentdictionary["Rings"]){ if (conindex2 !== equipmentdictionary["Rings"].length) { textthing = textthing + ring+", "; }else{ textthing = textthing + ring; } conindex2 = conindex2 + 1; } if (equipmentdictionary["Rings"].length === 0) { textthing = textthing+ "Nothing"; } textthing = textthing+"\nYour consumables: "; let conindex = 1; for(const consumable of consumablearray){ if (conindex !== consumablearray.length) { textthing = textthing + consumable+", "; }else{ textthing = textthing + consumable; } conindex = conindex + 1; } if (consumablearray.length === 0) { textthing = textthing + "Nothing"; } textthing = textthing + "\nYour gold: "+gold; let textalert = alert(textthing); }else if(movevar === "steal") { if (enemypresent === false) { if (checkcoords(-5,3) && gsh1 === true) { gsh1 = false; if(weapondictionary["Sword"] > weapondictionary[equipmentdictionary["Weapon"]]) { equipmentdictionary["Weapon"] = "Sword"; updatestats(); let lootalert = alert("You found a Sword!"); }else { let lootalert = alert("You found a Sword, but it did less damage than your current weapon so you didn't take it."); } }else if(checkcoords(5,-3) && gsh2 === true) { gsh2 = false; if(armourdictionary["Leather"] > armourdictionary[equipmentdictionary["Armour"]]) { equipmentdictionary["Armour"] = "Leather"; updatestats(); let lootalert = alert("You found Leather Armour!"); }else { let lootalert = alert("You found Leather Armour, but gave it less defense than your current armour so you didn't take it."); } }else if(checkcoords(7,7) && hf === true) { hf = false; let moneyamount = moneyround(Math.floor(Math.random() * 20)); gold = moneyround(gold + moneyamount); let lootalert = alert("You found "+moneyamount+" gold sitting at the bottom of the fountain."); }else { let lootalert = alert("There is nothing to steal."); } }else { let noalert = alert("You cant steal anything while in battle."); } }else if(movevar === "info"||movevar === "information") { let infoalert = alert("This game was made by Curtis.\nYou can find more information, and even mods in the discord server.\nDiscord server link: https://discord.gg/3xrFRrtskY"); }else if(movevar === "shoplist"||movevar === "shop list") { if (atshop) { let shoplisttext = "Shop name: "+shopname+"\n\n"; for (var item in shopdictionary[shopname]) { var itemdata = shopdictionary[shopname][item]; shoplisttext = shoplisttext + "Item: "+item+", Type: "+itemdata[0]+", Price: "+itemdata[1]+"\n"; } let shoplistalert = alert(shoplisttext); }else{ let shopalert = alert("You arent at a shop."); } }else if(words[0] === "buy"){ if (atshop) { let lowercaseitemkeys = Object.keys(shopdictionary[shopname]).map((a) => { return a.toLowerCase() }); let normalcaseitemkeys = Object.keys(shopdictionary[shopname]); let secondword = ""; for (const word of words) { if (words.indexOf(word) !== 0) { if (words.indexOf(word) === 1) { secondword = secondword + word; }else{ secondword = secondword +" "+word; } } } if (lowercaseitemkeys.includes(secondword.toLowerCase())) { let bothindex = lowercaseitemkeys.indexOf(secondword.toLowerCase()); let normalkey = normalcaseitemkeys[bothindex]; let iteminfoarray = shopdictionary[shopname][normalkey]; if (iteminfoarray[1] <= gold) { let receittext = ""; if (iteminfoarray[0] === "Weapon"){ if (equipmentdictionary["Weapon"] !== normalkey&&weapondictionary[normalkey] > weapondictionary[equipmentdictionary["Weapon"]]) { equipmentdictionary["Weapon"] = normalkey; gold = moneyround(gold - iteminfoarray[1]); receittext = "You bought the "+normalkey+" for "+iteminfoarray[1]+" gold."; }else{ receittext = "That weapon does less damage than your current weapon, so you didnt buy it."; } }else if (iteminfoarray[0] === "Armour"){ if (equipmentdictionary["Armour"] !== normalkey&&armourdictionary[normalkey] > armourdictionary[equipmentdictionary["Armour"]]) { equipmentdictionary["Armour"] = normalkey; gold = moneyround(gold - iteminfoarray[1]); receittext = "You bought the "+normalkey+" for "+iteminfoarray[1]+" gold."; }else{ receittext = "That armour gives less defense than your current armour, so you didnt buy it."; } }else if (iteminfoarray[0] === "Ring"){ if (equipmentdictionary["Rings"].includes(normalkey) === false){ equipmentdictionary["Rings"].push(normalkey); gold = moneyround(gold - iteminfoarray[1]); receittext = "You bought the "+normalkey+" for "+iteminfoarray[1]+" gold."; }else{ receittext = "You already have that ring, so you didnt buy another one." } }else if (iteminfoarray[0] === "Consumable"){ consumablearray.push(normalkey); gold = moneyround(gold - iteminfoarray[1]); receittext = "You bought a "+normalkey+" for "+iteminfoarray[1]+" gold."; } updatestats(); let receitalert = alert(receittext); }else{ let shopalert = alert("You dont have enough gold for that item."); } }else{ let shopalert = alert("That item either isnt in this shop, or doesnt exist."); } }else{ let shopalert = alert("You arent at a shop."); } }else if(movevar === "version") { let versionalert = alert(gameversion); }else if(movevar === atob(debugpassword)) { if (equipmentdictionary["Rings"].includes("Debug") === false){ equipmentdictionary["Rings"].push("Debug"); let debugalert = alert("Debug ring added to inventory."); updatestats(); } } } function basiccalculation(eattack,def){ let *** = eattack*def; let pee2 = eattack-***; return pee2 } function enemy(enemytype){ if (enemytype === "test dummy"){ enemypresent = true; enemyclass = "enemy"; enemymaxhealth = 5; enemyhealth = 5; enemyattack = 1; enemyname = "test dummy"; enemydropchance = 2; enemydrops = [["Weapon","Dagger"]]; enemygolddrop = 0.5; let enemyalert = alert("Uh oh! A random test dummy has appeared."); }else if(enemytype === "goblin"){ enemypresent = true; enemyclass = "enemy"; enemymaxhealth = 4; enemyhealth = 4; enemyattack = 1; enemyname = "goblin"; enemydropchance = 2; enemydrops = [["Weapon","Dagger"],["Consumable","Novice Health Potion"]]; enemygolddrop = 1; let enemyalert = alert("Woah! A goblin has appeared."); }else if(enemytype === "gnome"){ enemypresent = true; enemyclass = "boss"; enemymaxhealth = 1000; enemyhealth = 1000; enemyattack = 1; enemyname = "gnome"; enemydropchance = 0; enemydrops = [["Consumable","Gnome Trophie"]]; enemygolddrop = 250; let enemyalert = alert("Its not a gnoblin, its a gnome! And you've been gnomed!"); }else if(enemytype === "piggle"){ enemypresent = true; enemyclass = "enemy"; enemymaxhealth = 20; enemyhealth = 20; enemyattack = 2.5; enemyname = "piggle"; enemydropchance = 3; enemydrops = [["Consumable","Pork Chop"],["Ring","Silver"]]; enemygolddrop = 5; let enemyalert = alert('You hear what sounds like a deformed pig. Oh wait, its a piggle!'); }else if(enemytype === "big willy"){ enemypresent = true; enemyclass = "enemy"; enemymaxhealth = 5000; enemyhealth = 5000; enemyattack = 200; enemyname = "big willy"; enemydropchance = 10; enemydrops = [["Weapon","British Shank"]]; enemygolddrop = 1500; let enemyalert = alert("bruh"); }else if(enemytype === "lil benus") { enemypresent = true; enemyclass = "enemy"; enemymaxhealth = 50; enemyhealth = 50; enemyattack = 5; enemyname = "lil benus"; enemydropchance = 8; enemydrops = [["Consumable","Benus Milk"]]; enemygolddrop = 12; let enemyalert = alert("prepare to be benused"); }else if(enemytype === "elite goblin") { enemypresent = true; enemyclass = "enemy"; enemymaxhealth = 15; enemyhealth = 15; enemyattack = 2; enemyname = "elite goblin"; enemydropchance = 2; enemydrops = [["Ring","Steel"],["Consumable","Novice Health Potion"]]; enemygolddrop = 3 let enemyalert = alert("Woah! An elite goblin has appeared."); }else if(enemytype === "football jucie") { enemypresent = true; enemyclass = "enemy"; enemymaxhealth = 700; enemyhealth = 700; enemyattack = 700; enemyname = "football jucie"; enemydropchance = 2; enemydrops = [["Consumable","football"]]; enemygolddrop = 700; let enemyalert = alert("football."); }else if(enemytype === "goblin chieftan") { enemypresent = true; enemyclass = "boss"; enemymaxhealth = 60; enemyhealth = 60; enemyattack = 6; enemyname = "goblin chieftan"; enemydropchance = 0; enemydrops = [["Armour","ChainMail"],["Consumable","Boss Health Potion"],["Ring","Gold"]]; enemygolddrop = 25 let enemyalert = alert("You hear something huge coming towards you. Its the gobin chieftan! Note: This is the first boss fight. You will need to be prepared to win."); } countsinceenemy = 0; } var startprompt = prompt('You wake up in the middle of a large empty area. Strange. Say "up","down","right", or "left" to move. Say "cmds" for a full list of commands.'); move(startprompt); while(loopvar===true){ let chez; if (enemypresent === true){ if (enemyhealth > 0) { health = health - basiccalculation(enemyattack,defense); countsinceenemy = 0; let attackedalert = alert("Ouch! The "+enemyname+" attacked you for "+basiccalculation(enemyattack,defense)+" damage. You are now at "+health+"health."); if(health > 0){ chez = prompt("You are in battle. Make your move."); move(chez,true); }else{ loopvar = false; gameoveralert = alert("Game Over."); } }else { if (enemyclass === "enemy") { chez = "notnil" enemypresent = false; enemyclass = ""; enemyhealth = 0; enemymaxhealth = 0; enemyattack = 0; enemyname = ""; gold = moneyround(gold + enemygolddrop) let chancevar = Math.floor(Math.random() * enemydropchance); let mathvar = Math.floor(Math.random() * enemydrops.length); let loot = enemydrops[mathvar]; let wintext = "Wow! You won!"; if(loot[0] === "Weapon") { if (chancevar === 0) { if (equipmentdictionary["Weapon"] !== loot[1]&&weapondictionary[loot[1]] > weapondictionary[equipmentdictionary["Weapon"]]) { wintext = wintext + "\nLoot gained: "+loot[1]; equipmentdictionary["Weapon"] = loot[1]; } } }else if(loot[0] === "Armour") { if (chancevar === 0) { if (equipmentdictionary["Armour"] !== loot[1]&&armourdictionary[loot[1]] > armourdictionary[equipmentdictionary["Armour"]]) { wintext = wintext + "\nLoot gained: "+loot[1]; equipmentdictionary["Armour"] = loot[1]; } } }else if(loot[0] === "Ring") { if (chancevar === 0) { if (equipmentdictionary["Rings"].includes(loot[1]) === false){ wintext = wintext + "\nLoot gained: "+loot[1]; equipmentdictionary["Rings"].push(loot[1]); } } }else if(loot[0] === "Consumable") { wintext = wintext + "\nLoot gained: "+loot[1]; consumablearray.push(loot[1]); } if (wintext === "Wow! You won!"){ wintext = wintext + "\nLoot gained: Nothing" } wintext = wintext + "\nGold gained: "+enemygolddrop; enemydropchance = 0; enemydrops = []; enemygolddrop = 0; updatestats(); let winalert = alert(wintext); }else if(enemyclass === "boss") { chez = "notnil" enemypresent = false; enemyclass = ""; enemyhealth = 0; enemymaxhealth = 0; enemyattack = 0; BossesAlive[enemyname] = false; enemyname = ""; gold = moneyround(gold + enemygolddrop) let wintext = "Wow! You won!"; for (const loot of enemydrops) { if(loot[0] === "Weapon") { if (equipmentdictionary["Weapon"] !== loot[1]&&weapondictionary[loot[1]] > weapondictionary[equipmentdictionary["Weapon"]]) { wintext = wintext + "\nLoot gained: "+loot[1]; equipmentdictionary["Weapon"] = loot[1]; } }else if(loot[0] === "Armour") { if (equipmentdictionary["Armour"] !== loot[1]&&armourdictionary[loot[1]] > armourdictionary[equipmentdictionary["Armour"]]) { wintext = wintext + "\nLoot gained: "+loot[1]; equipmentdictionary["Armour"] = loot[1]; } }else if(loot[0] === "Ring") { if (equipmentdictionary["Rings"].includes(loot[1]) === false){ wintext = wintext + "\nLoot gained: "+loot[1]; equipmentdictionary["Rings"].push(loot[1]); } }else if(loot[0] === "Consumable") { wintext = wintext + "\nLoot gained: "+loot[1]; consumablearray.push(loot[1]); } if (wintext === "Wow! You won!"){ wintext = wintext + "\nLoot gained: Nothing" } } wintext = wintext + "\nGold gained: "+enemygolddrop; enemydropchance = 0; enemydrops = []; enemygolddrop = 0; updatestats(); let winalert = alert(wintext); } } }else if (checkcoords(6,3)){ chez = prompt('There is nothing but a sign in this area saying "Fish was here". Your position is '+x+','+y+'.'); move(chez); }else if(checkcoords(10,10)){ if (BossesAlive["gnome"]) { chez = "notnull"; enemy("gnome"); }else { chez = prompt("Welcome to the gnome room! Your position is "+x+","+y+". I have no idea how you survived."); move(chez); } }else if(checkcoords(-4,2)||checkcoords(4,-2)||checkcoords(4,2)||checkcoords(-4,-2)){ if (countsinceenemy > 5) { chez = "notnull"; enemy("goblin"); }else { chez = prompt("You are at a goblin camp. Your position is "+x+","+y+"."); move(chez); } }else if(checkcoords(5,5)||checkcoords(-5,-5)){ if (countsinceenemy > 6) { chez = "notnull"; enemy("piggle"); }else { chez = prompt("You are at a piggle nest. Your position is "+x+","+y+"."); move(chez); } }else if(checkcoords(-5,3)||checkcoords(5,-3)){ if (countsinceenemy > 6) { chez = "notnull"; enemy("elite goblin"); }else { chez = prompt("You are at a goblin stronghold. Your position is "+x+","+y+"."); move(chez); } }else if(checkcoords(7,7)){ chez = prompt("You are at the healing fountain. Every time you do something, you get 1/10 of your max health back. Your position is "+x+","+y+"."); move(chez); if (checkcoords(7,7)) { checkheal(maxhealth/10); } }else if(checkcoords(42,42)){ if(riddlesolved !== true) { chez = prompt('You enter the room, and you see a strange creature. It says:\n"Its shiny and green\nIts rare and serene\nIt has a bright gleam\nWhat am i thinking of?"'); if(chez.toLowerCase() === "emerald") { let correctalert = alert('The creature says "Correct! Here is a gift." Then, the creature hands you an emerald ring, and the creature falls into a deep sleep right after.'); equipmentdictionary["Rings"].push("Emerald"); riddlesolved = true; updatestats(); }else { let wrongalert = alert('The creature says "Wrong." and picks you up, and yeets you back to 0,0.'); x = 0; y = 0; } }else { chez = prompt("The creature is just sitting there, sleeping. Your position is "+x+","+y+"."); move(chez); } }else if(checkcoords(6,7)){ atshop = true; shopname = "beginner magic shop"; chez = prompt('"Welcome to the beginner magic shop, '+initprompt+'. Would you like to buy anything?" The blue witch says with a smile. Your position is '+x+','+y+'.'); move(chez); }else if(checkcoords(8,7)){ atshop = true; shopname = "beginner market"; chez = prompt('"Welcome to teh beginner market, you homeless baboon. Would you like to buy anything?" The owner says. Your position is '+x+','+y+'.'); move(chez); }else if(checkcoords(-10,-10)){ if (BossesAlive["goblin chieftan"]) { chez = "notnull"; enemy("goblin chieftan"); }else { chez = prompt("The goblin chieftans throne sits here, empty. Your position is "+x+","+y+"."); move(chez); } }else{ atshop = false; shopname = ""; chez = prompt("Your position is "+x+","+y+"."); move(chez); } if(chez === null){ loopvar = false; } countsinceenemy = countsinceenemy + 1; } }