From d84f78e4f5b3237b294b92014064c6b2e852aa2b Mon Sep 17 00:00:00 2001 From: Pamela Mackingue Date: Sat, 10 Feb 2024 20:26:17 -0500 Subject: [PATCH] changes to code --- week-04/index.html | 6 +-- week-04/js/main.js | 124 +++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 124 insertions(+), 6 deletions(-) diff --git a/week-04/index.html b/week-04/index.html index ab91e14..b47752d 100644 --- a/week-04/index.html +++ b/week-04/index.html @@ -36,8 +36,8 @@
Confirm
Question

With supporting text below as a natural lead-in to additional content.

- - + +
@@ -52,7 +52,7 @@
What is Your Name?
- + diff --git a/week-04/js/main.js b/week-04/js/main.js index df9bd66..bf9d548 100644 --- a/week-04/js/main.js +++ b/week-04/js/main.js @@ -6,15 +6,133 @@ import { Alert, Confirm, Prompt } from "./game-framework.js"; // Modify the text for the introduction -await Alert('Welcome to my game. Answer questions and complete tasks to escape the room!') +await Alert('In this short game, try to survive as you face an oncoming storm...') -let name = await Prompt("What is your name?") +let name = await Prompt("Hello there, what is your name traveler?") // Level 1 -if(await Confirm(`Hi ${name}. Do you want to play the game?`)) { +if(await Confirm(`Hi ${name}. News has been going around that a dangerous storm has made its way to your area. Stranded in the woods, you find a mysterious path. Would you like to take this path?`)) { await Alert('Great! Let\'s get started.') } else { await Alert('That\'s too bad. Maybe next time.') window.location.reload() } +// Level 2 +if (await Confirm(`You take the path. While walking, you find an abandoned home. Do you take shelter?`)) { + if (await Confirm('You stumble upon a mysterious box. Do you open the box?')) { + + } else { + await Alert("That's too bad. Maybe next time."); + let decision = await Prompt('A storm is brewing nearby...do you have a change of heart?'); + if (decision == "Yes") { + await Alert("Although it's been awhile since you passed the house, you attempt to return to the house despite worsening conditions..."); + await Alert("Before you make it back, you find yourself lost..."); + window.location.reload(); + } else if (decision == "No") { + await Alert('As time goes on, the storm gets worse, you find yourself in terrible conditions and collapse from exhaustion...'); + window.location.reload(); + } else { + window.location.reload(); + } + } +} else { + await Alert("That's too bad. Maybe next time."); + window.location.reload(); +} + +// Level 3 +if(await Alert("You open the box, and discover the following materials:")) { + await Alert('1. journal\t2. bow and arrow\t3. potion') + let item = await Prompt("What item would you like to grab? Enter item number.") + + //item 1 + if (item == "1") { + if(await Confirm(`Would you like to pick up the journal?`)) { + await Alert( "What's in here?" ); + await Alert(`"Dear ${name}...", Unfortunately as you read through the journal a hand grabs your shoulder, you're instantly attacked...`); + window.location.reload() + } + //pick up a different item + else { + await Confirm('Would you like to pick up another item?'); + let choice = await Prompt('What would you like to pick up? Enter item number:'); + if (choice == "2") { + await Alert('You picked up a bow and arrow.'); + if(await Confirm(`Would you like to pick up the bow and arrow?`)) { + await Alert('You picked up the weapon. As you do, a shadow grabs your shoulder.') + await Alert('You immediately grab your weapon and use it, succesfully defend yourself. Good job !') + } else { + await Alert('You ditch the bow and arrow and close the box. As you do, something grabs your arm. You are instantly attacked...') + window.location.reload() + } + } else if (choice === "3") { + await Alert('Hello!'); + if (await Confirm(`Would you like to drink the potion?`)) { + await Alert('You drink the potion, and begin to feel weird...'); + await Alert('However, as you try to figure out what was in the potion, you hear a loud noise from nearby...'); + await Alert('Surprisingly, with your new effects, you find yourself speeding through and out the door with a burst of energy. Weird, but good for you!'); + window.location.reload() + } else { + await Alert("Hesitating, you put the potion back in the box."); + } + } else { window.location.reload(); + + } + + } + } + //item 2 + else if (item == "2") { + await Alert('You picked up a bow and arrow.'); + if(await Confirm(`Would you like to pick up the bow and arrow?`)) { + await Alert('You picked up the weapon. As you do, a shadow grabs your shoulder.') + await Alert('You immediately grab your weapon and use it, succesfully defend yourself. Good job !') + } else { + await Alert('You ditch the bow and arrow and close the box. As you do, something grabs your arm. You are instantly attacked...') + window.location.reload() + } + } + //item 3 + else if (item === "3") { + await Alert('Hello!'); + if (await Confirm(`Would you like to drink the potion?`)) { + await Alert('You drink the potion, and begin to feel weird...'); + await Alert('However, as you try to figure out what was in the potion, you hear a loud noise from nearby...'); + await Alert('Surprisingly, with your new effects, you find yourself speeding through and out the door with a burst of energy. Weird, but good for you!'); + window.location.reload() + //pick up a different item + } else { + await Alert("Hesitating, you put the potion back in the box."); + await Confirm('Would you like to pick up another item?'); + await Alert('1. journal\t2. bow and arrow\t3. potion') + let choice = await Prompt('What would you like to pick up? Enter item number:'); + if (choice == "1") { + await Alert( "What's in here?" ); + await Alert(`"Dear ${name}...", Unfortunately as you read through the journal a hand grabs your shoulder, you're instantly attacked...`); + } + else if (item == "2") { + await Alert('You picked up a bow and arrow.'); + if(await Confirm(`Would you like to pick up the bow and arrow?`)) { + await Alert('You picked up the weapon. As you do, a shadow grabs your shoulder.') + await Alert('You immediately grab your weapon and use it, succesfully defend yourself. Good job !') + } else { + await Alert('You ditch the bow and arrow and close the box. As you do, something grabs your arm. You are instantly attacked...') + window.location.reload() + } + } else { + await Alert('Closing the box, you\'re attacked by a mysterious figure...') + window.location.reload(); + + } + + } + } + else { + window.location.reload(); + } + +} +else { + window.location.reload(); +} \ No newline at end of file