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 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 [page, setPage] = useState(0)
const timerRef = useRef<Timer | null>(null) const timerRef = useRef<Timer | null>(null)
useEffect(() => { useEffect(() => {
if (pagesCount <= 1) {
return
}
timerRef.current = setInterval(() => { timerRef.current = setInterval(() => {
setPage(page => (page + 1) % 3) setPage(page => (page + 1) % pagesCount)
}, 5000) }, pageInterval)
return () => { return () => {
if (timerRef.current) { if (timerRef.current) {
@ -69,13 +79,14 @@ export const LiveLeaderboard = ({ roomId }: Props) => {
return ( return (
<> <>
<h3> <h3>
<Clock /> &mdash; {room.id} (pag. {page + 1}/3) <Clock /> &mdash; {room.id}
{pagesCount > 1 ? ` (pagina ${page + 1}/${pagesCount})` : ''}
</h3> </h3>
<Leaderboard <Leaderboard
questions={room.questions} questions={room.questions}
scoreboard={{ scoreboard={{
teamJollyGroup: scoreboard.teamJollyGroup, 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"> <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 { export function updateRoom(id: string, data: RoomData): void {
emitRoomUpdate(id, data)
db.prepare<[string, string]>( db.prepare<[string, string]>(
` `
UPDATE rooms UPDATE rooms
@ -66,6 +64,8 @@ export function updateRoom(id: string, data: RoomData): void {
WHERE id = ?; WHERE id = ?;
` `
).run(JSON.stringify(data), id) ).run(JSON.stringify(data), id)
emitRoomUpdate(id, data)
} }
export function deleteRoom(id: string): void { export function deleteRoom(id: string): void {

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

Loading…
Cancel
Save