ajout tp2mvc, tp3 et update des tp 1 et 2

This commit is contained in:
EmmanuelTiamzon
2026-04-14 12:28:43 +02:00
parent d1e3f215aa
commit dbc0fbd946
14 changed files with 404 additions and 85 deletions
+29
View File
@@ -0,0 +1,29 @@
export default class GameModel {
constructor() {
this.choices = ["rock", "paper", "scissors"];
this.score = { player: 0, computer: 0};
}
getComputerChoice() {
const index = Math.floor(Math.random() * this.choices.length);
return this.choices[index];
}
getResult(player, computer) {
if (player === computer) return "égalité";
if (
(player === "rock" && computer === "scissors") ||
(player === "paper" && computer === "rock") ||
(player === "scissors" && computer === "paper")
) {
this.score.player++;
return "gagné";
}
this.score.computer++;
return "perdu";
}
getScore() {
return this.score;
}
}