The function to buy a weapon only allows the purchase of one weapon although 3 are available
It looks like to buy more weapons, you will have to first play a few rounds of the game and win by defeating the monster. By defeating the monster, you get extra gold which allows you to buy more weapons.
Also, if you get to play the easter egg game and win, then you will get more gold.
You can also test out getting more gold, by setting the gold variable on line 2 to 100.
You will also need to update the initial HTML with 100 instead of 50
this function
function buyWeapon() {
if (currentWeapon < weapons.length - 1) {
if (gold >= 30) {
gold -= 30;
currentWeapon++;
goldText.innerText = gold;
let newWeapon = weapons[currentWeapon].name;
text.innerText = "You now have a " + newWeapon + “.”;
inventory.push(newWeapon);
text.innerText += " In your inventory you have: " + inventory;
} else {
text.innerText = “You do not have enough gold to buy a weapon.”;
}
} else {
text.innerText = “You already have the most powerful weapon!”;
button2.innerText = “Sell weapon for 15 gold”;
button2.onclick = sellWeapon;
}
}
does not take into account the price of higher weapons
Are you saying that we should have different prices for different weapons instead of just having one price for all weapons?
OK, I guess I may have been confusing power with price. You are correct.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.