Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Game submit #100

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
19 changes: 18 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

81 changes: 78 additions & 3 deletions textBasedAdventure.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,80 @@
const readline1 = require('readline-sync')
const readlineSync = require('readline-sync')

let nameInput = readline.question("Enter your name: ")
const startGame = () => {
console.log("Welcome")
let answer = readlineSync.keyInYN("Are you ready?")
if (answer) {
play()
} else {
leaveGame()
Process.exit()
}

console.log(`Hello ${nameInput}! Welcome to my game.`)
}
const leaveGame = () => {
let leavingAnswer = readlineSync.keyInYN("Aww man, it looks like you kicked the bucket\n Would you like to try again?")
if (leavingAnswer) {
play()
} else {
console.log("Goodbye")
}
}

const youWin = () => {
let winningResponse = readlineSync.keyInYN('Would you like to play again')
if (winningResponse) {
play()
}else console.log("Goodbye")
}


const play = () => {

let nameInput = readlineSync.question("Enter your name: ")

let title = "A Warrior's Digest!"

console.log('Hello ' + nameInput)

console.log("Welcome to " + title)

console.log('You ' + nameInput + ' are a gifted warrior from the ancient lands of True North.\n After countless years away you have finally returned home. Only to find ')
console.log('The objective of the game is to defeat the dragon and save your homeland.')

let arr = ["Sword", "Bow & Arrow"]

let warriorChoice = readlineSync.keyInSelect(arr, "Please, choose your weapon: ")

console.log(nameInput +' has chosen the ' + arr[warriorChoice])


console.log('There is a terrible dragon that has been destroying the lands of True North! \n You are the only hope for your lands survival!')

let arr2 = ["Head", "Body", "Tail"]
let question2 = readlineSync.keyInYN("Will you " + nameInput + " face said dragon now?")
if (question2 === true) {
let question3 = readlineSync.keyInYN("Will you use the " + arr[warriorChoice] + " to attack?")
console.log(question3)
} else {console.log('Welp... the dragon ate you')
leaveGame()
process.exit()
}
if (question3 === arr2.length-2) {
let question4 = readlineSync.keyInSelect(arr2, "where will you use the " + arr[warriorChoice] + " to attack next?")
console.log(question4)
} else {
leaveGame()
process.exit()
}
let question5 = readlineSync.keyInSelect(arr2, 'Where will you attack next?')
if (question5 === arr2.length-1) {
console.log("Congratulations!!!!!!!!!!!!!!!\n You have slain the dragon!!!!!!!!!")
youWin()
} else {
leaveGame()
}

}


startGame()