fix: tunable page scrolling, scoring rules
continuous-integration/drone/push Build is passing Details

main
parent 09cbbdd438
commit 3e5c54bf8f

@ -51,13 +51,23 @@ export const LiveLeaderboard = ({ roomId }: Props) => {
room.actions
)
const url = new URL(window.location.href)
const pagesCount = parseInt(url.searchParams.get('pages') ?? '1')
const pageInterval = parseInt(url.searchParams.get('interval') ?? '5000')
const pageSize = Math.ceil(scoreboard.board.length / pagesCount)
const [page, setPage] = useState(0)
const timerRef = useRef<Timer | null>(null)
useEffect(() => {
if (pagesCount <= 1) {
return
}
timerRef.current = setInterval(() => {
setPage(page => (page + 1) % 3)
}, 5000)
setPage(page => (page + 1) % pagesCount)
}, pageInterval)
return () => {
if (timerRef.current) {
@ -69,13 +79,14 @@ export const LiveLeaderboard = ({ roomId }: Props) => {
return (
<>
<h3>
<Clock /> &mdash; {room.id} (pag. {page + 1}/3)
<Clock /> &mdash; {room.id}
{pagesCount > 1 ? ` (pagina ${page + 1}/${pagesCount})` : ''}
</h3>
<Leaderboard
questions={room.questions}
scoreboard={{
teamJollyGroup: scoreboard.teamJollyGroup,
board: scoreboard.board.slice(page * 20, (page + 1) * 20),
board: scoreboard.board.slice(page * pageSize, (page + 1) * pageSize),
}}
/>
<div class="position-fixed bottom right stack-v center">

@ -57,8 +57,6 @@ export function createRoom(id: string, teams: string[], questions: Question[]):
}
export function updateRoom(id: string, data: RoomData): void {
emitRoomUpdate(id, data)
db.prepare<[string, string]>(
`
UPDATE rooms
@ -66,6 +64,8 @@ export function updateRoom(id: string, data: RoomData): void {
WHERE id = ?;
`
).run(JSON.stringify(data), id)
emitRoomUpdate(id, data)
}
export function deleteRoom(id: string): void {

@ -163,11 +163,11 @@ export function computeScoreboardState(game: Game, rawActions: Action[]): Scoreb
.map(question => getCorrectnessMultiplier(question.outcome))
.reduce((a, b) => a + b, 0)
if (2 <= N && N < 4) {
if (2 <= N && N < 3.5) {
teamBonus = 5
} else if (4 <= N && N < 6) {
} else if (3.5 <= N && N < 5.5) {
teamBonus = 10
} else if (6 <= N) {
} else if (5.5 <= N) {
teamBonus = 30
}

Loading…
Cancel
Save