Skip to content

Commit

Permalink
Update script.js
Browse files Browse the repository at this point in the history
Camel Case names, don't show negative health but 0 instead, dislay health red if 0
  • Loading branch information
quentin-rey authored Mar 15, 2024
1 parent c767b7a commit 6c32c3d
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ let gold = 50;
let currentWeapon = 0;
let fighting;
let monsterHealth;
let inventory = ["stick"];
let inventory = ["Stick"];

const button1 = document.querySelector('#button1');
const button2 = document.querySelector("#button2");
Expand All @@ -17,44 +17,44 @@ const monsterStats = document.querySelector("#monsterStats");
const monsterName = document.querySelector("#monsterName");
const monsterHealthText = document.querySelector("#monsterHealth");
const weapons = [
{ name: 'stick', power: 5 },
{ name: 'dagger', power: 30 },
{ name: 'claw hammer', power: 50 },
{ name: 'sword', power: 100 }
{ name: 'Stick', power: 5 },
{ name: 'Dagger', power: 30 },
{ name: 'Claw hammer', power: 50 },
{ name: 'Sword', power: 100 }
];
const monsters = [
{
name: "slime",
name: "Slime",
level: 2,
health: 15
},
{
name: "fanged beast",
name: "Fanged beast",
level: 8,
health: 60
},
{
name: "dragon",
name: "Dragon",
level: 20,
health: 300
}
]
const locations = [
{
name: "town square",
"button text": ["Go to store", "Go to cave", "Fight dragon"],
"button text": ["Go to Store", "Go to Cave", "Fight Dragon"],
"button functions": [goStore, goCave, fightDragon],
text: "You are in the town square. You see a sign that says \"Store\"."
},
{
name: "store",
"button text": ["Buy 10 health (10 gold)", "Buy weapon (30 gold)", "Go to town square"],
"button text": ["Buy 10 health (10 gold)", "Buy weapon (30 gold)", "Go to Town Square"],
"button functions": [buyHealth, buyWeapon, goTown],
text: "You enter the store."
},
{
name: "cave",
"button text": ["Fight slime", "Fight fanged beast", "Go to town square"],
"button text": ["Fight Slime", "Fight Fanged Beast", "Go to Town Square"],
"button functions": [fightSlime, fightBeast, goTown],
text: "You enter the cave. You see some monsters."
},
Expand All @@ -66,7 +66,7 @@ const locations = [
},
{
name: "kill monster",
"button text": ["Go to town square", "Go to town square", "Go to town square"],
"button text": ["Go to Town Square", "Go to Town Square", "Go to Town Square"],
"button functions": [goTown, goTown, easterEgg],
text: 'The monster screams "Arg!" as it dies. You gain experience points and find gold.'
},
Expand All @@ -84,7 +84,7 @@ const locations = [
},
{
name: "easter egg",
"button text": ["2", "8", "Go to town square?"],
"button text": ["2", "8", "Go to Town Square?"],
"button functions": [pickTwo, pickEight, goTown],
text: "You find a secret game. Pick a number above. Ten numbers will be randomly chosen between 0 and 10. If the number you choose matches one of the random numbers, you win!"
}
Expand Down Expand Up @@ -233,6 +233,9 @@ function defeatMonster() {
}

function lose() {
healthText.style.color = "red";
health = 0;
healthText.innerText = health;
update(locations[5]);
}

Expand All @@ -241,6 +244,7 @@ function winGame() {
}

function restart() {
healthText.style.color = "inherit";
xp = 0;
health = 100;
gold = 50;
Expand Down

0 comments on commit 6c32c3d

Please sign in to comment.