diff --git a/.env.template b/.env.template index a54df82e..a9ae63d7 100644 --- a/.env.template +++ b/.env.template @@ -13,3 +13,7 @@ TURN_STATIC_AUTH_SECRET= # The email address used by Let's encrypt to send renewal warnings (compulsory) ACME_EMAIL= + +MAX_PER_GROUP=4 +MAX_USERNAME_LENGTH=8 + diff --git a/back/src/Enum/EnvironmentVariable.ts b/back/src/Enum/EnvironmentVariable.ts index 8736a856..81693a98 100644 --- a/back/src/Enum/EnvironmentVariable.ts +++ b/back/src/Enum/EnvironmentVariable.ts @@ -11,6 +11,7 @@ const HTTP_PORT = parseInt(process.env.HTTP_PORT || '8080') || 8080; const GRPC_PORT = parseInt(process.env.GRPC_PORT || '50051') || 50051; export const SOCKET_IDLE_TIMER = parseInt(process.env.SOCKET_IDLE_TIMER as string) || 30; // maximum time (in second) without activity before a socket is closed export const TURN_STATIC_AUTH_SECRET = process.env.TURN_STATIC_AUTH_SECRET || ''; +export const MAX_PER_GROUP = parseInt(process.env.MAX_PER_GROUP || '4'); export { MINIMUM_DISTANCE, diff --git a/back/src/Model/Group.ts b/back/src/Model/Group.ts index f26a0e0d..ffe7a78a 100644 --- a/back/src/Model/Group.ts +++ b/back/src/Model/Group.ts @@ -4,9 +4,9 @@ import {PositionInterface} from "_Model/PositionInterface"; import {Movable} from "_Model/Movable"; import {PositionNotifier} from "_Model/PositionNotifier"; import {gaugeManager} from "../Services/GaugeManager"; +import {MAX_PER_GROUP} from "../Enum/EnvironmentVariable"; export class Group implements Movable { - static readonly MAX_PER_GROUP = 4; private static nextId: number = 1; @@ -88,7 +88,7 @@ export class Group implements Movable { } isFull(): boolean { - return this.users.size >= Group.MAX_PER_GROUP; + return this.users.size >= MAX_PER_GROUP; } isEmpty(): boolean { diff --git a/docker-compose.single-domain.yaml b/docker-compose.single-domain.yaml index 0bd1dcb6..1a390f4c 100644 --- a/docker-compose.single-domain.yaml +++ b/docker-compose.single-domain.yaml @@ -116,6 +116,7 @@ services: ADMIN_API_TOKEN: "$ADMIN_API_TOKEN" JITSI_URL: $JITSI_URL JITSI_ISS: $JITSI_ISS + MAX_PER_GROUP: "$MAX_PER_GROUP" volumes: - ./back:/usr/src/app labels: diff --git a/docker-compose.yaml b/docker-compose.yaml index 504c5b23..cea1bc03 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -38,6 +38,8 @@ services: TURN_USER: "" TURN_PASSWORD: "" START_ROOM_URL: "$START_ROOM_URL" + MAX_PER_GROUP: "$MAX_PER_GROUP" + MAX_USERNAME_LENGTH: "$MAX_USERNAME_LENGTH" command: yarn run start volumes: - ./front:/usr/src/app @@ -110,6 +112,7 @@ services: JITSI_URL: $JITSI_URL JITSI_ISS: $JITSI_ISS TURN_STATIC_AUTH_SECRET: SomeStaticAuthSecret + MAX_PER_GROUP: "MAX_PER_GROUP" volumes: - ./back:/usr/src/app labels: diff --git a/front/src/Enum/EnvironmentVariable.ts b/front/src/Enum/EnvironmentVariable.ts index 5040e59f..11479b0f 100644 --- a/front/src/Enum/EnvironmentVariable.ts +++ b/front/src/Enum/EnvironmentVariable.ts @@ -15,6 +15,7 @@ const ZOOM_LEVEL = 1/*3/4*/; const POSITION_DELAY = 200; // Wait 200ms between sending position events const MAX_EXTRAPOLATION_TIME = 100; // Extrapolate a maximum of 250ms if no new movement is sent by the player export const MAX_USERNAME_LENGTH = parseInt(process.env.MAX_USERNAME_LENGTH || '') || 8; +export const MAX_PER_GROUP = parseInt(process.env.MAX_PER_GROUP || '4'); export { DEBUG_MODE, diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 294174a2..e9028a00 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -10,7 +10,14 @@ import { RoomJoinedMessageInterface } from "../../Connexion/ConnexionModels"; import {CurrentGamerInterface, hasMovedEventName, Player} from "../Player/Player"; -import {DEBUG_MODE, JITSI_PRIVATE_MODE, POSITION_DELAY, RESOLUTION, ZOOM_LEVEL} from "../../Enum/EnvironmentVariable"; +import { + DEBUG_MODE, + JITSI_PRIVATE_MODE, + MAX_PER_GROUP, + POSITION_DELAY, + RESOLUTION, + ZOOM_LEVEL +} from "../../Enum/EnvironmentVariable"; import {ITiledMap, ITiledMapLayer, ITiledMapLayerProperty, ITiledMapObject, ITiledTileSet} from "../Map/ITiledMap"; import {AddPlayerInterface} from "./AddPlayerInterface"; import {PlayerAnimationDirections} from "../Player/Animation"; @@ -1344,7 +1351,7 @@ ${escapedMessage} this, Math.round(groupPositionMessage.position.x), Math.round(groupPositionMessage.position.y), - groupPositionMessage.groupSize === 4 ? 'circleSprite-red' : 'circleSprite-white' + groupPositionMessage.groupSize === MAX_PER_GROUP ? 'circleSprite-red' : 'circleSprite-white' ); sprite.setDisplayOrigin(48, 48); this.add.existing(sprite);