revert 18b991048f
revert revert ff1820d582
revert "Project Rock,Scissors,Paper" version 1
Signed-off-by: Alice <Svfoxel@yandex.ru>
This commit is contained in:
Vendored
+2
-9
@@ -4,18 +4,11 @@
|
|||||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
|
||||||
"name": "Launch Chrome",
|
|
||||||
"request": "launch",
|
|
||||||
"type": "chrome",
|
|
||||||
"url": "http://localhost:8080",
|
|
||||||
"webRoot": "${workspaceFolder}"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "chrome",
|
"type": "chrome",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "Open javaScriptTester.html",
|
"name": "Open starter.html",
|
||||||
"file": "c:\\Users\\Dream\\JavaScript\\6\\javaScriptTester.html"
|
"file": "c:\\Users\\Dream\\JavaScript\\Project_Rock,Scissors,Paper\\starter.html"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
let hum = prompt('Выберите "камень", "ножницы" или "бумага"');
|
||||||
|
let npc = Math.floor(Math.random() * 3)+1;
|
||||||
|
|
||||||
|
let stats = JSON.parse(localStorage.getItem("stats"));
|
||||||
|
|
||||||
|
if (!stats) {
|
||||||
|
stats = {
|
||||||
|
wins: 0,
|
||||||
|
looses: 0,
|
||||||
|
draws: 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function save() {
|
||||||
|
localStorage.setItem("stats", JSON.stringify(stats));
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(npc);
|
||||||
|
console.log(hum);
|
||||||
|
|
||||||
|
const Stone = { num: 3, Name: 'камень'};
|
||||||
|
const Scissors = { num: 2, Name: 'ножницы'};
|
||||||
|
const Paper = { num: 1, Name: 'бумага'};
|
||||||
|
|
||||||
|
|
||||||
|
if (hum === Stone.Name){
|
||||||
|
hum = Stone.num;
|
||||||
|
} else if (hum === Scissors.Name) {
|
||||||
|
hum = Scissors.num;
|
||||||
|
} else if (hum === Paper.Name) {
|
||||||
|
hum = Paper.num;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
if (npc === 1 && hum === 3) {
|
||||||
|
npc = 4
|
||||||
|
}
|
||||||
|
if (npc === 3 && hum === 1) {
|
||||||
|
hum = 4
|
||||||
|
}
|
||||||
|
|
||||||
|
if (npc > hum) {
|
||||||
|
console.log("Вы проиграли");
|
||||||
|
alert("Вы проиграли");
|
||||||
|
stats.looses++;
|
||||||
|
save()
|
||||||
|
} else if (npc === hum) {
|
||||||
|
console.log("Ничья");
|
||||||
|
alert("Ничья");
|
||||||
|
stats.draws++;
|
||||||
|
save()
|
||||||
|
} else if (npc < hum) {
|
||||||
|
console.log("Вы выиграли");
|
||||||
|
alert("Вы выиграли");
|
||||||
|
stats.wins++;
|
||||||
|
save()
|
||||||
|
} else {
|
||||||
|
console.log("Пользователь написал какую-то фигню");
|
||||||
|
}
|
||||||
|
console.log("Ваши победы - " + stats.wins + ",Ваши проигрыши - " + stats.looses + ",Ваши ничьи - " + stats.draws);
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<head> <title>Игрульки</title></head>
|
||||||
|
<body>
|
||||||
|
<script type="text/javascript" src="main.js"></script>
|
||||||
|
<h1>Вас приветствует игра "Камень, Ножницы, Бумага"</h1>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user