Skip to content

Commit

Permalink
Fix run issues
Browse files Browse the repository at this point in the history
  • Loading branch information
vck3000 committed Feb 11, 2024
1 parent 3a5dd28 commit ae500a9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/gameplay/commonPhases/pickingTeam.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import usernamesIndexes from '../../myFunctions/usernamesIndexes';
import Phase from '../avalon/phases/phases';
import { MIN_PLAYERS } from '../game';

function PickingTeam(thisRoom_) {
this.thisRoom = thisRoom_;
Expand Down Expand Up @@ -39,7 +40,7 @@ PickingTeam.prototype.gameMove = function (

let num =
this.thisRoom.numPlayersOnMission[
this.thisRoom.playersInGame.length - this.thisRoom.minPlayers
this.thisRoom.playersInGame.length - MIN_PLAYERS
][this.thisRoom.missionNum - 1];
// console.log("Num player for this.thisRoom mission : " + num);

Expand Down Expand Up @@ -135,7 +136,7 @@ PickingTeam.prototype.buttonSettings = function (indexOfPlayer) {
PickingTeam.prototype.numOfTargets = function (indexOfPlayer) {
let num =
this.thisRoom.numPlayersOnMission[
this.thisRoom.playersInGame.length - this.thisRoom.minPlayers
this.thisRoom.playersInGame.length - MIN_PLAYERS
][this.thisRoom.missionNum - 1];
// console.log("Num player for this.thisRoom mission : " + num);

Expand All @@ -161,7 +162,7 @@ PickingTeam.prototype.getStatusMessage = function (indexOfPlayer) {
) {
const num =
this.thisRoom.numPlayersOnMission[
this.thisRoom.playersInGame.length - this.thisRoom.minPlayers
this.thisRoom.playersInGame.length - MIN_PLAYERS
][this.thisRoom.missionNum - 1];

return `Your turn to pick a team. Pick ${num} players.`;
Expand Down
2 changes: 1 addition & 1 deletion src/gameplay/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { gameModeObj } from './gameModes';
import Phase from './avalon/phases/phases';

export const WAITING = 'Waiting';
const MIN_PLAYERS = 5;
export const MIN_PLAYERS = 5;

class Game extends Room {
gameStarted = false;
Expand Down
3 changes: 2 additions & 1 deletion src/gameplay/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { AVALON, AVALON_BOT, GAME_MODE_NAMES, gameModeObj } from './gameModes';
import commonPhasesIndex from './indexCommonPhases';
import usernamesIndexes from '../myFunctions/usernamesIndexes';
import { SocketUser } from '../sockets/types';
import { MIN_PLAYERS } from './game';

class Room {
host: string;
Expand Down Expand Up @@ -656,7 +657,7 @@ class Room {

if (this.canJoin === true) {
// check before starting
if (this.socketsOfPlayers.length < this.minPlayers) {
if (this.socketsOfPlayers.length < MIN_PLAYERS) {
// NEED AT LEAST FIVE PLAYERS, SHOW ERROR MESSAGE BACK
// console.log("Not enough players.");
this.socketsOfPlayers[0].emit(
Expand Down
4 changes: 4 additions & 0 deletions src/sockets/sockets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ setTimeout(async () => {
.skip(i)
.limit(1)
.exec((err, foundSaveGameArr) => {
if (!foundSaveGameArr || foundSaveGameArr.length === 0) {
run = false;
return;
}
const foundSaveGame = foundSaveGameArr[0];

if (foundSaveGame && foundSaveGame.room) {
Expand Down

0 comments on commit ae500a9

Please sign in to comment.