Skip to content
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 guessing_game_ryan
Submodule guessing_game_ryan added at e1cd62
102 changes: 41 additions & 61 deletions guessinggame.html
Original file line number Diff line number Diff line change
@@ -1,62 +1,42 @@
<script type="text/javascript">
<!doctype html>
<html>
<head>
<title><b>Guessing My Concert Attendance in 2015</b></title>
</head>

<body>
<h1 style ="font-family:Arial;color:Orange;font-size:64px"><em>Have You Been Stalking Me?</em>The Guessing Game Based On My Concert Attendance in 2015</h1>

<img src="http://www.mikemezphotography.com/wp-content/uploads/2014/11/Slipknot-10.jpg" height="300px" width="500px"/>

<a href="http://www.google.com">Google</a>
<p id="result" style="color:Pink;font-stlye:serif;font-size:42px"></p>


<h2 style ="color:Red"><i>How Does My Game Work You Might Ask?</i></h2>
<p>The games starts with the prompt asking the player to take a stab at how the number of concerts I, the gamemaker, have attended in 2015. If the player is incorrect, the player will be asked to choose again. The player has 4 chances to choose the correct amount of concerts. Don't fret young padawin, there are several hints that are displayed after every wrong answer. These prompts will let you know if you are guessing too high or too low. So now that you know the rules, are you a terrible friend or are you a <b>STALKER?</b>
</p>

<h3 style ="color:Green"><i>List Of Guesses When You Answer Wrong</i></h3>

<ul>

<li>If the player guesses too low, they are prompted with a Mr.T type prompt</li>
<img src="http://spinoff.comicbookresources.com/wp-content/uploads/2014/06/mr-t.jpeg" height="300px" width="500px"/>
<li id="high">If the player guesses too high, they are prompted with a Cold Pop type prompt</li>
<img src="http://img.memecdn.com/ain-amp-039-t-nobody-got-time-for-that_o_1582005.jpg" height="300px" width="500px"/>

</ul>



<img src="http://i17.tinypic.com/2z65p2q.jpg" height="300px" width="500px"/>

<h4 style ="color:Blue;font-size:62px"><i>Are You Brave Enough To Play?</i>

<script src="guessinggame.js"></script>


</head>
</html>

// Asks the user to guess how many states I, the developer,
// have lived in. The user keeps guessing with guidance
// until they get the right answer. Once the user gets the
// right answer they will be asked to guess one of the states
// I have lived in. The user gets one shot to correctly guess
// one of the states I have lived in.

// Prompt the user for their guess
var userGuess = prompt("How many states have I lived in?");
console.log("The user guessed" + userGuess);

var answer = 7;
var numbTries = 1;
var message;
// Make the user keep guessing until they get it right.
// Hints are offered.
while (userGuess != answer && numbTries <= 5) {
if (userGuess <= 6) {
var userGuess = prompt("That's a little too low. Try again.");
} else if (userGuess >= 8) {
var userGuess = prompt("That's a bit too high. Guess again.");
}
numbTries +1;
}

if (userGuess >=5){
message = "The right answer is 7, Can you name one of the states?";
}else {
message = "Are you a stalker? You are correct. Can you name one of the states?";
}


// Once the user gets the right answer they're asked to name
// one of the states I've lived in. They get one chance.
var stateGuess = prompt(message);

var states = ["michigan", "maryland", "virginia", "new york", "colorado", "alaska", "washington" ]


// Idea to write this search function from http://stackoverflow.com/questions/143847/best-way-to-find-an-item-in-a-javascript-array
// and from the codecademy homework.

function include(array1, string1) {
for (var i = 0; i < array1.length; i++) {
if (string1.toLowerCase() == array1[i]) {
return true;
}
}
}

// call the 'include' function to see if the guess is in the array of right
// answers.
if (include(states,stateGuess)) {
alert("Yup. I've lived there!");
} else {
alert("I haven't lived there yet but perhaps some day I will.");
}


</script>
75 changes: 75 additions & 0 deletions guessinggame.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// THIS INSTANTIATES THE GAME
// var game5 = new Game(["Metallica", "Red Hot Chili Peppers","311","Melvins"]);

// var sam = new Game(["Devo", "The Replacements", "Elvis Costello", "Jack White", "Bootsy Collins"]);

// THIS RUNS THE GAME
// game5.run();

var Game = function(answer) {

this.answer = answer;
this.concerts = answer.length; // property, instance.concerts
// this.counter = 0;
var guess = "";

this.run = function() { // method, instance.run()

var counter = 0;
var play = confirm("Do you want to guess how many concerts I have been to in 2015?");

console.log("The user guessed " + guess);
console.log("The correct answer is " + this.concerts);

while (play && guess != this.concerts && counter < 10) {

if (counter === 0) {
guess = prompt("Can you guess how many concerts I have been to in 2015?");
}

++counter;
console.log("Counter after increment " + counter);

if (guess <= (this.concerts - 1)) {
var el = document.getElementById("result");
el.innerHTML = "I pity the fool that would guess that low! Guess again!"
//guess = prompt("I pity the fool that would guess that low! Guess again!");

} else if (guess >= (this.concerts + 1)) {
var el = document.getElementById("result")
el.innerHTML = "Ain't nobody got time for that many concerts!"
//guess = prompt("Ain't nobody got time for that many concerts! Guess again!");
}
}

console.log("While loop over after 10 fails");

if (guess != this.concerts) {
alert("You aren't my real friend. You don't know me at all!");
} else {
alert("It only took you " + counter + " guesses! You must have gone to some shows with me. Here's who I saw: ");
}

for (var i = 0; i < this.concerts; i++) {
alert(this.answer[i]);
}

alert(this.answer[0]);
alert(this.answer[1]);
alert(this.answer[2]);
alert(this.answer[3]);

};
}

// var game3 = new Game(["dogs","cats","snakes"]);
// game3.run();
// var game4 = new Game ([1,2,3,4,5,6,7,8,9,10]);
// game4.run();

// THIS INSTANTIATES THE GAME
var game5 = new Game(["Metallica", "Red Hot Chili Peppers","311","Melvins"]);

// THIS RUNS THE GAME
game5.run();

58 changes: 58 additions & 0 deletions guessinggame.js~
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

// Asks the user to guess how many states I, the developer,
// have lived in. The user keeps guessing with guidance
// until they get the right answer. Once the user gets the
// right answer they will be asked to guess one of the states
// I have lived in. The user gets one shot to correctly guess
// one of the states I have lived in.

// Prompt the user for their guess
var userGuess = prompt("How many states have I lived in?");
console.log("The user guessed" + userGuess);

var answer = 7;
var numbTries = 1;
var message;
// Make the user keep guessing until they get it right.
// Hints are offered.
while (userGuess != answer && numbTries <= 5) {
if (userGuess <= 6) {
var userGuess = prompt("That's a little too low. Try again.");
} else if (userGuess >= 8) {
var userGuess = prompt("That's a bit too high. Guess again.");
}
numbTries +1;
}

if (userGuess >=5){
message = "The right answer is 7, Can you name one of the states?";
}else {
message = "Are you a stalker? You are correct. Can you name one of the states?";
}


// Once the user gets the right answer they're asked to name
// one of the states I've lived in. They get one chance.
var stateGuess = prompt(message);

var states = ["michigan", "maryland", "virginia", "new york", "colorado", "alaska", "washington" ]


// Idea to write this search function from http://stackoverflow.com/questions/143847/best-way-to-find-an-item-in-a-javascript-array
// and from the codecademy homework.

function include(array1, string1) {
for (var i = 0; i < array1.length; i++) {
if (string1.toLowerCase() == array1[i]) {
return true;
}
}
}

// call the 'include' function to see if the guess is in the array of right
// answers.
if (include(states,stateGuess)) {
alert("Yup. I've lived there!");
} else {
alert("I haven't lived there yet but perhaps some day I will.");
}