-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
104 lines (83 loc) · 3.53 KB
/
Copy pathscript.js
File metadata and controls
104 lines (83 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Define the black card and white card options
const blackCard = "Лучший подарок на день рождения это __";
const whiteCardOptions = [
"Холокост",
"Сметана",
"Гитлер",
"24 абрикоса",
"бан на твиче",
"невидимые деньги",
"порватые штаны",
];
// Player scores
let player1Score = 0;
let player2Score = 0;
// Initialize player nickname
let playerNickname = localStorage.getItem("playerNickname");
if (!playerNickname) {
// Display the nickname modal if the nickname is not set
const nicknameModal = document.getElementById("nickname-modal");
nicknameModal.style.display = "block";
// Handle the nickname submission
const nicknameInput = document.getElementById("nickname-input");
const nicknameSubmit = document.getElementById("nickname-submit");
nicknameSubmit.addEventListener("click", () => {
playerNickname = nicknameInput.value;
localStorage.setItem("playerNickname", playerNickname);
nicknameModal.style.display = "none"; // Hide the modal
// Update the nickname in the HTML
const nicknameElement = document.getElementById("player-nickname");
nicknameElement.textContent = playerNickname;
initializeGame(); // Start the game
});
} else {
// Hide the modal if the nickname is already set
const nicknameModal = document.getElementById("nickname-modal");
nicknameModal.style.display = "none";
// Update the nickname in the HTML
const nicknameElement = document.getElementById("player-nickname");
nicknameElement.textContent = playerNickname;
initializeGame();
}
// Track the current judge (player 1 or player 2)
let currentJudge = 1;
// Initialize the game
function initializeGame() {
// Display the player's nickname
const nicknameElement = document.getElementById("player-nickname");
nicknameElement.textContent = playerNickname;
document.getElementById("black-card").innerHTML = `<h1>${blackCard}</h1>`;
document.getElementById("white-cards").innerHTML = "";
// Generate white card options
whiteCardOptions.forEach((option, index) => {
const whiteCard = document.createElement("div");
whiteCard.classList.add("white-card");
whiteCard.textContent = option;
whiteCard.addEventListener("click", () => chooseWhiteCard(index));
document.getElementById("white-cards").appendChild(whiteCard);
});
// Update the scoreboard
document.getElementById("player-1-score").textContent = player1Score;
document.getElementById("player-2-score").textContent = player2Score;
// Set the judge button
const judgeButton = document.getElementById("judge-button");
judgeButton.textContent = `Judge (Player ${currentJudge})`;
judgeButton.addEventListener("click", judgeRound);
}
// Function to choose a white card
function chooseWhiteCard(index) {
// Implement the logic for a player choosing a card
// Update the player's nickname in the chosen card for display
const selectedCard = whiteCardOptions[index];
const formattedCard = `${playerNickname} chose: ${selectedCard}`;
// Implement the logic to send this choice to other players if you have a multiplayer setup
}
// Function to judge the round
function judgeRound() {
// Implement the logic for judging the round and updating scores
// Switch judges (between Player 1 and Player 2)
currentJudge = currentJudge === 1 ? 2 : 1;
initializeGame();
}
// Initialize the game
initializeGame();