Merge branch 'feature/back-players-proximity' into barycenter_based_groups

This commit is contained in:
David Négrier 2020-04-29 22:06:37 +02:00
commit 5ffc5a420e
2 changed files with 67 additions and 15 deletions

View File

@ -61,8 +61,16 @@ export class World {
}
}
} else {
// If the user is part of a group:
// should we split the group?
// TODO: analyze the group of the user:
// => take one user. "walk the tree of users, each branch being a link<MIN_DISTANCE"
// If some users are not in the subgroup, take the other user and loop
// At the end, we will have a list of subgroups. From this list, we can send disconnect messages
}
// TODO : vérifier qu'ils ne sont pas déja dans un groupe plein
}
/**

View File

@ -53,6 +53,50 @@ describe("World", () => {
}));
expect(connectCalled).toBe(false);
});
it("should disconnect user1 and user2", () => {
let connectCalled: boolean = false;
let disconnectCalled: boolean = false;
let connect = (user1: string, user2: string): void => {
connectCalled = true;
}
let disconnect = (user1: string, user2: string): void => {
disconnectCalled = true;
}
let world = new World(connect, disconnect);
world.join(new MessageUserPosition({
userId: "foo",
roomId: 1,
position: new Point(100, 100)
}));
world.join(new MessageUserPosition({
userId: "bar",
roomId: 1,
position: new Point(259, 100)
}));
expect(connectCalled).toBe(false);
world.updatePosition(new MessageUserPosition({
userId: "bar",
roomId: 1,
position: new Point(261, 100)
}));
expect(disconnectCalled).toBe(true);
disconnectCalled = false;
world.updatePosition(new MessageUserPosition({
userId: "bar",
roomId: 1,
position: new Point(262, 100)
}));
expect(disconnectCalled).toBe(false);
});
/**
it('Should return the distances between all users', () => {
let connectCalled: boolean = false;