mirror of
https://github.com/AlecM33/Werewolf.git
synced 2025-12-26 07:47:50 +01:00
various enhancements
This commit is contained in:
@@ -6,7 +6,6 @@ export const globals = {
|
||||
TOAST_DURATION_DEFAULT: 6,
|
||||
ACCESS_CODE_LENGTH: 4,
|
||||
PLAYER_ID_COOKIE_KEY: 'play-werewolf-anon-id',
|
||||
ACCESS_CODE_CHAR_POOL: 'abcdefghijklmnopqrstuvwxyz0123456789',
|
||||
COMMANDS: {
|
||||
FETCH_GAME_STATE: 'fetchGameState',
|
||||
START_GAME: 'startGame',
|
||||
|
||||
@@ -174,7 +174,7 @@ export class GameCreationStepManager {
|
||||
showButtons(true, true, this.steps[step].forwardHandler, this.steps[step].backHandler);
|
||||
break;
|
||||
case 5:
|
||||
renderReviewAndCreateStep(containerId, step, this.currentGame);
|
||||
renderReviewAndCreateStep(containerId, step, this.currentGame, this.deckManager);
|
||||
showButtons(true, true, this.steps[step].forwardHandler, this.steps[step].backHandler, this.currentGame);
|
||||
break;
|
||||
default:
|
||||
@@ -349,7 +349,7 @@ function renderTimerStep (containerId, stepNumber, game, steps) {
|
||||
document.getElementById(containerId).appendChild(div);
|
||||
}
|
||||
|
||||
function renderReviewAndCreateStep (containerId, stepNumber, game) {
|
||||
function renderReviewAndCreateStep (containerId, stepNumber, game, deckManager) {
|
||||
const div = document.createElement('div');
|
||||
div.setAttribute('id', 'step-' + stepNumber);
|
||||
div.classList.add('step');
|
||||
@@ -368,7 +368,7 @@ function renderReviewAndCreateStep (containerId, stepNumber, game) {
|
||||
"<div id='timer-option' class='review-option'></div>" +
|
||||
'</div>' +
|
||||
'<div>' +
|
||||
"<label for='roles-option'>Game Deck</label>" +
|
||||
"<label id='roles-option-label' for='roles-option'>Game Deck</label>" +
|
||||
"<div id='roles-option' class='review-option'></div>" +
|
||||
'</div>';
|
||||
|
||||
@@ -393,9 +393,15 @@ function renderReviewAndCreateStep (containerId, stepNumber, game) {
|
||||
for (const card of game.deck) {
|
||||
const roleEl = document.createElement('div');
|
||||
roleEl.innerText = card.quantity + 'x ' + card.role;
|
||||
if (card.team === globals.ALIGNMENT.GOOD) {
|
||||
roleEl.classList.add(globals.ALIGNMENT.GOOD);
|
||||
} else {
|
||||
roleEl.classList.add(globals.ALIGNMENT.EVIL);
|
||||
}
|
||||
div.querySelector('#roles-option').appendChild(roleEl);
|
||||
}
|
||||
|
||||
div.querySelector('#roles-option-label').innerText += ' (' + deckManager.getDeckSize() + ' Players)';
|
||||
div.querySelector('#mod-name').innerText = game.moderatorName;
|
||||
|
||||
document.getElementById(containerId).appendChild(div);
|
||||
|
||||
@@ -6,27 +6,6 @@ import { globals } from '../config/globals.js';
|
||||
*/
|
||||
export const UserUtility = {
|
||||
|
||||
createNewAnonymousUserId (force = true, environment) {
|
||||
let newId, currentId;
|
||||
|
||||
if (environment === globals.ENVIRONMENT.LOCAL) {
|
||||
currentId = sessionStorage.getItem(globals.PLAYER_ID_COOKIE_KEY);
|
||||
} else {
|
||||
currentId = localStorage.getItem(globals.PLAYER_ID_COOKIE_KEY);
|
||||
}
|
||||
if (currentId !== null && !force) {
|
||||
newId = currentId;
|
||||
} else {
|
||||
newId = createRandomUserId();
|
||||
if (environment === globals.ENVIRONMENT.LOCAL) {
|
||||
sessionStorage.setItem(globals.PLAYER_ID_COOKIE_KEY, newId);
|
||||
} else {
|
||||
localStorage.setItem(globals.PLAYER_ID_COOKIE_KEY, newId);
|
||||
}
|
||||
}
|
||||
return newId;
|
||||
},
|
||||
|
||||
setAnonymousUserId (id, environment) {
|
||||
if (environment === globals.ENVIRONMENT.LOCAL) {
|
||||
sessionStorage.setItem(globals.PLAYER_ID_COOKIE_KEY, id);
|
||||
@@ -53,11 +32,3 @@ export const UserUtility = {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
function createRandomUserId () {
|
||||
let id = '';
|
||||
for (let i = 0; i < globals.USER_SIGNATURE_LENGTH; i ++) {
|
||||
id += globals.ACCESS_CODE_CHAR_POOL[Math.floor(Math.random() * globals.ACCESS_CODE_CHAR_POOL.length)];
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
"test:e2e": "karma start --single-run --browsers ChromeHeadless karma.conf.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
"node": "14.15.3"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const globals = {
|
||||
ACCESS_CODE_CHAR_POOL: 'BCDFGHJKLMNPQRSTVWXYZ0123456789',
|
||||
ACCESS_CODE_CHAR_POOL: 'BCDFGHJKLMNPQRSTVWXYZ23456789',
|
||||
ACCESS_CODE_LENGTH: 4,
|
||||
ACCESS_CODE_GENERATION_ATTEMPTS: 50,
|
||||
CLOCK_TICK_INTERVAL_MILLIS: 10,
|
||||
|
||||
Reference in New Issue
Block a user