fix(curriculum): allow screen readers to properly see emote values for rpg step 138 and 148 (#52924)

This commit is contained in:
a2937
2024-02-02 04:43:24 -05:00
committed by GitHub
parent b3a2324822
commit 8eb1c0d3f4
40 changed files with 583 additions and 223 deletions
@@ -565,148 +565,152 @@
"title": "Step 138"
},
{
"id": "62a8f35bde1750791f58773f",
"id": "65b2f6acce65b7a69751a090",
"title": "Step 139"
},
{
"id": "62a94114ce0b8918b487390f",
"id": "62a8f35bde1750791f58773f",
"title": "Step 140"
},
{
"id": "62aa1cea594f152ba626b872",
"id": "62a94114ce0b8918b487390f",
"title": "Step 141"
},
{
"id": "62aa1d6736ba262cfa74344b",
"id": "62aa1cea594f152ba626b872",
"title": "Step 142"
},
{
"id": "62aa1d9f535e102e4663e7a6",
"id": "62aa1d6736ba262cfa74344b",
"title": "Step 143"
},
{
"id": "62aa1e3c7c3d552fb04f0f18",
"id": "62aa1d9f535e102e4663e7a6",
"title": "Step 144"
},
{
"id": "62aa1e8ccd579330e097ce44",
"id": "62aa1e3c7c3d552fb04f0f18",
"title": "Step 145"
},
{
"id": "62aa1eec891ed731db227a36",
"id": "62aa1e8ccd579330e097ce44",
"title": "Step 146"
},
{
"id": "62aa1fed3d4e873366ff3131",
"id": "62aa1eec891ed731db227a36",
"title": "Step 147"
},
{
"id": "62aa204c1e1d33348ff09944",
"id": "62aa1fed3d4e873366ff3131",
"title": "Step 148"
},
{
"id": "62aa20e9cf1be9358f5aceae",
"id": "62aa204c1e1d33348ff09944",
"title": "Step 149"
},
{
"id": "62aa2136fc49b836dfedb959",
"id": "62aa20e9cf1be9358f5aceae",
"title": "Step 150"
},
{
"id": "62aa21971e3b743844849985",
"id": "62aa2136fc49b836dfedb959",
"title": "Step 151"
},
{
"id": "62aa21ea8d9d9f396b95dd87",
"id": "62aa21971e3b743844849985",
"title": "Step 152"
},
{
"id": "62aa226207f33d3ad4c6f546",
"id": "62aa21ea8d9d9f396b95dd87",
"title": "Step 153"
},
{
"id": "62aa22aba186563bcbf2c395",
"id": "62aa226207f33d3ad4c6f546",
"title": "Step 154"
},
{
"id": "62aa234322d4ad3e8bce42cc",
"id": "62aa22aba186563bcbf2c395",
"title": "Step 155"
},
{
"id": "62aa2469c77b363fdb4f0e06",
"id": "62aa234322d4ad3e8bce42cc",
"title": "Step 156"
},
{
"id": "62aa252c3b1073415ba2b898",
"id": "62aa2469c77b363fdb4f0e06",
"title": "Step 157"
},
{
"id": "62aa258da314ef42ba0a1858",
"id": "62aa252c3b1073415ba2b898",
"title": "Step 158"
},
{
"id": "62aa25fcb5837d43b4d9873d",
"id": "62aa258da314ef42ba0a1858",
"title": "Step 159"
},
{
"id": "62aa2626c3c10244b94c787b",
"id": "62aa25fcb5837d43b4d9873d",
"title": "Step 160"
},
{
"id": "62aa264d23cdaa45a20efada",
"id": "62aa2626c3c10244b94c787b",
"title": "Step 161"
},
{
"id": "62aa26cca3cd3d46c431e73b",
"id": "62aa264d23cdaa45a20efada",
"title": "Step 162"
},
{
"id": "62aa27227399d647e1c37a3c",
"id": "62aa26cca3cd3d46c431e73b",
"title": "Step 163"
},
{
"id": "62aa27560def7048d7b4a095",
"id": "62aa27227399d647e1c37a3c",
"title": "Step 164"
},
{
"id": "62aa27c40ca6f04ab8be5fac",
"id": "62aa27560def7048d7b4a095",
"title": "Step 165"
},
{
"id": "62aa28032d863d4bd8058799",
"id": "62aa27c40ca6f04ab8be5fac",
"title": "Step 166"
},
{
"id": "62aa287434dc284cea01157c",
"id": "62aa28032d863d4bd8058799",
"title": "Step 167"
},
{
"id": "62aa28bbd6323e4dfb3ac43e",
"id": "62aa287434dc284cea01157c",
"title": "Step 168"
},
{
"id": "62aa28fb651bf14efa2dbb16",
"id": "62aa28bbd6323e4dfb3ac43e",
"title": "Step 169"
},
{
"id": "62aa2943669c9d5026af6985",
"id": "62aa28fb651bf14efa2dbb16",
"title": "Step 170"
},
{
"id": "62aa2999ec27ec516655eba6",
"id": "62aa2943669c9d5026af6985",
"title": "Step 171"
},
{
"id": "62aa29d8f8f88152c91350ca",
"id": "62aa2999ec27ec516655eba6",
"title": "Step 172"
},
{
"id": "62aa2aec2f09d454253aad6c",
"id": "62aa29d8f8f88152c91350ca",
"title": "Step 173"
},
{
"id": "62aa2ba9cd881355a6f0a5a8",
"id": "62aa2aec2f09d454253aad6c",
"title": "Step 174"
},
{
"id": "62aa2ba9cd881355a6f0a5a8",
"title": "Step 175"
}
]
}
@@ -220,7 +220,7 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
}
];
@@ -1,8 +1,8 @@
---
id: 62a8f35bde1750791f58773f
title: Step 139
title: Step 140
challengeType: 0
dashedName: step-139
dashedName: step-140
---
# --description--
@@ -185,7 +185,7 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
}
];
@@ -202,7 +202,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,13 +1,13 @@
---
id: 62a94114ce0b8918b487390f
title: Step 140
title: Step 141
challengeType: 0
dashedName: step-140
dashedName: step-141
---
# --description--
Add another object in the `locations` array. Everything should be the same as the `lose` object, except the `name` should be `win` and the `text` should be `You defeat the dragon! YOU WIN THE GAME! 🎉`.
Add another object in the `locations` array. Everything should be the same as the `lose` object, except the `name` should be `win` and the `text` should be `You defeat the dragon! YOU WIN THE GAME! 🎉`.
# --hints--
@@ -41,10 +41,10 @@ Your seventh `locations` value should have a `button functions` array with three
assert.deepEqual(locations[6]["button functions"], [restart, restart, restart]);
```
Your seventh `locations` value should have a `text` property with the value `You defeat the dragon! YOU WIN THE GAME! 🎉`.
Your seventh `locations` value should have a `text` property with the value `You defeat the dragon! YOU WIN THE GAME! 🎉`.
```js
assert.equal(locations[6].text, 'You defeat the dragon! YOU WIN THE GAME! 🎉');
assert.equal(locations[6].text, 'You defeat the dragon! YOU WIN THE GAME! 🎉');
```
# --seed--
@@ -210,7 +210,7 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
}
--fcc-editable-region--
];
@@ -228,7 +228,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa1cea594f152ba626b872
title: Step 141
title: Step 142
challengeType: 0
dashedName: step-141
dashedName: step-142
---
# --description--
@@ -181,13 +181,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
}
];
@@ -204,7 +204,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa1d6736ba262cfa74344b
title: Step 142
title: Step 143
challengeType: 0
dashedName: step-142
dashedName: step-143
---
# --description--
@@ -185,13 +185,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
}
];
@@ -208,7 +208,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa1d9f535e102e4663e7a6
title: Step 143
title: Step 144
challengeType: 0
dashedName: step-143
dashedName: step-144
---
# --description--
@@ -193,13 +193,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
}
];
@@ -216,7 +216,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa1e3c7c3d552fb04f0f18
title: Step 144
title: Step 145
challengeType: 0
dashedName: step-144
dashedName: step-145
---
# --description--
@@ -179,13 +179,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
}
];
@@ -202,7 +202,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa1e8ccd579330e097ce44
title: Step 145
title: Step 146
challengeType: 0
dashedName: step-145
dashedName: step-146
---
# --description--
@@ -188,13 +188,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
}
];
@@ -211,7 +211,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa1eec891ed731db227a36
title: Step 146
title: Step 147
challengeType: 0
dashedName: step-146
dashedName: step-147
---
# --description--
@@ -207,13 +207,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
}
];
@@ -230,7 +230,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa1fed3d4e873366ff3131
title: Step 147
title: Step 148
challengeType: 0
dashedName: step-147
dashedName: step-148
---
# --description--
@@ -179,13 +179,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
}
];
@@ -202,7 +202,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa204c1e1d33348ff09944
title: Step 148
title: Step 149
challengeType: 0
dashedName: step-148
dashedName: step-149
---
# --description--
@@ -179,13 +179,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
}
];
@@ -202,7 +202,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa20e9cf1be9358f5aceae
title: Step 149
title: Step 150
challengeType: 0
dashedName: step-149
dashedName: step-150
---
# --description--
@@ -185,13 +185,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
}
];
@@ -208,7 +208,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa2136fc49b836dfedb959
title: Step 150
title: Step 151
challengeType: 0
dashedName: step-150
dashedName: step-151
---
# --description--
@@ -185,13 +185,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
}
];
@@ -208,7 +208,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa21971e3b743844849985
title: Step 151
title: Step 152
challengeType: 0
dashedName: step-151
dashedName: step-152
---
# --description--
@@ -197,13 +197,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
}
];
@@ -220,7 +220,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa21ea8d9d9f396b95dd87
title: Step 152
title: Step 153
challengeType: 0
dashedName: step-152
dashedName: step-153
---
# --description--
@@ -186,13 +186,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
}
];
@@ -209,7 +209,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa226207f33d3ad4c6f546
title: Step 153
title: Step 154
challengeType: 0
dashedName: step-153
dashedName: step-154
---
# --description--
@@ -204,13 +204,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
}
];
@@ -227,7 +227,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa22aba186563bcbf2c395
title: Step 154
title: Step 155
challengeType: 0
dashedName: step-154
dashedName: step-155
---
# --description--
@@ -187,13 +187,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
}
];
@@ -210,7 +210,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa234322d4ad3e8bce42cc
title: Step 155
title: Step 156
challengeType: 0
dashedName: step-155
dashedName: step-156
---
# --description--
@@ -201,13 +201,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
}
];
@@ -224,7 +224,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa2469c77b363fdb4f0e06
title: Step 156
title: Step 157
challengeType: 0
dashedName: step-156
dashedName: step-157
---
# --description--
@@ -193,13 +193,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
}
];
@@ -216,7 +216,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa252c3b1073415ba2b898
title: Step 157
title: Step 158
challengeType: 0
dashedName: step-157
dashedName: step-158
---
# --description--
@@ -185,13 +185,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
}
];
@@ -208,7 +208,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa258da314ef42ba0a1858
title: Step 158
title: Step 159
challengeType: 0
dashedName: step-158
dashedName: step-159
---
# --description--
@@ -211,13 +211,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
}
];
@@ -234,7 +234,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa25fcb5837d43b4d9873d
title: Step 159
title: Step 160
challengeType: 0
dashedName: step-159
dashedName: step-160
---
# --description--
@@ -209,13 +209,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
},
--fcc-editable-region--
@@ -235,7 +235,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa2626c3c10244b94c787b
title: Step 160
title: Step 161
challengeType: 0
dashedName: step-160
dashedName: step-161
---
# --description--
@@ -179,13 +179,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
},
{
name: "easter egg",
@@ -208,7 +208,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa264d23cdaa45a20efada
title: Step 161
title: Step 162
challengeType: 0
dashedName: step-161
dashedName: step-162
---
# --description--
@@ -195,13 +195,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
},
{
name: "easter egg",
@@ -224,7 +224,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa26cca3cd3d46c431e73b
title: Step 162
title: Step 163
challengeType: 0
dashedName: step-162
dashedName: step-163
---
# --description--
@@ -191,13 +191,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
},
{
name: "easter egg",
@@ -220,7 +220,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa27227399d647e1c37a3c
title: Step 163
title: Step 164
challengeType: 0
dashedName: step-163
dashedName: step-164
---
# --description--
@@ -191,13 +191,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
},
{
name: "easter egg",
@@ -220,7 +220,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa27560def7048d7b4a095
title: Step 164
title: Step 165
challengeType: 0
dashedName: step-164
dashedName: step-165
---
# --description--
@@ -179,13 +179,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
},
{
name: "easter egg",
@@ -208,7 +208,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa27c40ca6f04ab8be5fac
title: Step 165
title: Step 166
challengeType: 0
dashedName: step-165
dashedName: step-166
---
# --description--
@@ -185,13 +185,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
},
{
name: "easter egg",
@@ -214,7 +214,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa28032d863d4bd8058799
title: Step 166
title: Step 167
challengeType: 0
dashedName: step-166
dashedName: step-167
---
# --description--
@@ -183,13 +183,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
},
{
name: "easter egg",
@@ -212,7 +212,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa287434dc284cea01157c
title: Step 167
title: Step 168
challengeType: 0
dashedName: step-167
dashedName: step-168
---
# --description--
@@ -181,13 +181,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
},
{
name: "easter egg",
@@ -210,7 +210,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa28bbd6323e4dfb3ac43e
title: Step 168
title: Step 169
challengeType: 0
dashedName: step-168
dashedName: step-169
---
# --description--
@@ -181,13 +181,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
},
{
name: "easter egg",
@@ -210,7 +210,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa28fb651bf14efa2dbb16
title: Step 169
title: Step 170
challengeType: 0
dashedName: step-169
dashedName: step-170
---
# --description--
@@ -197,13 +197,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
},
{
name: "easter egg",
@@ -226,7 +226,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa2943669c9d5026af6985
title: Step 170
title: Step 171
challengeType: 0
dashedName: step-170
dashedName: step-171
---
# --description--
@@ -198,13 +198,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
},
{
name: "easter egg",
@@ -227,7 +227,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa2999ec27ec516655eba6
title: Step 171
title: Step 172
challengeType: 0
dashedName: step-171
dashedName: step-172
---
# --description--
@@ -191,13 +191,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
},
{
name: "easter egg",
@@ -220,7 +220,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa29d8f8f88152c91350ca
title: Step 172
title: Step 173
challengeType: 0
dashedName: step-172
dashedName: step-173
---
# --description--
@@ -197,13 +197,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
},
{
name: "easter egg",
@@ -226,7 +226,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa2aec2f09d454253aad6c
title: Step 173
title: Step 174
challengeType: 0
dashedName: step-173
dashedName: step-174
---
# --description--
@@ -192,13 +192,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
},
{
name: "easter egg",
@@ -221,7 +221,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -1,8 +1,8 @@
---
id: 62aa2ba9cd881355a6f0a5a8
title: Step 174
title: Step 175
challengeType: 0
dashedName: step-174
dashedName: step-175
---
# --description--
@@ -183,13 +183,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
},
{
name: "easter egg",
@@ -212,7 +212,7 @@ function update(location) {
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
text.innerHTML = location.text;
}
function goTown() {
@@ -557,13 +557,13 @@ const locations = [
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. ☠️"
text: "You die. ☠"
},
{
name: "win",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
text: "You defeat the dragon! YOU WIN THE GAME! 🎉"
},
{
name: "easter egg",
@@ -7,7 +7,7 @@ dashedName: step-137
# --description--
In the `locations` array, add another object at the end. Set the `name` property to `lose`, set `button text` to an array with three `REPLAY?` strings, set `button functions` to an array with three `restart` variables, and set `text` to `You die. ☠️`. You can copy that text to use the emote.
In the `locations` array, add another object at the end. Set the `name` property to `lose`, set `button text` to an array with three `REPLAY?` strings, set `button functions` to an array with three `restart` variables, and set `text` to `You die. ☠`.
# --hints--
@@ -41,10 +41,10 @@ Your sixth `locations` value should have a `button functions` array with three `
assert.deepEqual(locations[5]["button functions"], [restart, restart, restart]);
```
Your sixth `locations` value should have a `text` property with the value `You die. ☠️`.
Your sixth `locations` value should have a `text` property with the value `You die. ☠`.
```js
assert.equal(locations[5].text, 'You die. ☠️');
assert.equal(locations[5].text, 'You die. ☠');
```
# --seed--
@@ -0,0 +1,356 @@
---
id: 65b2f6acce65b7a69751a090
title: Step 139
challengeType: 0
dashedName: step-139
---
# --description--
In order for the `&#x2620;` emoticon text to properly display on the page, you will need to use the <dfn>innerHTML</dfn> property.
The `innerHTML` property allows you to access or modify the content inside an HTML element using JavaScript.
Here is an example of updating the content for this paragraph element using the `innerHTML` property.
```html
<p id="demo">This is a paragraph.</p>
```
```js
document.querySelector("#demo").innerHTML = "Hello, innerHTML!";
```
In the `update` function, change `text.innerText` to `text.innerHTML`.
# --hints--
You should use dot notation to access the `innerHTML` property of `text`.
```js
assert.match(code, /text\.innerHTML/);
```
You should not use `let` or `const` to access the `innerHTML` property of `text`.
```js
assert.notMatch(code, /(let|const)\s+text.innerHTML/);
```
You should set `innerHTML` equal to the `text` property of `location`.
```js
assert.match(code, /text\.innerHTML\s*=\s*location\.text/);
```
# --seed--
## --seed-contents--
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="./styles.css">
<title>RPG - Dragon Repeller</title>
</head>
<body>
<div id="game">
<div id="stats">
<span class="stat">XP: <strong><span id="xpText">0</span></strong></span>
<span class="stat">Health: <strong><span id="healthText">100</span></strong></span>
<span class="stat">Gold: <strong><span id="goldText">50</span></strong></span>
</div>
<div id="controls">
<button id="button1">Go to store</button>
<button id="button2">Go to cave</button>
<button id="button3">Fight dragon</button>
</div>
<div id="monsterStats">
<span class="stat">Monster Name: <strong><span id="monsterName"></span></strong></span>
<span class="stat">Health: <strong><span id="monsterHealth"></span></strong></span>
</div>
<div id="text">
Welcome to Dragon Repeller. You must defeat the dragon that is preventing people from leaving the town. You are in the town square. Where do you want to go? Use the buttons above.
</div>
</div>
<script src="./script.js"></script>
</body>
</html>
```
```css
body {
background-color: #0a0a23;
}
#text {
background-color: #0a0a23;
color: #ffffff;
padding: 10px;
}
#game {
max-width: 500px;
max-height: 400px;
background-color: #ffffff;
color: #ffffff;
margin: 30px auto 0px;
padding: 10px;
}
#controls,
#stats {
border: 1px solid #0a0a23;
padding: 5px;
color: #0a0a23;
}
#monsterStats {
display: none;
border: 1px solid #0a0a23;
padding: 5px;
color: #ffffff;
background-color: #c70d0d;
}
.stat {
padding-right: 10px;
}
button {
cursor: pointer;
color: #0a0a23;
background-color: #feac32;
background-image: linear-gradient(#fecc4c, #ffac33);
border: 3px solid #feac32;
}
```
```js
let xp = 0;
let health = 100;
let gold = 50;
let currentWeapon = 0;
let fighting;
let monsterHealth;
let inventory = ["stick"];
const button1 = document.querySelector('#button1');
const button2 = document.querySelector("#button2");
const button3 = document.querySelector("#button3");
const text = document.querySelector("#text");
const xpText = document.querySelector("#xpText");
const healthText = document.querySelector("#healthText");
const goldText = document.querySelector("#goldText");
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 }
];
const monsters = [
{
name: "slime",
level: 2,
health: 15
},
{
name: "fanged beast",
level: 8,
health: 60
},
{
name: "dragon",
level: 20,
health: 300
}
]
const locations = [
{
name: "town square",
"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 functions": [buyHealth, buyWeapon, goTown],
text: "You enter the store."
},
{
name: "cave",
"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."
},
{
name: "fight",
"button text": ["Attack", "Dodge", "Run"],
"button functions": [attack, dodge, goTown],
text: "You are fighting a monster."
},
{
name: "kill monster",
"button text": ["Go to town square", "Go to town square", "Go to town square"],
"button functions": [goTown, goTown, goTown],
text: 'The monster screams "Arg!" as it dies. You gain experience points and find gold.'
},
{
name: "lose",
"button text": ["REPLAY?", "REPLAY?", "REPLAY?"],
"button functions": [restart, restart, restart],
text: "You die. &#x2620;"
}
];
// initialize buttons
button1.onclick = goStore;
button2.onclick = goCave;
button3.onclick = fightDragon;
function update(location) {
--fcc-editable-region--
monsterStats.style.display = "none";
button1.innerText = location["button text"][0];
button2.innerText = location["button text"][1];
button3.innerText = location["button text"][2];
button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];
text.innerText = location.text;
--fcc-editable-region--
}
function goTown() {
update(locations[0]);
}
function goStore() {
update(locations[1]);
}
function goCave() {
update(locations[2]);
}
function buyHealth() {
if (gold >= 10) {
gold -= 10;
health += 10;
goldText.innerText = gold;
healthText.innerText = health;
} else {
text.innerText = "You do not have enough gold to buy health.";
}
}
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;
}
}
function sellWeapon() {
if (inventory.length > 1) {
gold += 15;
goldText.innerText = gold;
let currentWeapon = inventory.shift();
text.innerText = "You sold a " + currentWeapon + ".";
text.innerText += " In your inventory you have: " + inventory;
} else {
text.innerText = "Don't sell your only weapon!";
}
}
function fightSlime() {
fighting = 0;
goFight();
}
function fightBeast() {
fighting = 1;
goFight();
}
function fightDragon() {
fighting = 2;
goFight();
}
function goFight() {
update(locations[3]);
monsterHealth = monsters[fighting].health;
monsterStats.style.display = "block";
monsterName.innerText = monsters[fighting].name;
monsterHealthText.innerText = monsterHealth;
}
function attack() {
text.innerText = "The " + monsters[fighting].name + " attacks.";
text.innerText += " You attack it with your " + weapons[currentWeapon].name + ".";
health -= monsters[fighting].level;
monsterHealth -= weapons[currentWeapon].power + Math.floor(Math.random() * xp) + 1;
healthText.innerText = health;
monsterHealthText.innerText = monsterHealth;
if (health <= 0) {
lose();
} else if (monsterHealth <= 0) {
if (fighting === 2) {
winGame();
} else {
defeatMonster();
}
}
}
function dodge() {
text.innerText = "You dodge the attack from the " + monsters[fighting].name;
}
function defeatMonster() {
gold += Math.floor(monsters[fighting].level * 6.7);
xp += monsters[fighting].level;
goldText.innerText = gold;
xpText.innerText = xp;
update(locations[4]);
}
function lose() {
update(locations[5]);
}
function restart() {
xp = 0;
health = 100;
gold = 50;
currentWeapon = 0;
inventory = ["stick"];
goldText.innerText = gold;
healthText.innerText = health;
xpText.innerText = xp;
goTown();
}
```