-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feedback #1
base: feedback
Are you sure you want to change the base?
Feedback #1
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[![Review Assignment Due Date](https://classroom.github.com/assets/deadline-readme-button-22041afd0340ce965d47ae6ef1cefeee28c7c493a6346c4f15d667ab976d596c.svg)](https://classroom.github.com/a/1XPbwjV5) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Master Mind</title> | ||
<link rel="stylesheet" href="style.css" /> | ||
<script defer src="script.js"></script> | ||
</head> | ||
<body> | ||
<h1>Mastermind</h1> | ||
<div class="container"> | ||
<div class="blue"></div> | ||
<div class="yellow"></div> | ||
<div class="red"></div> | ||
<div class="green"></div> | ||
<div class="orange"></div> | ||
<div class="purple"></div> | ||
<div class="pink"></div> | ||
<div class="cyan"></div> | ||
</div> | ||
<div class="button"> | ||
<button id="btn">Guess !</button> | ||
</div> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"use strict"; | ||
|
||
const button = document.getElementById("btn"); | ||
|
||
const colors = ["red", "blue", "yellow", "green"]; | ||
|
||
const allRounds = 12; | ||
const colorsLength = 4; | ||
let secretColors = ["yellow", "blue", "green", "red"]; | ||
let currentResult = []; | ||
let allTries = 0; | ||
|
||
let color1; | ||
let color2; | ||
let color3; | ||
let color4; | ||
|
||
function startGame() { | ||
color1 = prompt( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ca pourrait etre interessant de valider que le joueur a bien donné une des couleurs disponible |
||
"Please choose the first colors from the listed colors : red, blue, yellow, green" | ||
); | ||
|
||
color2 = prompt( | ||
"Please choose your second color from the listed colors: red, blue, yellow, green" | ||
); | ||
color3 = prompt( | ||
"Please choose your third color from the listed colors: red, blue, yellow, green" | ||
); | ||
color4 = prompt( | ||
"Please choose your fourth color from the listed colors: red, blue, yellow, green" | ||
); | ||
currentResult = color1 + ", " + color2 + ", " + color3 + ", " + color4; | ||
|
||
console.log(currentResult); | ||
validateGuess(); | ||
resetGame(); | ||
} | ||
|
||
function validateGuess() { | ||
if (secretColors.length == currentResult.length) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ici, tu verifie que la réponse a le même nombre de caractere que le resultat caché. Du coup, si le resultat caché etait : "toto" et que ta réponse était "tata", ca considererait que tu a gagné. |
||
console.log("You Won ! 😃"); | ||
} else { | ||
console.log("You lost the game! 😥"); | ||
} | ||
} | ||
validateGuess(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ici, tu n'execute validateGuess que deux fois. |
||
|
||
function resetGame() { | ||
if (allRounds == allTries) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sauf erreur, allTries n'est pas utilisé, mais c'est une bonne idée pour definir la fin de la partie. Tu pourrai l'incrementer a chaque fois que tu execute validateGuess par exemple. |
||
console.log("All rounds up!"); | ||
} | ||
} | ||
resetGame(); | ||
|
||
button.addEventListener("click", startGame); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
body { | ||
background-color: white; | ||
} | ||
|
||
h1 { | ||
font-size: 50px; | ||
font-weight: bold; | ||
color: black; | ||
font-style: italic; | ||
text-align: center; | ||
} | ||
|
||
.container { | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-around; | ||
margin-top: 80px; | ||
} | ||
|
||
.blue { | ||
width: 70px; | ||
height: 70px; | ||
background-color: blue; | ||
border: 2px solid black; | ||
} | ||
|
||
.yellow { | ||
width: 70px; | ||
height: 70px; | ||
background-color: yellow; | ||
border: 2px solid black; | ||
} | ||
|
||
.red { | ||
width: 70px; | ||
height: 70px; | ||
background-color: red; | ||
border: 2px solid black; | ||
} | ||
|
||
.green { | ||
width: 70px; | ||
height: 70px; | ||
background-color: green; | ||
border: 2px solid black; | ||
} | ||
|
||
.orange { | ||
width: 70px; | ||
height: 70px; | ||
background-color: orange; | ||
border: 2px solid black; | ||
} | ||
|
||
.purple { | ||
width: 70px; | ||
height: 70px; | ||
background-color: purple; | ||
border: 2px solid black; | ||
} | ||
|
||
.pink { | ||
width: 70px; | ||
height: 70px; | ||
background-color: pink; | ||
border: 2px solid black; | ||
} | ||
|
||
.cyan { | ||
width: 70px; | ||
height: 70px; | ||
background-color: cyan; | ||
border: 2px solid black; | ||
} | ||
|
||
#btn { | ||
display: block; | ||
background-color: darkcyan; | ||
box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.5); | ||
font-weight: bolder; | ||
margin-top: 150px; | ||
margin-left: 750px; | ||
font-size: 40px; | ||
font-size: 20px; | ||
padding: 15px 30px; | ||
border-radius: 5px; | ||
width: 200px; | ||
height: 60px; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L'idée d'avoir une fonction pour lancer le jeu est bonne. Tu pourrais factorise la recuperation des 4 couleurs avec une boucle