Skip to content

Commit

Permalink
Merge pull request #166 from AlecM33/remove-1-card-requirement
Browse files Browse the repository at this point in the history
Remove 1 card requirement
  • Loading branch information
AlecM33 committed Aug 7, 2023
2 parents 9bb8881 + dc58333 commit 7805e2a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
10 changes: 6 additions & 4 deletions client/src/modules/game_creation/GameCreationStepManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ export class GameCreationStepManager {
forwardHandler: () => {
if (this.deckManager.getDeckSize() > 50) {
toast('Your deck is too large. The max is 50 cards.', 'error', true);
} else if (this.deckManager.getDeckSize() < 1) {
toast('You must add at least one card', 'error', true);
} else {
this.currentGame.deck = this.deckManager.deck.filter((card) => card.quantity > 0);
cancelCurrentToast();
Expand Down Expand Up @@ -366,7 +364,7 @@ function renderTimerStep (containerId, stepNumber, game, steps) {
const hoursDiv = document.createElement('div');
const hoursLabel = document.createElement('label');
hoursLabel.setAttribute('for', 'game-hours');
hoursLabel.innerText = 'Hours (max 5)';
hoursLabel.innerText = 'Hours';
const hours = document.createElement('input');
hours.addEventListener('keyup', steps[stepNumber].forwardHandler);
setAttributes(hours, { type: 'number', id: 'game-hours', name: 'game-hours', min: '0', max: '5', value: game.timerParams?.hours });
Expand Down Expand Up @@ -414,7 +412,7 @@ function renderReviewAndCreateStep (containerId, stepNumber, game, deckManager)
'</div>' +
'<div>' +
"<label id='roles-option-label' for='roles-option'>Game Deck:</label>" +
"<div id='roles-option' class='review-option'></div>" +
"<div id='roles-option' class='review-option'>No cards selected.</div>" +
'</div>';

div.querySelector('#test-game').innerText = game.isTestGame ? 'Yes' : 'No';
Expand All @@ -437,6 +435,10 @@ function renderReviewAndCreateStep (containerId, stepNumber, game, deckManager)
div.querySelector('#timer-option').innerText = 'untimed';
}

if (game.deck.length > 0) {
div.querySelector('#roles-option').innerText = '';
}

for (const card of game.deck) {
const roleEl = document.createElement('div');
roleEl.innerText = card.quantity + 'x ' + card.role;
Expand Down
2 changes: 0 additions & 2 deletions client/src/modules/game_state/states/Lobby.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ export class Lobby {
roleEditPrompt.querySelector('#save-role-changes-button').addEventListener('click', () => {
if (this.gameCreationStepManager.deckManager.getDeckSize() > 50) {
toast('Your deck is too large. The max is 50 cards.', 'error', true);
} else if (this.gameCreationStepManager.deckManager.getDeckSize() < 1) {
toast('You must add at least one card', 'error', true);
} else {
document.querySelector('#mid-game-role-editor')?.remove();
document.querySelector('#role-edit-container-background')?.remove();
Expand Down
4 changes: 3 additions & 1 deletion server/model/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ class Game {
this.previousModeratorId = null;
this.createTime = createTime;
this.timerParams = timerParams;
this.isStartable = (this.gameSize === 1 && !this.hasDedicatedModerator) || isTestGame;
this.isStartable = (this.gameSize === 1 && !this.hasDedicatedModerator)
|| (this.gameSize === 0 && this.hasDedicatedModerator)
|| isTestGame;
this.timeRemaining = null;
}
}
Expand Down
4 changes: 2 additions & 2 deletions server/model/GameCreationRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class GameCreationRequest {
};

static deckIsValid = (deck) => {
if (Array.isArray(deck) && deck.length > 0) {
if (Array.isArray(deck)) {
for (const entry of deck) {
if (entry !== null
&& typeof entry === 'object'
Expand All @@ -45,7 +45,7 @@ class GameCreationRequest {
&& entry.description.length <= globals.MAX_CUSTOM_ROLE_DESCRIPTION_LENGTH
&& (!entry.custom || typeof entry.custom === 'boolean')
&& typeof entry.quantity === 'number'
&& entry.quantity >= 1
&& entry.quantity >= 0
&& entry.quantity <= 50
) {
continue;
Expand Down

0 comments on commit 7805e2a

Please sign in to comment.