- 在国际化文件中添加奖池相关的翻译配置 - 定义 JackpotPoolState 和 GameJackpotPoolDto 类型接口 - 在 DashboardState 中添加 jackpotPool 字段 - 实现 normalizeJackpotPoolState 函数处理奖池数据转换 - 更新游戏 API 中的初始化和数据归一化逻辑 - 添加 Oxanium 字体依赖并配置奖池金额字体样式 - 实现 JackpotPoolTicker 组件显示动态增长的奖池金额 - 在消息广播组件中集成奖池显示功能 - 更新实时同步钩子中的奖池数据处理逻辑
86 lines
1.9 KiB
TypeScript
86 lines
1.9 KiB
TypeScript
import {
|
|
DEFAULT_CHIP_AMOUNTS,
|
|
DEFAULT_GAME_CHIP_COLORS,
|
|
GAME_MAX_SELECTION_CELLS,
|
|
} from '@/constants'
|
|
import type {
|
|
AnnouncementState,
|
|
Chip,
|
|
ConnectionState,
|
|
DashboardState,
|
|
GameBootstrapSnapshot,
|
|
RoundSnapshot,
|
|
} from '@/type'
|
|
|
|
function createEmptyRoundSnapshot(nowIso: string): RoundSnapshot {
|
|
return {
|
|
bettingClosesAt: nowIso,
|
|
id: '',
|
|
phase: 'waiting',
|
|
revealingAt: nowIso,
|
|
settledAt: null,
|
|
startedAt: nowIso,
|
|
winningCellId: null,
|
|
}
|
|
}
|
|
|
|
function createEmptyAnnouncementState(): AnnouncementState {
|
|
return {
|
|
activeAnnouncementId: null,
|
|
items: [],
|
|
lastUpdatedAt: null,
|
|
}
|
|
}
|
|
|
|
function createEmptyConnectionState(): ConnectionState {
|
|
return {
|
|
connectedAt: null,
|
|
lastError: null,
|
|
lastMessageAt: null,
|
|
latencyMs: null,
|
|
reconnectAttempt: 0,
|
|
status: 'idle',
|
|
transport: 'offline',
|
|
}
|
|
}
|
|
|
|
function createEmptyDashboardState(nowIso: string): DashboardState {
|
|
return {
|
|
countdownMs: 0,
|
|
featuredCellId: null,
|
|
jackpotPool: null,
|
|
onlinePlayers: 0,
|
|
tableLimitMax: 0,
|
|
tableLimitMin: 0,
|
|
totalPoolAmount: 0,
|
|
updatedAt: nowIso,
|
|
}
|
|
}
|
|
|
|
function createDefaultChips(): Chip[] {
|
|
return DEFAULT_CHIP_AMOUNTS.map((chip, index) => ({
|
|
amount: chip.amount,
|
|
color: DEFAULT_GAME_CHIP_COLORS[index] ?? DEFAULT_GAME_CHIP_COLORS[0],
|
|
id: chip.id,
|
|
isDefault: chip.id === 'chip-5',
|
|
label: String(chip.amount),
|
|
}))
|
|
}
|
|
|
|
export function createEmptyGameBootstrapSnapshot(
|
|
nowIso = new Date().toISOString(),
|
|
): GameBootstrapSnapshot {
|
|
return {
|
|
announcements: createEmptyAnnouncementState(),
|
|
cells: [],
|
|
chips: createDefaultChips(),
|
|
connection: createEmptyConnectionState(),
|
|
dashboard: createEmptyDashboardState(nowIso),
|
|
history: [],
|
|
maxSelectionCount: GAME_MAX_SELECTION_CELLS,
|
|
round: createEmptyRoundSnapshot(nowIso),
|
|
selections: [],
|
|
trends: [],
|
|
}
|
|
}
|