stuff
This commit is contained in:
parent
6e940aceb0
commit
9acd6a6fa9
5 changed files with 21 additions and 53 deletions
|
|
@ -667,7 +667,7 @@ const GameManagementModal = ({
|
||||||
<button
|
<button
|
||||||
className="mgmt-button start-button"
|
className="mgmt-button start-button"
|
||||||
onClick={onStartGame}
|
onClick={onStartGame}
|
||||||
disabled={participants.length < 2}
|
disabled={questions.length === 0}
|
||||||
>
|
>
|
||||||
▶️ Начать игру
|
▶️ Начать игру
|
||||||
</button>
|
</button>
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,15 @@
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import { useTheme } from '../context/ThemeContext'
|
import { useTheme } from '../context/ThemeContext'
|
||||||
|
|
||||||
const SNOWFLAKE_LIFETIME = 15000 // 15 seconds max lifetime
|
|
||||||
const TARGET_COUNT = 30 // Target number of snowflakes
|
const TARGET_COUNT = 30 // Target number of snowflakes
|
||||||
const UPDATE_INTERVAL = 500 // Check every 500ms
|
const UPDATE_INTERVAL = 500 // Check every 500ms
|
||||||
|
|
||||||
function createSnowflake(id) {
|
function createSnowflake(id, isInitial = false) {
|
||||||
return {
|
return {
|
||||||
id: id || `snowflake-${Date.now()}-${Math.random()}`,
|
id: id || `snowflake-${Date.now()}-${Math.random()}`,
|
||||||
left: Math.random() * 100,
|
left: Math.random() * 100,
|
||||||
duration: Math.random() * 3 + 7, // 7-10s
|
duration: Math.random() * 3 + 7, // 7-10s
|
||||||
delay: Math.random() * 2, // 0-2s delay for initial batch
|
delay: isInitial ? Math.random() * 2 : 0, // Only delay initial batch
|
||||||
size: Math.random() * 10 + 10, // 10-20px
|
size: Math.random() * 10 + 10, // 10-20px
|
||||||
opacity: Math.random() * 0.5 + 0.5, // 0.5-1
|
opacity: Math.random() * 0.5 + 0.5, // 0.5-1
|
||||||
createdAt: Date.now(),
|
createdAt: Date.now(),
|
||||||
|
|
@ -51,7 +50,7 @@ const Snowflakes = ({ roomParticlesEnabled = null }) => {
|
||||||
setSnowflakes([])
|
setSnowflakes([])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const initial = Array.from({ length: TARGET_COUNT }, (_, i) => createSnowflake(i))
|
const initial = Array.from({ length: TARGET_COUNT }, (_, i) => createSnowflake(i, true))
|
||||||
setSnowflakes(initial)
|
setSnowflakes(initial)
|
||||||
}, [particlesEnabled, particleSymbol, currentThemeData])
|
}, [particlesEnabled, particleSymbol, currentThemeData])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,6 @@ const CreateRoom = () => {
|
||||||
const [settings, setSettings] = useState({
|
const [settings, setSettings] = useState({
|
||||||
maxPlayers: 10,
|
maxPlayers: 10,
|
||||||
allowSpectators: true,
|
allowSpectators: true,
|
||||||
timerEnabled: false,
|
|
||||||
timerDuration: 30,
|
|
||||||
password: '',
|
password: '',
|
||||||
});
|
});
|
||||||
const [isNameModalOpen, setIsNameModalOpen] = useState(false);
|
const [isNameModalOpen, setIsNameModalOpen] = useState(false);
|
||||||
|
|
@ -105,34 +103,6 @@ const CreateRoom = () => {
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="form-group checkbox">
|
|
||||||
<label>
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
checked={settings.timerEnabled}
|
|
||||||
onChange={(e) =>
|
|
||||||
setSettings({ ...settings, timerEnabled: e.target.checked })
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
Включить таймер
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{settings.timerEnabled && (
|
|
||||||
<div className="form-group">
|
|
||||||
<label>Время на ответ (сек):</label>
|
|
||||||
<input
|
|
||||||
type="number"
|
|
||||||
min="10"
|
|
||||||
max="120"
|
|
||||||
value={settings.timerDuration}
|
|
||||||
onChange={(e) =>
|
|
||||||
setSettings({ ...settings, timerDuration: parseInt(e.target.value) })
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div className="form-group">
|
<div className="form-group">
|
||||||
<label>Пароль на комнату (необязательно):</label>
|
<label>Пароль на комнату (необязательно):</label>
|
||||||
<input
|
<input
|
||||||
|
|
|
||||||
|
|
@ -363,6 +363,16 @@ const GamePage = () => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleToggleParticles = (particlesEnabled) => {
|
||||||
|
if (!gameState.roomId || !user) return;
|
||||||
|
socketService.toggleParticles(
|
||||||
|
gameState.roomId,
|
||||||
|
gameState.roomCode,
|
||||||
|
user.id,
|
||||||
|
particlesEnabled
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const handleSelectPlayer = (participantId) => {
|
const handleSelectPlayer = (participantId) => {
|
||||||
if (!gameState.roomId || !user) return;
|
if (!gameState.roomId || !user) return;
|
||||||
if (!isHost) return; // Только хост может выбирать игрока
|
if (!isHost) return; // Только хост может выбирать игрока
|
||||||
|
|
|
||||||
|
|
@ -339,28 +339,16 @@ const RoomPage = () => {
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="question-pack-section">
|
|
||||||
<h3>Вопросы:</h3>
|
|
||||||
<div className="pack-info">
|
|
||||||
<p>
|
|
||||||
Вопросов в комнате: <strong>{roomQuestions.length}</strong>
|
|
||||||
</p>
|
|
||||||
{isHost && (
|
|
||||||
<p className="pack-hint">
|
|
||||||
Вы можете настроить вопросы перед началом игры
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{isHost && (
|
{isHost && (
|
||||||
|
<div className="button-group">
|
||||||
<button
|
<button
|
||||||
onClick={() => setIsQuestionsModalOpen(true)}
|
onClick={() => setIsQuestionsModalOpen(true)}
|
||||||
className="secondary"
|
className="primary"
|
||||||
>
|
>
|
||||||
Настроить вопросы
|
🎛 Настроить игру
|
||||||
</button>
|
</button>
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className="button-group">
|
<div className="button-group">
|
||||||
<button
|
<button
|
||||||
|
|
@ -437,6 +425,7 @@ const RoomPage = () => {
|
||||||
onUpdateQuestions={handleUpdateRoomQuestions}
|
onUpdateQuestions={handleUpdateRoomQuestions}
|
||||||
availablePacks={questionPacks}
|
availablePacks={questionPacks}
|
||||||
onChangeParticipantRole={handleChangeParticipantRole}
|
onChangeParticipantRole={handleChangeParticipantRole}
|
||||||
|
onStartGame={handleStartGame}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue