mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-05 00:00:18 -04:00
fix(curriculum): editable region boundaries to the JS projects. (#46167)
This commit is contained in:
@@ -98,8 +98,10 @@ assert(health === 100);
|
||||
|
||||
```html
|
||||
<script>
|
||||
--fcc-editable-region--
|
||||
var xp = 0;
|
||||
|
||||
--fcc-editable-region--
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
@@ -96,9 +96,11 @@ assert(gold === 50);
|
||||
|
||||
```html
|
||||
<script>
|
||||
--fcc-editable-region--
|
||||
var xp = 0;
|
||||
var health = 100;
|
||||
|
||||
--fcc-editable-region--
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
@@ -98,10 +98,12 @@ assert(currentWeapon === 0);
|
||||
|
||||
```html
|
||||
<script>
|
||||
--fcc-editable-region--
|
||||
var xp = 0;
|
||||
var health = 100;
|
||||
var gold = 50;
|
||||
|
||||
--fcc-editable-region--
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
@@ -103,11 +103,13 @@ assert(
|
||||
|
||||
```html
|
||||
<script>
|
||||
--fcc-editable-region--
|
||||
var xp = 0;
|
||||
var health = 100;
|
||||
var gold = 50;
|
||||
var currentWeapon = 0;
|
||||
|
||||
--fcc-editable-region--
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
@@ -98,11 +98,13 @@ assert(/let\s+fighting\s*;?/.test(code) && fighting === undefined);
|
||||
|
||||
```html
|
||||
<script>
|
||||
--fcc-editable-region--
|
||||
let xp = 0;
|
||||
let health = 100;
|
||||
let gold = 50;
|
||||
let currentWeapon = 0;
|
||||
|
||||
--fcc-editable-region--
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
@@ -96,12 +96,14 @@ assert(monsterHealth === undefined && inventory === undefined);
|
||||
|
||||
```html
|
||||
<script>
|
||||
--fcc-editable-region--
|
||||
let xp = 0;
|
||||
let health = 100;
|
||||
let gold = 50;
|
||||
let currentWeapon = 0;
|
||||
let fighting;
|
||||
|
||||
--fcc-editable-region--
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
@@ -98,6 +98,7 @@ assert(inventory === 'stick');
|
||||
|
||||
```html
|
||||
<script>
|
||||
--fcc-editable-region--
|
||||
let xp = 0;
|
||||
let health = 100;
|
||||
let gold = 50;
|
||||
@@ -106,6 +107,7 @@ let fighting;
|
||||
let monsterHealth;
|
||||
let inventory;
|
||||
|
||||
--fcc-editable-region--
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
@@ -106,6 +106,7 @@ assert(
|
||||
|
||||
```html
|
||||
<script>
|
||||
--fcc-editable-region--
|
||||
let xp = 0;
|
||||
let health = 100;
|
||||
let gold = 50;
|
||||
@@ -114,6 +115,7 @@ let fighting;
|
||||
let monsterHealth;
|
||||
let inventory = "stick";
|
||||
|
||||
--fcc-editable-region--
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
@@ -96,6 +96,7 @@ assert(inventory[0] === 'stick' && inventory.length === 1);
|
||||
|
||||
```html
|
||||
<script>
|
||||
--fcc-editable-region--
|
||||
let xp = 0;
|
||||
let health = 100;
|
||||
let gold = 50;
|
||||
@@ -104,6 +105,7 @@ let fighting;
|
||||
let monsterHealth;
|
||||
let inventory = ["stick", "dagger", "sword"];
|
||||
|
||||
--fcc-editable-region--
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
@@ -102,6 +102,7 @@ assert(
|
||||
|
||||
```html
|
||||
<script>
|
||||
--fcc-editable-region--
|
||||
let xp = 0;
|
||||
let health = 100;
|
||||
let gold = 50;
|
||||
@@ -111,6 +112,7 @@ let monsterHealth;
|
||||
let inventory = ["stick"];
|
||||
|
||||
|
||||
--fcc-editable-region--
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
@@ -103,9 +103,11 @@ let currentWeapon = 0;
|
||||
let fighting;
|
||||
let monsterHealth;
|
||||
let inventory = ["stick"];
|
||||
--fcc-editable-region--
|
||||
|
||||
let button1 = document.querySelector('#button1');
|
||||
|
||||
--fcc-editable-region--
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
@@ -133,9 +133,11 @@ let currentWeapon = 0;
|
||||
let fighting;
|
||||
let monsterHealth;
|
||||
let inventory = ["stick"];
|
||||
--fcc-editable-region--
|
||||
|
||||
const button1 = document.querySelector('#button1');
|
||||
|
||||
--fcc-editable-region--
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
@@ -116,7 +116,9 @@ const goldText = document.querySelector("#goldText");
|
||||
const monsterStats = document.querySelector("#monsterStats");
|
||||
const monsterNameText = document.querySelector("#monsterName");
|
||||
const monsterHealthText = document.querySelector("#monsterHealth");
|
||||
--fcc-editable-region--
|
||||
|
||||
--fcc-editable-region--
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
@@ -114,10 +114,12 @@ const goldText = document.querySelector("#goldText");
|
||||
const monsterStats = document.querySelector("#monsterStats");
|
||||
const monsterNameText = document.querySelector("#monsterName");
|
||||
const monsterHealthText = document.querySelector("#monsterHealth");
|
||||
--fcc-editable-region--
|
||||
|
||||
// initialize buttons
|
||||
|
||||
|
||||
--fcc-editable-region--
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
@@ -117,10 +117,12 @@ const goldText = document.querySelector("#goldText");
|
||||
const monsterStats = document.querySelector("#monsterStats");
|
||||
const monsterNameText = document.querySelector("#monsterName");
|
||||
const monsterHealthText = document.querySelector("#monsterHealth");
|
||||
--fcc-editable-region--
|
||||
|
||||
// initialize buttons
|
||||
button1.onclick = goStore;
|
||||
|
||||
--fcc-editable-region--
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
@@ -124,7 +124,9 @@ const monsterHealthText = document.querySelector("#monsterHealth");
|
||||
button1.onclick = goStore;
|
||||
button2.onclick = goCave;
|
||||
button3.onclick = fightDragon;
|
||||
--fcc-editable-region--
|
||||
|
||||
--fcc-editable-region--
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
@@ -130,8 +130,10 @@ button1.onclick = goStore;
|
||||
button2.onclick = goCave;
|
||||
button3.onclick = fightDragon;
|
||||
|
||||
--fcc-editable-region--
|
||||
function goStore() {
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
</script>
|
||||
```
|
||||
|
||||
@@ -127,7 +127,9 @@ button3.onclick = fightDragon;
|
||||
function goStore() {
|
||||
console.log("Going to store.")
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
--fcc-editable-region--
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
@@ -133,7 +133,9 @@ function goStore() {
|
||||
function goCave() {
|
||||
console.log("Going to cave.");
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
--fcc-editable-region--
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
@@ -127,9 +127,11 @@ button1.onclick = goStore;
|
||||
button2.onclick = goCave;
|
||||
button3.onclick = fightDragon;
|
||||
|
||||
--fcc-editable-region--
|
||||
function goStore() {
|
||||
console.log("Going to store.");
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function goCave() {
|
||||
console.log("Going to cave.");
|
||||
|
||||
@@ -129,9 +129,11 @@ button1.onclick = goStore;
|
||||
button2.onclick = goCave;
|
||||
button3.onclick = fightDragon;
|
||||
|
||||
--fcc-editable-region--
|
||||
function goStore() {
|
||||
button1.innerText = "Buy 10 health (10 gold)";
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function goCave() {
|
||||
console.log("Going to cave.");
|
||||
|
||||
@@ -124,11 +124,13 @@ button1.onclick = goStore;
|
||||
button2.onclick = goCave;
|
||||
button3.onclick = fightDragon;
|
||||
|
||||
--fcc-editable-region--
|
||||
function goStore() {
|
||||
button1.innerText = "Buy 10 health (10 gold)";
|
||||
button2.innerText = "Buy weapon (30 gold)";
|
||||
button3.innerText = "Go to town square";
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function goCave() {
|
||||
console.log("Going to cave.");
|
||||
|
||||
@@ -124,6 +124,7 @@ button1.onclick = goStore;
|
||||
button2.onclick = goCave;
|
||||
button3.onclick = fightDragon;
|
||||
|
||||
--fcc-editable-region--
|
||||
function goStore() {
|
||||
button1.innerText = "Buy 10 health (10 gold)";
|
||||
button2.innerText = "Buy weapon (30 gold)";
|
||||
@@ -132,6 +133,7 @@ function goStore() {
|
||||
button2.onclick = buyWeapon;
|
||||
button3.onclick = goTown;
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function goCave() {
|
||||
console.log("Going to cave.");
|
||||
|
||||
@@ -141,7 +141,9 @@ function goCave() {
|
||||
function fightDragon() {
|
||||
console.log("Fighting dragon.");
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
--fcc-editable-region--
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
@@ -133,6 +133,7 @@ button1.onclick = goStore;
|
||||
button2.onclick = goCave;
|
||||
button3.onclick = fightDragon;
|
||||
|
||||
--fcc-editable-region--
|
||||
function goStore() {
|
||||
button1.innerText = "Buy 10 health (10 gold)";
|
||||
button2.innerText = "Buy weapon (30 gold)";
|
||||
@@ -159,6 +160,7 @@ function buyWeapon() {
|
||||
|
||||
function goTown() {
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
</script>
|
||||
```
|
||||
|
||||
@@ -128,6 +128,7 @@ button1.onclick = goStore;
|
||||
button2.onclick = goCave;
|
||||
button3.onclick = fightDragon;
|
||||
|
||||
--fcc-editable-region--
|
||||
function goTown() {
|
||||
button1.innerText = "Go to store";
|
||||
button2.innerText = "Go to cave";
|
||||
@@ -137,6 +138,7 @@ function goTown() {
|
||||
button3.onclick = fightDragon;
|
||||
text.innerText = "You are in the town square. You see a sign that says Store.";
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function goStore() {
|
||||
button1.innerText = "Buy 10 health (10 gold)";
|
||||
|
||||
@@ -129,7 +129,9 @@ const monsterHealthText = document.querySelector("#monsterHealth");
|
||||
button1.onclick = goStore;
|
||||
button2.onclick = goCave;
|
||||
button3.onclick = fightDragon;
|
||||
--fcc-editable-region--
|
||||
|
||||
--fcc-editable-region--
|
||||
function goTown() {
|
||||
button1.innerText = "Go to store";
|
||||
button2.innerText = "Go to cave";
|
||||
|
||||
@@ -114,6 +114,9 @@ const goldText = document.querySelector("#goldText");
|
||||
const monsterStats = document.querySelector("#monsterStats");
|
||||
const monsterNameText = document.querySelector("#monsterName");
|
||||
const monsterHealthText = document.querySelector("#monsterHealth");
|
||||
--fcc-editable-region--
|
||||
|
||||
--fcc-editable-region--
|
||||
|
||||
// initialize buttons
|
||||
button1.onclick = goStore;
|
||||
|
||||
@@ -119,7 +119,9 @@ const monsterStats = document.querySelector("#monsterStats");
|
||||
const monsterNameText = document.querySelector("#monsterName");
|
||||
const monsterHealthText = document.querySelector("#monsterHealth");
|
||||
|
||||
--fcc-editable-region--
|
||||
const locations = [];
|
||||
--fcc-editable-region--
|
||||
|
||||
// initialize buttons
|
||||
button1.onclick = goStore;
|
||||
|
||||
@@ -125,7 +125,9 @@ const monsterStats = document.querySelector("#monsterStats");
|
||||
const monsterNameText = document.querySelector("#monsterName");
|
||||
const monsterHealthText = document.querySelector("#monsterHealth");
|
||||
|
||||
--fcc-editable-region--
|
||||
const locations = [{}];
|
||||
--fcc-editable-region--
|
||||
|
||||
// initialize buttons
|
||||
button1.onclick = goStore;
|
||||
|
||||
@@ -126,11 +126,13 @@ const monsterStats = document.querySelector("#monsterStats");
|
||||
const monsterNameText = document.querySelector("#monsterName");
|
||||
const monsterHealthText = document.querySelector("#monsterHealth");
|
||||
|
||||
--fcc-editable-region--
|
||||
const locations = [
|
||||
{
|
||||
name: "town square"
|
||||
}
|
||||
];
|
||||
--fcc-editable-region--
|
||||
|
||||
// initialize buttons
|
||||
button1.onclick = goStore;
|
||||
|
||||
@@ -121,12 +121,14 @@ const monsterStats = document.querySelector("#monsterStats");
|
||||
const monsterNameText = document.querySelector("#monsterName");
|
||||
const monsterHealthText = document.querySelector("#monsterHealth");
|
||||
|
||||
--fcc-editable-region--
|
||||
const locations = [
|
||||
{
|
||||
name: "town square",
|
||||
"button text": []
|
||||
}
|
||||
];
|
||||
--fcc-editable-region--
|
||||
|
||||
// initialize buttons
|
||||
button1.onclick = goStore;
|
||||
|
||||
@@ -119,12 +119,14 @@ const monsterStats = document.querySelector("#monsterStats");
|
||||
const monsterNameText = document.querySelector("#monsterName");
|
||||
const monsterHealthText = document.querySelector("#monsterHealth");
|
||||
|
||||
--fcc-editable-region--
|
||||
const locations = [
|
||||
{
|
||||
name: "town square",
|
||||
"button text": ["Go to store", "Go to cave", "Fight dragon"]
|
||||
}
|
||||
];
|
||||
--fcc-editable-region--
|
||||
|
||||
// initialize buttons
|
||||
button1.onclick = goStore;
|
||||
|
||||
@@ -118,6 +118,7 @@ const monsterStats = document.querySelector("#monsterStats");
|
||||
const monsterNameText = document.querySelector("#monsterName");
|
||||
const monsterHealthText = document.querySelector("#monsterHealth");
|
||||
|
||||
--fcc-editable-region--
|
||||
const locations = [
|
||||
{
|
||||
name: "town square",
|
||||
@@ -125,6 +126,7 @@ const locations = [
|
||||
"button functions": [goStore, goCave, fightDragon]
|
||||
}
|
||||
];
|
||||
--fcc-editable-region--
|
||||
|
||||
// initialize buttons
|
||||
button1.onclick = goStore;
|
||||
|
||||
@@ -124,6 +124,7 @@ const monsterStats = document.querySelector("#monsterStats");
|
||||
const monsterNameText = document.querySelector("#monsterName");
|
||||
const monsterHealthText = document.querySelector("#monsterHealth");
|
||||
|
||||
--fcc-editable-region--
|
||||
const locations = [
|
||||
{
|
||||
name: "town square",
|
||||
@@ -132,6 +133,7 @@ const locations = [
|
||||
text: "You are in the town square. You see a sign that says \"Store.\""
|
||||
}
|
||||
];
|
||||
--fcc-editable-region--
|
||||
|
||||
// initialize buttons
|
||||
button1.onclick = goStore;
|
||||
|
||||
@@ -151,6 +151,7 @@ button1.onclick = goStore;
|
||||
button2.onclick = goCave;
|
||||
button3.onclick = fightDragon;
|
||||
|
||||
--fcc-editable-region--
|
||||
function update(location) {
|
||||
}
|
||||
|
||||
@@ -173,6 +174,7 @@ function goStore() {
|
||||
button3.onclick = goTown;
|
||||
text.innerText = "You enter the store.";
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function goCave() {
|
||||
console.log("Going to cave.");
|
||||
|
||||
@@ -147,8 +147,10 @@ function update(location) {
|
||||
text.innerText = "You are in the town square. You see a sign that says \"Store\".";
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function goTown() {
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function goStore() {
|
||||
}
|
||||
|
||||
@@ -147,9 +147,11 @@ function update(location) {
|
||||
text.innerText = "You are in the town square. You see a sign that says \"Store\".";
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function goTown() {
|
||||
update();
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function goStore() {
|
||||
}
|
||||
|
||||
@@ -145,9 +145,11 @@ function update(location) {
|
||||
text.innerText = "You are in the town square. You see a sign that says \"Store\".";
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function goTown() {
|
||||
update(locations);
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function goStore() {
|
||||
}
|
||||
|
||||
@@ -141,6 +141,7 @@ button1.onclick = goStore;
|
||||
button2.onclick = goCave;
|
||||
button3.onclick = fightDragon;
|
||||
|
||||
--fcc-editable-region--
|
||||
function update(location) {
|
||||
button1.innerText = "Go to store";
|
||||
button2.innerText = "Go to cave";
|
||||
@@ -150,6 +151,7 @@ function update(location) {
|
||||
button3.onclick = fightDragon;
|
||||
text.innerText = "You are in the town square. You see a sign that says \"Store\".";
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function goTown() {
|
||||
update(locations[0]);
|
||||
|
||||
@@ -141,6 +141,7 @@ button1.onclick = goStore;
|
||||
button2.onclick = goCave;
|
||||
button3.onclick = fightDragon;
|
||||
|
||||
--fcc-editable-region--
|
||||
function update(location) {
|
||||
button1.innerText = location["button text"];
|
||||
button2.innerText = "Go to cave";
|
||||
@@ -150,6 +151,7 @@ function update(location) {
|
||||
button3.onclick = fightDragon;
|
||||
text.innerText = "You are in the town square. You see a sign that says \"Store\".";
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function goTown() {
|
||||
update(locations[0]);
|
||||
|
||||
@@ -146,6 +146,7 @@ button1.onclick = goStore;
|
||||
button2.onclick = goCave;
|
||||
button3.onclick = fightDragon;
|
||||
|
||||
--fcc-editable-region--
|
||||
function update(location) {
|
||||
button1.innerText = location["button text"][0];
|
||||
button2.innerText = "Go to cave";
|
||||
@@ -155,6 +156,7 @@ function update(location) {
|
||||
button3.onclick = fightDragon;
|
||||
text.innerText = "You are in the town square. You see a sign that says \"Store\".";
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function goTown() {
|
||||
update(locations[0]);
|
||||
|
||||
@@ -151,6 +151,7 @@ button1.onclick = goStore;
|
||||
button2.onclick = goCave;
|
||||
button3.onclick = fightDragon;
|
||||
|
||||
--fcc-editable-region--
|
||||
function update(location) {
|
||||
button1.innerText = location["button text"][0];
|
||||
button2.innerText = location["button text"][1];
|
||||
@@ -160,6 +161,7 @@ function update(location) {
|
||||
button3.onclick = fightDragon;
|
||||
text.innerText = "You are in the town square. You see a sign that says \"Store\".";
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function goTown() {
|
||||
update(locations[0]);
|
||||
|
||||
@@ -137,6 +137,7 @@ button1.onclick = goStore;
|
||||
button2.onclick = goCave;
|
||||
button3.onclick = fightDragon;
|
||||
|
||||
--fcc-editable-region--
|
||||
function update(location) {
|
||||
button1.innerText = location["button text"][0];
|
||||
button2.innerText = location["button text"][1];
|
||||
@@ -146,6 +147,7 @@ function update(location) {
|
||||
button3.onclick = location["button functions"][2];
|
||||
text.innerText = "You are in the town square. You see a sign that says \"Store\".";
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function goTown() {
|
||||
update(locations[0]);
|
||||
|
||||
@@ -149,8 +149,10 @@ function goTown() {
|
||||
update(locations[0]);
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function goStore() {
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function goCave() {
|
||||
console.log("Going to cave.");
|
||||
|
||||
@@ -127,6 +127,7 @@ const monsterStats = document.querySelector("#monsterStats");
|
||||
const monsterNameText = document.querySelector("#monsterName");
|
||||
const monsterHealthText = document.querySelector("#monsterHealth");
|
||||
|
||||
--fcc-editable-region--
|
||||
const locations = [
|
||||
{
|
||||
name: "town square",
|
||||
@@ -141,6 +142,7 @@ const locations = [
|
||||
text: "You enter the store."
|
||||
}
|
||||
];
|
||||
--fcc-editable-region--
|
||||
|
||||
// initialize buttons
|
||||
button1.onclick = goStore;
|
||||
|
||||
@@ -164,9 +164,11 @@ function goStore() {
|
||||
update(locations[1]);
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function goCave() {
|
||||
console.log("Going to cave.");
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function fightDragon() {
|
||||
console.log("Fighting dragon.");
|
||||
|
||||
@@ -172,7 +172,9 @@ function buyHealth() {
|
||||
|
||||
function buyWeapon() {
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
--fcc-editable-region--
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
@@ -169,8 +169,10 @@ function fightDragon() {
|
||||
console.log("Fighting dragon.");
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function buyHealth() {
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function buyWeapon() {
|
||||
}
|
||||
|
||||
@@ -167,9 +167,11 @@ function fightDragon() {
|
||||
console.log("Fighting dragon.");
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function buyHealth() {
|
||||
gold = gold - 10;
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function buyWeapon() {
|
||||
}
|
||||
|
||||
@@ -172,10 +172,12 @@ function fightDragon() {
|
||||
console.log("Fighting dragon.");
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function buyHealth() {
|
||||
gold = gold - 10;
|
||||
health = health + 10;
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function buyWeapon() {
|
||||
}
|
||||
|
||||
@@ -170,10 +170,12 @@ function fightDragon() {
|
||||
console.log("Fighting dragon.");
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function buyHealth() {
|
||||
gold -= 10;
|
||||
health += 10;
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function buyWeapon() {
|
||||
}
|
||||
|
||||
@@ -187,12 +187,14 @@ function fightDragon() {
|
||||
console.log("Fighting dragon.");
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function buyHealth() {
|
||||
gold -= 10;
|
||||
health += 10;
|
||||
goldText.innerText = gold;
|
||||
healthText.innerText = health;
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function buyWeapon() {
|
||||
}
|
||||
|
||||
@@ -175,6 +175,7 @@ function fightDragon() {
|
||||
console.log("Fighting dragon.");
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function buyHealth() {
|
||||
if (condition) {
|
||||
gold -= 10;
|
||||
@@ -183,6 +184,7 @@ function buyHealth() {
|
||||
healthText.innerText = health;
|
||||
}
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function buyWeapon() {
|
||||
}
|
||||
|
||||
@@ -176,6 +176,7 @@ function fightDragon() {
|
||||
console.log("Fighting dragon.");
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function buyHealth() {
|
||||
if (gold >= 10) {
|
||||
gold -= 10;
|
||||
@@ -184,6 +185,7 @@ function buyHealth() {
|
||||
healthText.innerText = health;
|
||||
}
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function buyWeapon() {
|
||||
}
|
||||
|
||||
@@ -169,6 +169,7 @@ function fightDragon() {
|
||||
console.log("Fighting dragon.");
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function buyHealth() {
|
||||
if (gold >= 10) {
|
||||
gold -= 10;
|
||||
@@ -179,6 +180,7 @@ function buyHealth() {
|
||||
|
||||
}
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function buyWeapon() {
|
||||
}
|
||||
|
||||
@@ -114,7 +114,9 @@ const goldText = document.querySelector("#goldText");
|
||||
const monsterStats = document.querySelector("#monsterStats");
|
||||
const monsterNameText = document.querySelector("#monsterName");
|
||||
const monsterHealthText = document.querySelector("#monsterHealth");
|
||||
--fcc-editable-region--
|
||||
|
||||
--fcc-editable-region--
|
||||
const locations = [
|
||||
{
|
||||
name: "town square",
|
||||
|
||||
@@ -120,7 +120,9 @@ const monsterStats = document.querySelector("#monsterStats");
|
||||
const monsterNameText = document.querySelector("#monsterName");
|
||||
const monsterHealthText = document.querySelector("#monsterHealth");
|
||||
|
||||
--fcc-editable-region--
|
||||
const weapons = [];
|
||||
--fcc-editable-region--
|
||||
|
||||
const locations = [
|
||||
{
|
||||
|
||||
@@ -197,8 +197,10 @@ function buyHealth() {
|
||||
}
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function buyWeapon() {
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function fightSlime() {
|
||||
}
|
||||
|
||||
@@ -197,11 +197,13 @@ function buyHealth() {
|
||||
}
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function buyWeapon() {
|
||||
if (gold >= 30) {
|
||||
|
||||
}
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function fightSlime() {
|
||||
}
|
||||
|
||||
@@ -197,11 +197,13 @@ function buyHealth() {
|
||||
}
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function buyWeapon() {
|
||||
if (gold >= 30) {
|
||||
gold -= 30;
|
||||
}
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function fightSlime() {
|
||||
}
|
||||
|
||||
@@ -205,12 +205,14 @@ function buyHealth() {
|
||||
}
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function buyWeapon() {
|
||||
if (gold >= 30) {
|
||||
gold -= 30;
|
||||
currentWeapon += 1;
|
||||
}
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function fightSlime() {
|
||||
}
|
||||
|
||||
@@ -201,12 +201,14 @@ function buyHealth() {
|
||||
}
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function buyWeapon() {
|
||||
if (gold >= 30) {
|
||||
gold -= 30;
|
||||
currentWeapon++;
|
||||
}
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function fightSlime() {
|
||||
}
|
||||
|
||||
@@ -197,6 +197,7 @@ function buyHealth() {
|
||||
}
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function buyWeapon() {
|
||||
if (gold >= 30) {
|
||||
gold -= 30;
|
||||
@@ -205,6 +206,7 @@ function buyWeapon() {
|
||||
text.innerText = "You now have a new weapon.";
|
||||
}
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function fightSlime() {
|
||||
}
|
||||
|
||||
@@ -197,6 +197,7 @@ function buyHealth() {
|
||||
}
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function buyWeapon() {
|
||||
if (gold >= 30) {
|
||||
gold -= 30;
|
||||
@@ -206,6 +207,7 @@ function buyWeapon() {
|
||||
text.innerText = "You now have a new weapon.";
|
||||
}
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function fightSlime() {
|
||||
}
|
||||
|
||||
@@ -199,6 +199,7 @@ function buyHealth() {
|
||||
}
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function buyWeapon() {
|
||||
if (gold >= 30) {
|
||||
gold -= 30;
|
||||
@@ -208,6 +209,7 @@ function buyWeapon() {
|
||||
text.innerText = "You now have a new weapon.";
|
||||
}
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function fightSlime() {
|
||||
}
|
||||
|
||||
@@ -208,6 +208,7 @@ function buyHealth() {
|
||||
}
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function buyWeapon() {
|
||||
if (gold >= 30) {
|
||||
gold -= 30;
|
||||
@@ -217,6 +218,7 @@ function buyWeapon() {
|
||||
text.innerText = "You now have a new weapon.";
|
||||
}
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function fightSlime() {
|
||||
}
|
||||
|
||||
@@ -204,6 +204,7 @@ function buyHealth() {
|
||||
}
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function buyWeapon() {
|
||||
if (gold >= 30) {
|
||||
gold -= 30;
|
||||
@@ -213,6 +214,7 @@ function buyWeapon() {
|
||||
text.innerText = "You now have a " + newWeapon + ".";
|
||||
}
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function fightSlime() {
|
||||
}
|
||||
|
||||
@@ -203,6 +203,7 @@ function buyHealth() {
|
||||
}
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function buyWeapon() {
|
||||
if (gold >= 30) {
|
||||
gold -= 30;
|
||||
@@ -213,6 +214,7 @@ function buyWeapon() {
|
||||
inventory.push(newWeapon);
|
||||
}
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function fightSlime() {
|
||||
}
|
||||
|
||||
@@ -203,6 +203,7 @@ function buyHealth() {
|
||||
}
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function buyWeapon() {
|
||||
if (gold >= 30) {
|
||||
gold -= 30;
|
||||
@@ -214,6 +215,7 @@ function buyWeapon() {
|
||||
text.innerText += " In your inventory you have: ";
|
||||
}
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function fightSlime() {
|
||||
}
|
||||
|
||||
@@ -203,6 +203,7 @@ function buyHealth() {
|
||||
}
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function buyWeapon() {
|
||||
if (gold >= 30) {
|
||||
gold -= 30;
|
||||
@@ -214,6 +215,7 @@ function buyWeapon() {
|
||||
text.innerText += " In your inventory you have: " + inventory;
|
||||
}
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function fightSlime() {
|
||||
}
|
||||
|
||||
@@ -208,6 +208,7 @@ function buyHealth() {
|
||||
}
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function buyWeapon() {
|
||||
if (gold >= 30) {
|
||||
gold -= 30;
|
||||
@@ -221,6 +222,7 @@ function buyWeapon() {
|
||||
text.innerText = "You do not have enough gold to buy a weapon.";
|
||||
}
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function fightSlime() {
|
||||
}
|
||||
|
||||
@@ -203,6 +203,7 @@ function buyHealth() {
|
||||
}
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function buyWeapon() {
|
||||
if (currentWeapon < 3) {
|
||||
if (gold >= 30) {
|
||||
@@ -218,6 +219,7 @@ function buyWeapon() {
|
||||
}
|
||||
}
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function fightSlime() {
|
||||
}
|
||||
|
||||
@@ -203,6 +203,7 @@ function buyHealth() {
|
||||
}
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function buyWeapon() {
|
||||
if (currentWeapon < weapons.length) {
|
||||
if (gold >= 30) {
|
||||
@@ -218,6 +219,7 @@ function buyWeapon() {
|
||||
}
|
||||
}
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function fightSlime() {
|
||||
}
|
||||
|
||||
@@ -203,6 +203,7 @@ function buyHealth() {
|
||||
}
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function buyWeapon() {
|
||||
if (currentWeapon < weapons.length - 1) {
|
||||
if (gold >= 30) {
|
||||
@@ -218,6 +219,7 @@ function buyWeapon() {
|
||||
}
|
||||
}
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function fightSlime() {
|
||||
}
|
||||
|
||||
@@ -203,6 +203,7 @@ function buyHealth() {
|
||||
}
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function buyWeapon() {
|
||||
if (currentWeapon < weapons.length - 1) {
|
||||
if (gold >= 30) {
|
||||
@@ -220,6 +221,7 @@ function buyWeapon() {
|
||||
text.innerText = "You already have the most powerful weapon!";
|
||||
}
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function fightSlime() {
|
||||
}
|
||||
|
||||
@@ -216,7 +216,9 @@ function buyWeapon() {
|
||||
button2.onclick = sellWeapon;
|
||||
}
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
--fcc-editable-region--
|
||||
function fightSlime() {
|
||||
}
|
||||
|
||||
|
||||
@@ -221,8 +221,10 @@ function buyWeapon() {
|
||||
}
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function sellWeapon() {
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function fightSlime() {
|
||||
}
|
||||
|
||||
@@ -230,11 +230,13 @@ function buyWeapon() {
|
||||
}
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function sellWeapon() {
|
||||
if (inventory.length > 1) {
|
||||
|
||||
}
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function fightSlime() {
|
||||
}
|
||||
|
||||
@@ -221,12 +221,14 @@ function buyWeapon() {
|
||||
}
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function sellWeapon() {
|
||||
if (inventory.length > 1) {
|
||||
gold += 15;
|
||||
goldText.innerText = gold;
|
||||
}
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function fightSlime() {
|
||||
}
|
||||
|
||||
@@ -229,6 +229,7 @@ function buyWeapon() {
|
||||
}
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function sellWeapon() {
|
||||
if (inventory.length > 1) {
|
||||
gold += 15;
|
||||
@@ -236,6 +237,7 @@ function sellWeapon() {
|
||||
let currentWeapon;
|
||||
}
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function fightSlime() {
|
||||
}
|
||||
|
||||
@@ -219,6 +219,7 @@ function buyWeapon() {
|
||||
}
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function sellWeapon() {
|
||||
if (inventory.length > 1) {
|
||||
gold += 15;
|
||||
@@ -227,6 +228,7 @@ function sellWeapon() {
|
||||
|
||||
}
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function fightSlime() {
|
||||
}
|
||||
|
||||
@@ -221,6 +221,7 @@ function buyWeapon() {
|
||||
}
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function sellWeapon() {
|
||||
if (inventory.length > 1) {
|
||||
gold += 15;
|
||||
@@ -230,6 +231,7 @@ function sellWeapon() {
|
||||
|
||||
}
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function fightSlime() {
|
||||
}
|
||||
|
||||
@@ -222,6 +222,7 @@ function buyWeapon() {
|
||||
}
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function sellWeapon() {
|
||||
if (inventory.length > 1) {
|
||||
gold += 15;
|
||||
@@ -231,6 +232,7 @@ function sellWeapon() {
|
||||
text.innerText += " In your inventory you have: " + inventory;
|
||||
}
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function fightSlime() {
|
||||
}
|
||||
|
||||
@@ -121,6 +121,10 @@ const monsterStats = document.querySelector("#monsterStats");
|
||||
const monsterNameText = document.querySelector("#monsterName");
|
||||
const monsterHealthText = document.querySelector("#monsterHealth");
|
||||
|
||||
--fcc-editable-region--
|
||||
|
||||
--fcc-editable-region--
|
||||
|
||||
const weapons = [
|
||||
{
|
||||
name: "stick",
|
||||
|
||||
@@ -242,6 +242,7 @@ function sellWeapon() {
|
||||
text.innerText = "Don't sell your only weapon!";
|
||||
}
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function fightSlime() {
|
||||
}
|
||||
@@ -253,6 +254,8 @@ function fightDragon() {
|
||||
console.log("Fighting dragon.");
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
@@ -245,8 +245,10 @@ function sellWeapon() {
|
||||
}
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function fightSlime() {
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function fightBeast() {
|
||||
}
|
||||
|
||||
@@ -251,12 +251,14 @@ function fightSlime() {
|
||||
goFight();
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function fightBeast() {
|
||||
}
|
||||
|
||||
function fightDragon() {
|
||||
console.log("Fighting dragon.");
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function goFight() {
|
||||
}
|
||||
|
||||
@@ -162,6 +162,7 @@ const monsters = [
|
||||
}
|
||||
];
|
||||
|
||||
--fcc-editable-region--
|
||||
const locations = [
|
||||
{
|
||||
name: "town square",
|
||||
@@ -182,6 +183,7 @@ const locations = [
|
||||
text: "You enter the cave. You see some monsters."
|
||||
}
|
||||
];
|
||||
--fcc-editable-region--
|
||||
|
||||
// initialize buttons
|
||||
button1.onclick = goStore;
|
||||
|
||||
@@ -266,6 +266,9 @@ function fightDragon() {
|
||||
|
||||
function goFight() {
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
--fcc-editable-region--
|
||||
|
||||
</script>
|
||||
```
|
||||
|
||||
@@ -264,8 +264,10 @@ function fightDragon() {
|
||||
goFight();
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function goFight() {
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function attack() {
|
||||
}
|
||||
|
||||
@@ -277,9 +277,11 @@ function fightDragon() {
|
||||
goFight();
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function goFight() {
|
||||
update(locations[3]);
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function attack() {
|
||||
}
|
||||
|
||||
@@ -270,10 +270,12 @@ function fightDragon() {
|
||||
goFight();
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function goFight() {
|
||||
update(locations[3]);
|
||||
monsterHealth = monsters[fighting].health;
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function attack() {
|
||||
}
|
||||
|
||||
@@ -279,11 +279,13 @@ function fightDragon() {
|
||||
goFight();
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function goFight() {
|
||||
update(locations[3]);
|
||||
monsterHealth = monsters[fighting].health;
|
||||
monsterStats.style.display = "block";
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function attack() {
|
||||
}
|
||||
|
||||
@@ -272,8 +272,10 @@ function goFight() {
|
||||
monsterHealthText.innerText = monsterHealth;
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function attack() {
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function dodge() {
|
||||
}
|
||||
|
||||
@@ -277,9 +277,11 @@ function goFight() {
|
||||
monsterHealthText.innerText = monsterHealth;
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function attack() {
|
||||
text.innerText = "The " + monsters[fighting].name + " attacks.";
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function dodge() {
|
||||
}
|
||||
|
||||
@@ -272,10 +272,12 @@ function goFight() {
|
||||
monsterHealthText.innerText = monsterHealth;
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function attack() {
|
||||
text.innerText = "The " + monsters[fighting].name + " attacks.";
|
||||
text.innerText += " You attack it with your " + weapons[currentWeapon].name + ".";
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function dodge() {
|
||||
}
|
||||
|
||||
@@ -272,11 +272,13 @@ function goFight() {
|
||||
monsterHealthText.innerText = monsterHealth;
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
function attack() {
|
||||
text.innerText = "The " + monsters[fighting].name + " attacks.";
|
||||
text.innerText += " You attack it with your " + weapons[currentWeapon].name + ".";
|
||||
health -= monsters[fighting].level;
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function dodge() {
|
||||
}
|
||||
|
||||
@@ -278,12 +278,14 @@ function goFight() {
|
||||
monsterHealthText.innerText = monsterHealth;
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
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;
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function dodge() {
|
||||
}
|
||||
|
||||
@@ -277,12 +277,14 @@ function goFight() {
|
||||
monsterHealthText.innerText = monsterHealth;
|
||||
}
|
||||
|
||||
--fcc-editable-region--
|
||||
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;
|
||||
}
|
||||
--fcc-editable-region--
|
||||
|
||||
function dodge() {
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user