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
46 changes: 46 additions & 0 deletions css/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
body {
background: #302c2c;
font-family: 'Chilanka', cursive;

}

main {
background: gray;
margin: auto;
width: 50%;
padding: 30px;
}


button {
background: #ffdc8b;
border: 1px solid #716d6d;
padding: 20px;
width: 9em;
border-radius: 40px;
}

button:focus {
outline: unset;
}

button:hover {
background: #eaf64f;
}

.btns-container {
display: flex;
justify-content: space-around;
background: #b3ae95;
padding: 10px;

}

#result {
background: burlywood;
text-align: center;
font-size: 1.8em;
padding: 20px;


}
122 changes: 122 additions & 0 deletions debug.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
[0901/144401.283:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.286:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.286:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.286:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.286:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.287:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.287:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.287:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.287:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.287:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.287:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.287:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.287:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.287:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.287:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.287:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.287:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.287:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.288:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.288:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.288:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.288:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.288:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.288:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.288:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.288:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.288:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.288:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.288:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.288:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.288:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.288:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.288:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.288:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.288:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.288:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.288:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.288:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.288:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.289:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.289:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.289:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.290:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.290:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.290:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.290:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.290:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.290:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.290:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.290:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.290:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.290:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.290:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.290:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.290:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.290:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.290:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.290:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.291:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.291:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0901/144401.291:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.973:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.973:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.973:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.973:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.973:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.973:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.974:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.974:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.974:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.974:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.974:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.974:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.974:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.974:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.974:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.974:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.974:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.974:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.974:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.974:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.974:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.974:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.974:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.974:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.974:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.974:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.974:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.974:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.974:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.974:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.974:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.974:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.974:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.974:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.975:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.975:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.975:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.975:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.975:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.975:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.975:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.975:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.975:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.975:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.975:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.975:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.975:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.975:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.975:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.975:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.975:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.975:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.975:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.976:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.976:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.976:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.976:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.976:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.976:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.976:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0922/115921.976:ERROR:crash_report_database_win.cc(469)] failed to stat report
104 changes: 101 additions & 3 deletions game.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,101 @@
// Write all your code here
// Replace the contents of this file with your own code
console.log('Hello, world!');
const choices = ["ROCK", "SCISSOR", "PAPER"];

function computerPlay() {
return choices[Math.floor(Math.random() * choices.length)];
}


let counter = {
computer: 0,
user: 0,
tie: 0
};
let btns = document.getElementsByClassName('btns-container')[0];
btns.addEventListener('click', function (e) {
if (e.target.tagName = 'BUTTON') {
let playerSelection = e.target.innerHTML;
let computerSelection = computerPlay();
let result = playRound(playerSelection, computerSelection);
winCounter(result, playerSelection, computerSelection);

}

});


let p = document.getElementById('result');

// track result
function winCounter(result, playerSelection, computerSelection) {
if (result == 'computer') {
counter.computer++;
p.innerHTML = ` You Lose ${computerSelection} Beats ${playerSelection}`;
} else if (result == 'user') {
counter.user++;
p.innerHTML = ` You Win ${playerSelection} Beats ${computerSelection}`;
} else if (result == 'tie') {
p.innerHTML = ` Tie ! ${playerSelection} VS ${computerSelection}`;
counter.tie++;
}
console.log("result is " + counter)
score.innerHTML = "Compter: " + counter.computer;
score.innerHTML += " | You:" + counter.user;
score.innerHTML += " Tie:" + counter.tie;
finalWinner(counter);
}



let score = document.getElementById("score");
// declare the winner who win in five rounds
function finalWinner(counter) {
resetCounter = false;
if (counter.computer >= 5) {
console.log('done computer win')
resetCounter = true;
p.innerHTML = "Congratulation You Won five rounds"
} else if (counter.user >= 5) {
console.log('done user win ')
resetCounter = true;
p.innerHTML = "Unfortunately lose in five rounds"
}

//reset the counter
if (resetCounter) {
for (let prop in counter)
counter[prop] = 0;

}
}





function playRound(playerSelection, computerSelection) {
//playerSelection = playerSelection.toUpperCase();

//if( (playerSelection !== "ROCK") && (playerSelection !== "PAPER") && (playerSelection !== "SCISSOR") ){
// return "INVALID INPUT";
//}

computerWin = false;
if (playerSelection === computerSelection) {
return "tie"
} else if (playerSelection == "ROCK" && computerSelection == "PAPER") {
computerWin = true;
} else if (playerSelection == "PAPER" && computerSelection == "SCISSOR") {
computerWin = true;
} else if (playerSelection == "SCISSOR" && computerSelection == "ROCK") {
computerWin = true;
}

if (computerWin)
return 'computer';
else
return 'user';

}


//game();
25 changes: 21 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<title>Rock, Paper, Scissors!</title>
<script src="game.js" defer></script>
<meta charset="UTF-8">
<link href="https://fonts.googleapis.com/css?family=Chilanka&display=swap" rel="stylesheet">
<title>Rock, Paper, Scissors!</title>
<script src="game.js" defer></script>
<link rel="stylesheet" type="text/css" href="css/main.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>

<body>
<main>
<div class="btns-container">
<button>ROCK</button>
<button>PAPER</button>
<button>SCISSOR</button>
</div>
<section>
<p id="result"> You win, rock beats scissor</p>
</section>
<div id="score">sdfsadfsd</div>
</main>
</body>
</html>

</html>