Merge branch 'develop' into usersLimit

# Conflicts:
#	front/src/Phaser/Game/GameScene.ts
This commit is contained in:
Gregoire Parant 2020-10-24 10:50:37 +02:00
commit 1cf2f19e47
6 changed files with 87 additions and 107 deletions

View file

@ -56,7 +56,7 @@ export class GameRoom {
this.anonymous = isRoomAnonymous(roomId);
this.tags = [];
this.policyType = GameRoomPolicyTypes.ANONYMUS_POLICY;
if (this.anonymous) {
this.roomSlug = extractRoomSlugPublicRoomId(this.roomId);
} else {
@ -65,8 +65,8 @@ export class GameRoom {
this.organizationSlug = organizationSlug;
this.worldSlug = worldSlug;
}
this.users = new Map<number, User>();
this.groups = new Set<Group>();
this.connectCallback = connectCallback;
@ -138,6 +138,12 @@ export class GameRoom {
if (user.group === undefined) {
// If the user is not part of a group:
// should he join a group?
// If the user is moving, don't try to join
if (user.getPosition().moving) {
return;
}
const closestItem: User|Group|null = this.searchClosestAvailableUserOrGroup(user);
if (closestItem !== null) {
@ -275,7 +281,7 @@ export class GameRoom {
return this.itemsState;
}
setViewport(socket : Identificable, viewport: ViewportInterface): Movable[] {
const user = this.users.get(socket.userId);
if(typeof user === 'undefined') {

View file

@ -11,7 +11,7 @@ function createMockUser(userId: number): ExSocketInterface {
} as ExSocketInterface;
}
describe("World", () => {
describe("GameRoom", () => {
it("should connect user1 and user2", () => {
let connectCalledNumber: number = 0;
const connect: ConnectCallback = (user: User, group: Group): void => {