Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e9bf4b31c | ||
|
|
600c3a1836 | ||
|
|
ef56c1d9c1 |
No files matched your search
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "jeobeardy",
|
||||
"version": "1.1.0",
|
||||
"version": "1.1.1",
|
||||
"description": "Jeobeardy (/dʒebeərdi/) is similiar to but not quite like Jeopardy. It is a quiz game where you can create your own boards with categories and then make your friends compete in a fun and interactive way",
|
||||
"keywords": [
|
||||
"jeobeardy",
|
||||
@@ -34,6 +34,7 @@
|
||||
"@fortawesome/free-solid-svg-icons": "~7.2.0",
|
||||
"@fortawesome/vue-fontawesome": "~3.1.3",
|
||||
"@popperjs/core": "~2.11.8",
|
||||
"@vitejs/plugin-vue": "~6.0.5",
|
||||
"axios": "~1.15.0",
|
||||
"bcryptjs": "~3.0.3",
|
||||
"body-parser": "~2.2.2",
|
||||
@@ -57,7 +58,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rushstack/eslint-patch": "~1.16.1",
|
||||
"@vitejs/plugin-vue": "~6.0.5",
|
||||
"@vue/eslint-config-prettier": "~10.2.0",
|
||||
"eslint": "~10.2.0",
|
||||
"eslint-plugin-vue": "~10.8.0",
|
||||
|
||||
@@ -54,6 +54,7 @@ exports.addBoard = ( postObject, ownerId ) => {
|
||||
ownerId: ownerId,
|
||||
name: postObject.boardName,
|
||||
categories: postObject.categories,
|
||||
options: postObject.options,
|
||||
});
|
||||
return newBoard.save();
|
||||
} else {
|
||||
|
||||
@@ -6,6 +6,7 @@ const BoardSchema = new Schema({
|
||||
ownerId: { type: Schema.Types.ObjectId, ref: "User", required: true },
|
||||
name: { type: String, required: true, maxLength: 100 },
|
||||
categories: { type: [Object], required: false, default: [] },
|
||||
options: { type: Object, required: true, default: { losePointsOnWrong: false, lossMultiplier: 1, onlyOnBuzzer: true } }
|
||||
});
|
||||
|
||||
// Virtual for player's URL
|
||||
@@ -17,6 +18,7 @@ BoardSchema.virtual("url").get(function () {
|
||||
BoardSchema.virtual("setFromPostObject").set( function( postObject ){
|
||||
this.name = postObject.boardName;
|
||||
this.categories = postObject.categories;
|
||||
this.options = postObject.options;
|
||||
})
|
||||
|
||||
// Export model
|
||||
|
||||
@@ -452,6 +452,22 @@ exports.handleMessage = ( gameSocketList, socket, dataRaw ) => {
|
||||
reject( new Error("No playerId found for connection") );
|
||||
}
|
||||
break;
|
||||
case "startTimer":
|
||||
if( socket.locals.isHost ){
|
||||
sendAllPlayers( socket, gameSocketList, "timerStarted", "A timer has been started", { timerAmount: payload });
|
||||
resolve();
|
||||
} else {
|
||||
reject( new Error("No playerId found for connection") );
|
||||
}
|
||||
break;
|
||||
case "stopTimer":
|
||||
if( socket.locals.isHost ){
|
||||
sendAllPlayers( socket, gameSocketList, "timerStopped", "The timer has been stopped", {});
|
||||
resolve();
|
||||
} else {
|
||||
reject( new Error("No playerId found for connection") );
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -89,6 +89,8 @@ $font-family-base: "Urbanist";
|
||||
|
||||
$enable-caret: false;
|
||||
|
||||
$form-check-input-checked-bg-color: $pink-accent-primary;
|
||||
$form-switch-color: $body-color;
|
||||
|
||||
|
||||
// 2. Include any default variable overrides here
|
||||
@@ -203,3 +205,7 @@ $utilities: map-merge(
|
||||
color: $gray-600;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.fs-sm {
|
||||
font-size: .75em;
|
||||
}
|
||||
@@ -217,7 +217,7 @@ if( route.params.boardId !== undefined ){
|
||||
boardIsLoading.value = false;
|
||||
});
|
||||
} else {
|
||||
gameCreationStore.board = new Board( undefined, "New Board", [] );
|
||||
gameCreationStore.board = new Board();
|
||||
selectedObject.value = gameCreationStore.board;
|
||||
boardIsLoading.value = false;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,6 @@ let audioInstance = ref(null);
|
||||
let showingAnswer = ref( false );
|
||||
let showingQuestion = ref( false );
|
||||
|
||||
|
||||
const isBoardSelected = computed( () => {
|
||||
return selectedObject.value instanceof Board;
|
||||
});
|
||||
@@ -153,8 +152,10 @@ function setUpListeners(){
|
||||
});
|
||||
gameStore.addSocketListener("questionLocked", ( _data ) => {
|
||||
gameStore.acceptAnswers = false;
|
||||
for( let i in gameStore.players ){
|
||||
gameStore.players[i].isAnswering = true;
|
||||
if( isFreeTextAnswerType.value ){
|
||||
for( let i in gameStore.players ){
|
||||
gameStore.players[i].isAnswering = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
gameStore.addSocketListener("playerAnswersRevealed", ( data ) => {
|
||||
@@ -206,10 +207,18 @@ function setUpListeners(){
|
||||
gameStore.addSocketListener("questionLayerSelected", ( data ) => {
|
||||
questionIndex.value = Number( data.payload.questionIndex );
|
||||
});
|
||||
gameStore.addSocketListener("timerStarted", ( data ) => {
|
||||
gameStore.setUpTimer(Number( data.payload.timerAmount ));
|
||||
});
|
||||
gameStore.addSocketListener("timerStopped", ( data ) => {
|
||||
gameStore.clearTimer();
|
||||
});
|
||||
}
|
||||
|
||||
function playerBuzzered( data ){
|
||||
gameStore.acceptAnswers = false;
|
||||
gameStore.clearTimer();
|
||||
|
||||
if( gameStore.playerId === data.payload.playerId ){
|
||||
buzzBuzz.play();
|
||||
}
|
||||
@@ -314,7 +323,8 @@ function questionAnsweredRevert( cIndex, bEIndex ){
|
||||
gameStore.sendEvent("questionAnsweredRevert", payload );
|
||||
}
|
||||
|
||||
function manualPointsAdjustment( playerId, playerName, points ){
|
||||
function manualPointsAdjustment( playerId, playerName, arePointsAdded ){
|
||||
let points = ( arePointsAdded ? gameStore.hostData.manualAdjustmentValue : -1 * gameStore.hostData.manualAdjustmentValue );
|
||||
let payload = {
|
||||
reopenQuestion: gameStore.acceptAnswers,
|
||||
playerId: playerId,
|
||||
@@ -369,6 +379,17 @@ function revealPlayerAnswers( playerIds ){
|
||||
gameStore.sendEvent("revealPlayerAnswers", payload);
|
||||
}
|
||||
|
||||
function startTimer( timerAmount ){
|
||||
if( gameStore.isHost ){
|
||||
gameStore.sendEvent("startTimer", timerAmount );
|
||||
}
|
||||
}
|
||||
function stopTimer(){
|
||||
if( gameStore.isHost ){
|
||||
gameStore.sendEvent("stopTimer", {});
|
||||
}
|
||||
}
|
||||
|
||||
gameStore.getBoardToGame( route.params.gameId )
|
||||
.then( () => {
|
||||
selectedObject.value = gameStore.board;
|
||||
@@ -402,8 +423,11 @@ onBeforeRouteLeave((to, from) => {
|
||||
}
|
||||
});
|
||||
|
||||
const isFreeTextAnswerType = computed(() => {
|
||||
return gameStore.board.categories[categoryIndex.value].boardEntries[boardEntryIndex.value].answer.answerInteraction === 'freeTextInteraction';
|
||||
})
|
||||
|
||||
//TODO List:
|
||||
// -Profile Pic
|
||||
// -More Question Types
|
||||
// -Height of Category Headers (on Multiline)
|
||||
|
||||
@@ -453,6 +477,7 @@ onBeforeRouteLeave((to, from) => {
|
||||
<PlayersView
|
||||
:players="gameStore.players"
|
||||
:questionPoints="(isBoardSelected ? 0 : Number(selectedObject.points) )"
|
||||
:boardOptions="gameStore.board.options"
|
||||
:answerInteraction="(isBoardSelected ? '' : selectedObject.answer.answerInteraction )"
|
||||
:isHost="gameStore.isHost"
|
||||
:acceptAnswers="gameStore.acceptAnswers"
|
||||
@@ -488,6 +513,8 @@ onBeforeRouteLeave((to, from) => {
|
||||
@questionAnswered="questionAnswered"
|
||||
@questionAnsweredRevert="questionAnsweredRevert"
|
||||
@letNextPlayerChoose="letNextPlayerChoose"
|
||||
@startTimer="startTimer"
|
||||
@stopTimer="stopTimer"
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ function deleteCategoryButtonClicked( cIndex ){
|
||||
<input v-model="gameCreationStore.board.boardName" class="form-control bg-dark-blue" type="text">
|
||||
</div>
|
||||
<div>
|
||||
<label class="form-label fs-4 mt-3">Categories</label>
|
||||
<h4 class="mt-3">Categories</h4>
|
||||
<div v-if="gameCreationStore.board.categories.length === 0">No categories yet</div>
|
||||
<template v-else>
|
||||
<div v-for="( category, categoryListIndex ) in gameCreationStore.board.categories" :key="category.categoryName">
|
||||
@@ -77,6 +77,27 @@ function deleteCategoryButtonClicked( cIndex ){
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h4 class="mt-3">Options</h4>
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" role="switch" v-model="gameCreationStore.board.options.losePointsOnWrong" id="lose-points-on-wrong">
|
||||
<label class="form-check-label" for="lose-points-on-wrong">
|
||||
Lose Points on Wrong Answer
|
||||
</label>
|
||||
</div>
|
||||
<template v-if="gameCreationStore.board.options.losePointsOnWrong">
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" role="switch" v-model="gameCreationStore.board.options.onlyOnBuzzer" id="only-on-buzzer-type">
|
||||
<label class="form-check-label" for="only-on-buzzer-type">
|
||||
Only on Buzzer Answer Type
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label class="form-label" for="loss-multiplier">Loss Multiplier</label>
|
||||
<input v-model="gameCreationStore.board.options.lossMultiplier" class="form-control bg-dark-blue" type="number" step="0.5" min="0" id="loss-multiplier">
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
import QuestionView from "@/components/views/QuestionView.vue"
|
||||
import AnswerView from "@/components/views/AnswerView.vue"
|
||||
import { useGameStore } from '@/stores/GameStore';
|
||||
|
||||
const props = defineProps({
|
||||
board: Object,
|
||||
@@ -34,12 +35,18 @@ const props = defineProps({
|
||||
|
||||
const emit = defineEmits(["specificQuestionLayerSelected", "backToBoard", "playerBuzzered", "playAudio", "stopAudio", "showQuestion", "showAnswer", "hideQuestion", "hideAnswer" ]);
|
||||
|
||||
const gameStore = useGameStore();
|
||||
|
||||
let boardEntry = computed( () => {
|
||||
return props.board.categories[props.cIndex].boardEntries[props.bEIndex];
|
||||
})
|
||||
|
||||
const showingQuestion = computed( () => {
|
||||
return props.isAnswerRevealed || ( props.isQuestionRevealed && !props.anyPlayerIsAnswering );
|
||||
return props.isAnswerRevealed || ( props.isQuestionRevealed && (isFreeTextAnswerType.value || !props.anyPlayerIsAnswering) );
|
||||
});
|
||||
|
||||
const isFreeTextAnswerType = computed(() => {
|
||||
return gameStore.board.categories[props.cIndex].boardEntries[props.bEIndex].answer.answerInteraction === 'freeTextInteraction';
|
||||
});
|
||||
|
||||
function showQuestion(){
|
||||
@@ -73,6 +80,34 @@ function stopAudio(){
|
||||
emit( "stopAudio" );
|
||||
}
|
||||
|
||||
const progressRef = ref(null);
|
||||
let timerAnimation = null;
|
||||
|
||||
watch(
|
||||
() => gameStore.timer.amount,
|
||||
(newVal) => {
|
||||
if( newVal !== null ){
|
||||
if( timerAnimation !== null ){
|
||||
timerAnimation.cancel();
|
||||
timerAnimation = null;
|
||||
}
|
||||
animateTimer(newVal);
|
||||
} else if(timerAnimation !== null ){
|
||||
timerAnimation.cancel();
|
||||
timerAnimation = null;
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
function animateTimer(timerAmountInS){
|
||||
timerAnimation = progressRef.value.animate([
|
||||
{ width: '100%' },
|
||||
], {
|
||||
duration: 1000 * timerAmountInS,
|
||||
iterations: 1,
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -140,8 +175,10 @@ function stopAudio(){
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<div :class="[{'d-none': gameStore.timer.timeoutId === null}]" class="position-absolute bottom-0 start-0 w-100">
|
||||
<div class="progress bg-primary" role="progressbar" aria-label="Basic example" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">
|
||||
<div ref="progressRef" class="progress-bar bg-pink-accent-primary" style="width: 0"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
@@ -1,6 +1,8 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
|
||||
import { useGameStore } from '@/stores/GameStore';
|
||||
|
||||
const props = defineProps({
|
||||
objToDisplay: String,
|
||||
board: Object,
|
||||
@@ -12,7 +14,9 @@ const props = defineProps({
|
||||
}
|
||||
});
|
||||
|
||||
const emit = defineEmits( "lockQuestion", "revealPlayerAnswers", "letNextPlayerChoose" );
|
||||
const emit = defineEmits( "lockQuestion", "revealPlayerAnswers", "letNextPlayerChoose", "stopTimer", "startTimer" );
|
||||
|
||||
const gameStore = useGameStore();
|
||||
|
||||
let boardEntry = computed( () => {
|
||||
if( props.objToDisplay === "BoardEntry" ){
|
||||
@@ -33,14 +37,41 @@ function letNextPlayerChoose(){
|
||||
emit("letNextPlayerChoose");
|
||||
}
|
||||
|
||||
|
||||
function startTimer(){
|
||||
emit("startTimer", gameStore.hostData.timerAmount);
|
||||
}
|
||||
function stopTimer(){
|
||||
emit("stopTimer");
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-if="boardEntry !== undefined"
|
||||
class="d-flex flex-column justify-content-center border-top border-pink-accent-primary interaction-size"
|
||||
class="d-flex flex-column justify-content-center border-top border-pink-accent-primary py-2 interaction-size"
|
||||
>
|
||||
<div class="row mx-1 mb-0">
|
||||
<div class="col">
|
||||
<label for="manual-adjustment-value">Point Adjustment Value</label>
|
||||
<input v-model="gameStore.hostData.manualAdjustmentValue" id="manual-adjustment-value" type="text" name="manual-adjustment-value" class="form-control form-control-sm border-pink-accent-primary">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mx-1 mb-3">
|
||||
<div class="col">
|
||||
<label for="timer-value">Timer Length <span class="fs-sm">(in seconds)</span></label>
|
||||
<div class="d-flex gap-1">
|
||||
<input v-model="gameStore.hostData.timerAmount" id="timer-value" type="number" min="1" class="form-control form-control-sm border-pink-accent-primary" :disabled="gameStore.timer.timeoutId !== null">
|
||||
<button v-if="gameStore.timer.timeoutId === null" class="btn btn-sm btn-pink-accent-primary text-nowrap" @click="startTimer">
|
||||
Start Timer
|
||||
<font-awesome-icon icon="fa-solid fa-play"/>
|
||||
</button>
|
||||
<button v-else class="btn btn-sm btn-pink-accent-primary text-nowrap" @click="stopTimer">
|
||||
Stop Timer
|
||||
<font-awesome-icon icon="fa-solid fa-stop"/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mx-2">
|
||||
<div class="col-12 text-center text-truncate">
|
||||
Answer: {{ boardEntry.answer.answerText }}
|
||||
@@ -69,7 +100,7 @@ function letNextPlayerChoose(){
|
||||
|
||||
<style scoped>
|
||||
.interaction-size{
|
||||
height: 6rem;
|
||||
min-height: 6rem;
|
||||
}
|
||||
.no-resize{
|
||||
resize: none;
|
||||
|
||||
@@ -43,9 +43,7 @@ function answerTextUpdated(){
|
||||
class="buzzer d-flex justify-content-center align-items-center rounded-circle shadow m-2"
|
||||
:class="[ { 'buzzer-answering': props.playerIsAnswering }, { 'bg-gray': !props.acceptAnswers && !props.playerIsAnswering } ]"
|
||||
@click="buzzeredTheBuzzBuzz"
|
||||
>
|
||||
Buzzer
|
||||
</div>
|
||||
>Buzzer</div>
|
||||
<div v-else class="d-flex justify-content-center align-items-center w-100 h-100 m-3">
|
||||
<div class="w-100">
|
||||
<label for="textarea-player-input" class="form-label">Answer:</label>
|
||||
|
||||
@@ -10,6 +10,7 @@ const props = defineProps({
|
||||
default: false,
|
||||
},
|
||||
questionPoints: Number,
|
||||
boardOptions: Object,
|
||||
answerInteraction: {
|
||||
type: String,
|
||||
default: "buzzerInteraction"
|
||||
@@ -28,15 +29,24 @@ const emit = defineEmits( "manualPointsAdjustment", "answerRuled", "revealPlayer
|
||||
|
||||
let buttonDivHeight = ref("3rem");
|
||||
let navbarHeight = ref("4rem");
|
||||
let manualAdjustmentValue = ref( 100 );
|
||||
|
||||
function manualPointsAdjustment( playerId, playerName, arePointsAdded ) {
|
||||
let points = ( arePointsAdded ? manualAdjustmentValue.value : -1 * manualAdjustmentValue.value );
|
||||
emit("manualPointsAdjustment", playerId, playerName, points );
|
||||
emit("manualPointsAdjustment", playerId, playerName, arePointsAdded );
|
||||
}
|
||||
|
||||
function answerRuled( playerId, playerName, isAnswerCorrect ){
|
||||
let points = ( isAnswerCorrect ? props.questionPoints : 0 );
|
||||
let points = 0;
|
||||
if( isAnswerCorrect ){
|
||||
points = props.questionPoints;
|
||||
} else if(
|
||||
props.boardOptions.losePointsOnWrong &&
|
||||
(
|
||||
!props.boardOptions.onlyOnBuzzer ||
|
||||
props.answerInteraction === "buzzerInteraction"
|
||||
)
|
||||
) {
|
||||
points = Math.round(props.questionPoints * props.boardOptions.lossMultiplier * -1);
|
||||
}
|
||||
let reopenQuestion;
|
||||
if( ["buzzerInteraction"].includes( props.answerInteraction ) ){
|
||||
reopenQuestion = !isAnswerCorrect;
|
||||
@@ -61,12 +71,6 @@ function letPlayerChoose( playerId ){
|
||||
<div class="d-flex flex-column px-3" :style="[{'height': 'calc( 100vh - ' + (navbarHeight - buttonDivHeight) + 'px)' }]">
|
||||
<div class="my-3">
|
||||
<h3 class="border-bottom border-3 border-pink-accent-primary fw-bold">Players</h3>
|
||||
<div v-if="props.isHost" class="row mb-3">
|
||||
<div class="col">
|
||||
<label for="manual-adjustment-value">Manual Adjustment Value</label>
|
||||
<input v-model="manualAdjustmentValue" id="manual-adjustment-value" type="text" name="manual-adjustment-value" class="form-control form-control-sm border-pink-accent-primary">
|
||||
</div>
|
||||
</div>
|
||||
<template v-for="(player) in props.players" :key="player._id">
|
||||
<PlayerListEntry
|
||||
:player="player"
|
||||
|
||||
+2
-1
@@ -5,7 +5,7 @@ import { FontAwesomeIcon, FontAwesomeLayers } from "@fortawesome/vue-fontawesome
|
||||
import { library } from "@fortawesome/fontawesome-svg-core";
|
||||
import { faDragon, faRightToBracket, faUsers, faUserPlus, faSpinner, faPlusSquare, faBorderAll, faPen, faTrash, faAngleDown, faAngleUp,
|
||||
faPlus, faMinus, faAngleRight, faSquare, faPlay, faCircleExclamation, faSquareCheck, faSquareMinus, faHandPointer, faFloppyDisk,
|
||||
faEye, faRotateLeft } from "@fortawesome/free-solid-svg-icons";
|
||||
faEye, faRotateLeft, faStop } from "@fortawesome/free-solid-svg-icons";
|
||||
import { faCircleUser, faSquarePlus } from "@fortawesome/free-regular-svg-icons";
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ library.add({
|
||||
faFloppyDisk,
|
||||
faEye,
|
||||
faRotateLeft,
|
||||
faStop,
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
export default class Board{
|
||||
|
||||
constructor( id, name, categories ){
|
||||
constructor( id = undefined, name = "New Board", categories = [], options = { losePointsOnWrong: false, lossMultiplier: 1, onlyOnBuzzer: true } ){
|
||||
this.boardId = id;
|
||||
this.boardName = name;
|
||||
this.categories = categories;
|
||||
this.options = options;
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ export function boardResponseToBoardModel( boardResponse ){
|
||||
);
|
||||
}
|
||||
|
||||
return new Board( boardResponse._id, boardResponse.name, categories );
|
||||
return new Board( boardResponse._id, boardResponse.name, categories, boardResponse.options );
|
||||
}
|
||||
|
||||
export function openModal( modalId ){
|
||||
|
||||
@@ -14,7 +14,7 @@ const uService = new UserService();
|
||||
export const useGameCreationStore = defineStore('gameCreation', {
|
||||
state: ()=>{
|
||||
return {
|
||||
board: new Board( undefined, "New Board", []),
|
||||
board: new Board(),
|
||||
images: [],
|
||||
audios: [],
|
||||
answerImages: [],
|
||||
|
||||
@@ -4,6 +4,7 @@ import { useUserStore } from "@/stores/UserStore";
|
||||
import { GAME_STATES } from "@/services/GameService";
|
||||
import Board from "@/models/Board";
|
||||
import { boardResponseToBoardModel } from "@/services/util";
|
||||
import { nextTick } from 'vue';
|
||||
|
||||
const gService = new GameService();
|
||||
|
||||
@@ -21,11 +22,16 @@ export const useGameStore = defineStore('game', {
|
||||
gameService: gService,
|
||||
//concrete Game Data
|
||||
currentQuestion: {},
|
||||
board: new Board( undefined, "New Board", []),
|
||||
board: new Board(),
|
||||
acceptAnswers: false,
|
||||
isPlayerChoosing: false,
|
||||
chosenEntry: undefined,
|
||||
keepAliveInterval: undefined,
|
||||
timer: {
|
||||
timeoutId: null, //null | timeoutId
|
||||
amount: null,
|
||||
},
|
||||
hostData: {},
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
@@ -63,6 +69,12 @@ export const useGameStore = defineStore('game', {
|
||||
isHost: res.data.isHost,
|
||||
gameState: res.data.gameState,
|
||||
}
|
||||
if(isHost){
|
||||
this.hostData = {
|
||||
manualAdjustmentValue: 100,
|
||||
timerAmount: 15,
|
||||
}
|
||||
}
|
||||
this.gameCode = res.data.gameCode;
|
||||
resolve( data );
|
||||
} else {
|
||||
@@ -83,6 +95,10 @@ export const useGameStore = defineStore('game', {
|
||||
this.gameState = GAME_STATES.INIT;
|
||||
this.gameCode = res.data.code;
|
||||
this.isHost = true;
|
||||
this.hostData = {
|
||||
manualAdjustmentValue: 100,
|
||||
timerAmount: 15,
|
||||
}
|
||||
resolve();
|
||||
} else {
|
||||
reject( res.data.error );
|
||||
@@ -182,6 +198,10 @@ export const useGameStore = defineStore('game', {
|
||||
this.removeSocketListener("noUser");
|
||||
this.players = data.payload.players;
|
||||
this.isHost = true;
|
||||
this.hostData = {
|
||||
manualAdjustmentValue: 100,
|
||||
timerAmount: 15,
|
||||
}
|
||||
resolve( data.payload.gameId );
|
||||
});
|
||||
|
||||
@@ -321,6 +341,27 @@ export const useGameStore = defineStore('game', {
|
||||
this.addSocketListener("payloadIncomplete", ( _data ) => {
|
||||
console.error("Invalid or Incomplete Payload!");
|
||||
});
|
||||
},
|
||||
setUpTimer(timerAmountInS){
|
||||
this.timer.timeoutId = setTimeout(() => {
|
||||
this.acceptAnswers = false;
|
||||
clearTimeout(this.timer);
|
||||
this.timer.timeoutId = null;
|
||||
nextTick(() => {
|
||||
this.timer.amount = null;
|
||||
});
|
||||
if(this.isHost){
|
||||
this.sendEvent("lockQuestion", {});
|
||||
}
|
||||
}, timerAmountInS * 1000);
|
||||
this.timer.amount = timerAmountInS;
|
||||
},
|
||||
clearTimer(){
|
||||
if(this.timer.timeoutId){
|
||||
clearTimeout(this.timer.timeoutId);
|
||||
this.timer.timeoutId = null;
|
||||
this.timer.amount = null;
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
Reference in new issue
Block a user