20.04.26
This commit is contained in:
@@ -612,8 +612,8 @@
|
||||
return;
|
||||
}
|
||||
|
||||
const readyPlayers = {{ players|selectattr('is_ready')|list|length }};
|
||||
const totalPlayers = {{ players|length }};
|
||||
const readyPlayers = document.querySelectorAll('.player-ready.ready').length;
|
||||
const totalPlayers = document.querySelectorAll('.player-item').length;
|
||||
|
||||
if (totalPlayers < 2) {
|
||||
showNotification('❌ Нужно минимум 2 игрока для начала игры', 'error');
|
||||
@@ -626,6 +626,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
showNotification('🔄 Запуск игры...', 'info');
|
||||
|
||||
fetch('/room/{{ room.code }}/start', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@@ -633,7 +635,12 @@
|
||||
'X-CSRFToken': '{{ csrf_token() if csrf_token else "" }}'
|
||||
}
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
return response.json().then(err => Promise.reject(err));
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
showNotification('✅ Игра начинается!', 'success');
|
||||
@@ -647,8 +654,8 @@
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
showNotification('❌ Ошибка при запуске игры', 'error');
|
||||
console.error('Error starting game:', error);
|
||||
showNotification('❌ Ошибка при запуске игры: ' + (error.error || error.message || 'Неизвестная ошибка'), 'error');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user