Skip to content

Commit

Permalink
changes to code
Browse files Browse the repository at this point in the history
  • Loading branch information
pcm20001 committed Feb 11, 2024
1 parent 0ef0887 commit d84f78e
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 6 deletions.
6 changes: 3 additions & 3 deletions week-04/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ <h5 class="card-header">Confirm</h5>
<div class="card-body">
<h5 class="card-title">Question</h5>
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
<button class="btn btn-primary btn-true">OK</button>
<button class="btn btn-secondary btn-false">Cancel</button>
<button class="btn btn-primary btn-true">Yes</button>
<button class="btn btn-secondary btn-false">No</button>
</div>
</div>
</template>
Expand All @@ -52,7 +52,7 @@ <h5 class="card-title">What is Your Name?</h5>
</label>
<input type="text" class="form-control" id="exampleFormControlInput1" placeholder="Type your response...">
</div>
<button class="btn btn-primary btn-true">OK</button>
<button class="btn btn-primary btn-true">Confirm</button>
<button class="btn btn-secondary btn-false">Cancel</button>
</div>
</div>
Expand Down
124 changes: 121 additions & 3 deletions week-04/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

0 comments on commit d84f78e

Please sign in to comment.