Doing a Rock, paper, scissors, spock, lizard game, and it's not working. Im sure i wasnt writing it correctly, but wanted to do as much as i could before i asked for help. So yeah, it doesnt work :/
Jsfiddle - http://jsfiddle.net/yo5Lnmqn/
html -
<body>
<div id="wrapper">
<h1>Lizard, paper, scissors, spock, rock</h1>
<div id="images">
<img class="game-image" src="Images/lizard.jpg" width="150" height="150" alt="" data-value="1"/>
<img class="game-image" src="Images/paper.jpg" width="150" height="150" alt="" data-value="2"/>
<img class="game-image" src="Images/scissors.jpg" width="150" height="150" alt="" data-value="3"/>
<img class="game-image" src="Images/spock.jpg" width="150" height="150" alt="" data-value="4"/>
<img class="game-image" src="Images/rock.jpg" width="150" height="150" alt="" data-value="5"/>
</div>
<div id="win">
</div>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="unit2.js"></script>
</body>
JS-
$(function(){
$(document).on('click', '.game-image', function(event) {
var value = event.target.data('value');
var comproll = 1 + Math.floor(Math.random() * 5);
//$('#comproll').html('Result: '+comproll)
if (#comproll === 1) {
comp = "Lizard";
}
else if (#comproll === 2) {
comp = "paper";
}
else if (#comproll === 3) {
comp = "scissors";
}
else if (#comproll === 4) {
comp = "Spock";
}
else if (#comproll === 5) {
comp = "Rock";
}
if (#game-image === comproll) {
#win = "This ends in a tie"
}
else if (game-image === 1) {
if (comproll === 2, 4) {
#win = "You win, comp choose" + comp + ".";
} else if (comproll === 3, 5){
#win = "You lose, comp choose " + comp + ".";
}
else if (game-image === 2) {
if (comproll === 4, 5) {
#win = "You win, comp choose" + comp + ".";
} else if (comproll === 1, 3){
#win = "You lose, comp choose " + comp + ".";
}
else if (game-image === 3) {
if (comproll === 1, 2) {
#win = "You win, comp choose" + comp + ".";
} else if (comproll === 4, 5){
#win = "You lose, comp choose " + comp + ".";
}
else if (game-image === 4) {
if (comproll === 3, 5) {
#win = "You win, comp choose" + comp + ".";
} else if (comproll === 1, 2){
#win = "You lose, comp choose " + comp + ".";
}
else if (game-image === 5) {
if (comproll === 1, 3) {
#win = "You win, comp choose" + comp + ".";
} else if (comproll === 2, 4){
#win = "You lose, comp choose " + comp + ".";
}
});//closes play function
});// closes function
as usual, thanks, u guys are awesome.