mirror of
https://github.com/randyjc/Rahoot.git
synced 2026-03-13 20:15:35 +01:00
Add Manager Skip button on quiz
This commit is contained in:
@@ -40,6 +40,8 @@ io.on("connection", (socket) => {
|
||||
Player.selectedAnswer(gameState, io, socket, answerKey),
|
||||
)
|
||||
|
||||
socket.on("manager:abortQuiz", () => Manager.abortQuiz(gameState, io, socket))
|
||||
|
||||
socket.on("manager:nextQuestion", () =>
|
||||
Manager.nextQuestion(gameState, io, socket),
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { GAME_STATE_INIT } from "../quizz.config.js"
|
||||
import { startRound } from "../utils/round.js"
|
||||
import generateRoomId from "../utils/generateRoomId.js"
|
||||
import { cooldown, sleep } from "../utils/cooldown.js"
|
||||
import { abortCooldown, cooldown, sleep } from "../utils/cooldown.js"
|
||||
import deepClone from "../utils/deepClone.js"
|
||||
|
||||
const Manager = {
|
||||
@@ -77,6 +77,18 @@ const Manager = {
|
||||
startRound(game, io, socket)
|
||||
},
|
||||
|
||||
abortQuiz: (game, io, socket) => {
|
||||
if (!game.started) {
|
||||
return
|
||||
}
|
||||
|
||||
if (socket.id !== game.manager) {
|
||||
return
|
||||
}
|
||||
|
||||
abortCooldown(game, io, game.room)
|
||||
},
|
||||
|
||||
showLoaderboard: (game, io, socket) => {
|
||||
if (!game.questions[game.currentQuestion + 1]) {
|
||||
socket.emit("game:status", {
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
SFX_RESULTS_SOUND,
|
||||
} from "@/constants"
|
||||
import useSound from "use-sound"
|
||||
import { usePlayerContext } from "@/context/player"
|
||||
|
||||
const calculatePercentages = (objectResponses) => {
|
||||
const keys = Object.keys(objectResponses)
|
||||
@@ -37,6 +38,7 @@ export default function Answers({
|
||||
data: { question, answers, image, time, responses, correct },
|
||||
}) {
|
||||
const { socket } = useSocketContext()
|
||||
const { player } = usePlayerContext()
|
||||
|
||||
const [percentages, setPercentages] = useState([])
|
||||
const [cooldown, setCooldown] = useState(time)
|
||||
@@ -58,6 +60,10 @@ export default function Answers({
|
||||
)
|
||||
|
||||
const handleAnswer = (answer) => {
|
||||
if (!player) {
|
||||
return
|
||||
}
|
||||
|
||||
socket.emit("player:selectedAnswer", answer)
|
||||
sfxPop()
|
||||
}
|
||||
|
||||
@@ -63,6 +63,10 @@ export default function Manager() {
|
||||
socket.emit("manager:startGame")
|
||||
break
|
||||
|
||||
case "SELECT_ANSWER":
|
||||
socket.emit("manager:abortQuiz")
|
||||
break
|
||||
|
||||
case "SHOW_RESPONSES":
|
||||
socket.emit("manager:showLeaderboard")
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user