New config file and update README

This commit is contained in:
Ralex
2024-09-22 14:16:10 +02:00
parent b5abfbb724
commit e775763914
10 changed files with 1099 additions and 476 deletions

View File

@@ -1,5 +1,5 @@
import { Server } from "socket.io"
import { GAME_STATE_INIT } from "./quizz.config.js"
import { GAME_STATE_INIT, WEBSOCKET_SERVER_PORT } from "../config.mjs"
import Manager from "./roles/manager.js"
import Player from "./roles/player.js"
import { abortCooldown } from "./utils/cooldown.js"
@@ -11,10 +11,10 @@ const io = new Server({
cors: {
origin: "*",
},
path: "/ws/",
})
io.listen(5157)
console.log(`Server running on port ${WEBSOCKET_SERVER_PORT}`)
io.listen(WEBSOCKET_SERVER_PORT)
io.on("connection", (socket) => {
console.log(`A user connected ${socket.id}`)
@@ -59,6 +59,7 @@ io.on("connection", (socket) => {
gameState = deepClone(GAME_STATE_INIT)
abortCooldown()
return
}

View File

@@ -1,95 +0,0 @@
export const GAME_STATE_INIT = {
started: false,
password: "PASSWORD",
players: [],
playersAnswer: [],
manager: null,
room: null,
currentQuestion: 0,
roundStartTime: 0,
subject: "Adobe",
questions: [
{
question: "Who are the founders of Adobe?",
answers: [
"Steve Jobs and Charles Geschke",
"Jhon Warnock and Charles Geschke",
"Jhon Jonse and Charles Geskie",
"Bill Gate",
],
solution: 1,
cooldown: 5,
time: 15,
},
{
question: "What is Adobe's most famous software?",
answers: ["Encore", "AfterEffect", "Creative Cloud", "Photoshop"],
image:
"https://images.unsplash.com/photo-1626785774573-4b799315345d?q=80&w=500&auto=webp",
solution: 3,
cooldown: 5,
time: 15,
},
{
question: "When was Adobe created?",
answers: ["2000", "1982", "2003", "1987"],
solution: 1,
cooldown: 5,
time: 15,
},
{
question: "Where is headquertes located?",
answers: [
"San Jose, California",
"Bookworm, Cascui",
"DowTown, Texas",
"Tokyo, Japan",
],
solution: 0,
cooldown: 5,
time: 15,
},
{
question: "How many employees at Adobe?",
answers: [
"15,423 employees",
"30,803 employees",
"25,988 employees",
"5,073 employees",
],
image:
"https://images.unsplash.com/photo-1504384308090-c894fdcc538d?q=80&w=500&auto=webp",
solution: 2,
cooldown: 5,
time: 15,
},
{
question: "Who is the Current CEO?",
answers: [
"Jhon Warnock",
"Victor Newway",
"Mark Java",
"Shantanu Narayen",
],
image:
"https://images.unsplash.com/photo-1435348773030-a1d74f568bc2?q=80&w=500&auto=webp",
solution: 3,
cooldown: 5,
time: 15,
},
{
question: "Adobe's core business is focused on?",
answers: [
"Creative Software",
"Video Game",
"Logistics software",
"Other",
],
image:
"https://images.unsplash.com/photo-1582736317407-371893d9e146?q=80&w=500&auto=webp",
solution: 0,
cooldown: 5,
time: 15,
},
],
}

View File

@@ -1,8 +1,8 @@
import { GAME_STATE_INIT } from "../quizz.config.js"
import { startRound } from "../utils/round.js"
import generateRoomId from "../utils/generateRoomId.js"
import { GAME_STATE_INIT } from "../../config.mjs"
import { abortCooldown, cooldown, sleep } from "../utils/cooldown.js"
import deepClone from "../utils/deepClone.js"
import generateRoomId from "../utils/generateRoomId.js"
import { startRound } from "../utils/round.js"
const Manager = {
createRoom: (game, io, socket, password) => {

View File

@@ -3,7 +3,10 @@ let cooldownResolve
export const abortCooldown = () => {
clearInterval(cooldownTimeout)
cooldownResolve()
if (cooldownResolve) {
cooldownResolve()
}
}
export const cooldown = (ms, io, room) => {