add current player name and score block
This commit is contained in:
+18
-5
@@ -455,6 +455,12 @@ class CardGame {
|
||||
this.updatePlayersInRoom(data.room.players);
|
||||
break;
|
||||
case 'game_started':
|
||||
// Проверяем это переподключение или новая игра
|
||||
// Если мы на экране комнаты или лобби - это новая игра
|
||||
// Если мы на экране игры - это переподключение
|
||||
const isReconnect = this.gameScreen.classList.contains('active') ||
|
||||
(this.hand && this.hand.length > 0 && !this.roomScreen.classList.contains('active'));
|
||||
|
||||
this.hand = data.hand;
|
||||
this.currentPlayerId = data.current_player;
|
||||
this.dealerId = data.dealer;
|
||||
@@ -464,9 +470,6 @@ class CardGame {
|
||||
this.eightDrawnCards = data.eight_drawn_cards || [];
|
||||
this.cardDrawnThisTurn = data.card_drawn_this_turn || false;
|
||||
|
||||
// Проверяем это переподключение или новая игра
|
||||
const isReconnect = this.gameScreen.classList.contains('active');
|
||||
|
||||
if (!isReconnect) {
|
||||
// Новая игра - очищаем лог и добавляем сообщение
|
||||
this.clearLog();
|
||||
@@ -496,7 +499,7 @@ class CardGame {
|
||||
}
|
||||
} else {
|
||||
// Переподключение - просто добавляем сообщение в лог
|
||||
this.addLogEntry('Переподключение к игре...');
|
||||
this.addLogEntry('Вы переподключились');
|
||||
}
|
||||
|
||||
this.hideCountdown();
|
||||
@@ -844,6 +847,13 @@ class CardGame {
|
||||
this.chosenSuitIndicator.style.display = 'none';
|
||||
}
|
||||
|
||||
// Update player info
|
||||
const currentPlayer = data.players.find(p => p.id === this.playerId);
|
||||
if (currentPlayer) {
|
||||
document.getElementById('player-name').textContent = currentPlayer.nickname;
|
||||
document.getElementById('player-score').textContent = `Очки: ${currentPlayer.score}`;
|
||||
}
|
||||
|
||||
// Update opponents around the table
|
||||
this.updateOpponents(data.players, this.currentPlayerId);
|
||||
|
||||
@@ -970,12 +980,15 @@ class CardGame {
|
||||
}
|
||||
});
|
||||
|
||||
// Подсвечиваем наши карты, если наш ход
|
||||
// Подсвечиваем наши карты и инфо, если наш ход
|
||||
const playerHand = document.querySelector('.player-hand');
|
||||
const playerInfo = document.querySelector('.player-info');
|
||||
if (currentPlayerId === this.playerId) {
|
||||
playerHand.classList.add('current-turn');
|
||||
playerInfo.classList.add('current-turn');
|
||||
} else {
|
||||
playerHand.classList.remove('current-turn');
|
||||
playerInfo.classList.remove('current-turn');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-3
@@ -178,9 +178,18 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Карты игрока внизу -->
|
||||
<div class="player-hand">
|
||||
<div id="hand-cards"></div>
|
||||
<!-- Контейнер игрока -->
|
||||
<div class="player-container">
|
||||
<!-- Информация об игроке -->
|
||||
<div class="player-info">
|
||||
<span class="player-name" id="player-name"></span>
|
||||
<span class="player-score" id="player-score"></span>
|
||||
</div>
|
||||
|
||||
<!-- Карты игрока внизу -->
|
||||
<div class="player-hand">
|
||||
<div id="hand-cards"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+68
-3
@@ -1108,13 +1108,37 @@ border: 2px solid #ffd700;
|
||||
font-size: 40px;
|
||||
}
|
||||
|
||||
.player-hand {
|
||||
/* Контейнер игрока */
|
||||
.player-container {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
background: rgba(255, 255, 255, 0.95);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
z-index: 1102;
|
||||
}
|
||||
|
||||
/* Информация об игроке */
|
||||
.player-info {
|
||||
background: rgb(255, 255, 255);
|
||||
padding: 8px 12px;
|
||||
border-radius: 8px 8px 0 0;
|
||||
box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.2);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
z-index: 1102;
|
||||
border: none;
|
||||
border-bottom: none;
|
||||
margin-left: 20px;
|
||||
align-self: flex-start;
|
||||
}
|
||||
|
||||
.player-hand {
|
||||
width: 100%;
|
||||
background: rgb(255, 255, 255);
|
||||
border-radius: 11px 11px 0 0;
|
||||
box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.3);
|
||||
z-index: 1100;
|
||||
max-height: 30vh;
|
||||
padding: 20px 10px 10px 10px;
|
||||
overflow-y: auto;
|
||||
@@ -1124,6 +1148,33 @@ border: 2px solid #ffd700;
|
||||
overscroll-behavior-y: none;
|
||||
}
|
||||
|
||||
.player-name {
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.player-score {
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
/* Подсветка при ходе игрока */
|
||||
.player-info.current-turn {
|
||||
background: linear-gradient(135deg, #ffd900e1 0%, #d3c333 100%);
|
||||
border: none;
|
||||
border-bottom: none;
|
||||
box-shadow: 0 -2px 12px rgba(255, 215, 0, 0.4);
|
||||
}
|
||||
|
||||
.player-info.current-turn .player-name {
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.player-info.current-turn .player-score {
|
||||
color: #555;
|
||||
}
|
||||
|
||||
#hand-cards {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
@@ -1526,6 +1577,20 @@ border: 2px solid #ffd700;
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
/* Блок информации игрока на мобильных */
|
||||
.player-info {
|
||||
padding: 5px 12px;
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
.player-name {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.player-score {
|
||||
font-size: 9px;
|
||||
}
|
||||
|
||||
.player-hand {
|
||||
padding: 15px 5px 5px 5px;
|
||||
max-width: 100%;
|
||||
|
||||
Reference in New Issue
Block a user