Merge branch '2daysLimit' of github.com:thecodingmachine/workadventure into 2daysLimit

This commit is contained in:
David Négrier 2022-01-05 14:32:17 +01:00
commit 6766ee86da
2 changed files with 39 additions and 31 deletions

View File

@ -5,11 +5,11 @@ import {roomManager} from "./src/RoomManager";
import { IRoomManagerServer, RoomManagerService } from "./src/Messages/generated/messages_grpc_pb"; import { IRoomManagerServer, RoomManagerService } from "./src/Messages/generated/messages_grpc_pb";
import { HTTP_PORT, GRPC_PORT } from "./src/Enum/EnvironmentVariable"; import { HTTP_PORT, GRPC_PORT } from "./src/Enum/EnvironmentVariable";
App.listen(HTTP_PORT, () => console.log(`WorkAdventure HTTP API starting on port %d!`, HTTP_PORT)) App.listen(HTTP_PORT, () => console.log(`WorkAdventure HTTP API starting on port %d!`, HTTP_PORT));
const server = new grpc.Server(); const server = new grpc.Server();
server.addService<IRoomManagerServer>(RoomManagerService, roomManager); server.addService<IRoomManagerServer>(RoomManagerService, roomManager);
server.bind(`0.0.0.0:${GRPC_PORT}`, grpc.ServerCredentials.createInsecure()); server.bind(`0.0.0.0:${GRPC_PORT}`, grpc.ServerCredentials.createInsecure());
server.start(); server.start();
console.log('WorkAdventure HTTP/2 API starting on port %d!', GRPC_PORT); console.log("WorkAdventure HTTP/2 API starting on port %d!", GRPC_PORT);

View File

@ -3,21 +3,23 @@ import {PlayerMovement} from "../../../src/Phaser/Game/PlayerMovement";
describe("Interpolation / Extrapolation", () => { describe("Interpolation / Extrapolation", () => {
it("should interpolate", () => { it("should interpolate", () => {
const playerMovement = new PlayerMovement({ const playerMovement = new PlayerMovement(
x: 100, y: 200 {
}, 42000, x: 100,
y: 200,
},
42000,
{ {
x: 200, x: 200,
y: 100, y: 100,
oldX: 100, oldX: 100,
oldY: 200, oldY: 200,
moving: true, moving: true,
direction: "up" direction: "up",
}, },
42200 42200
); );
expect(playerMovement.isOutdated(42100)).toBe(false); expect(playerMovement.isOutdated(42100)).toBe(false);
expect(playerMovement.isOutdated(43000)).toBe(true); expect(playerMovement.isOutdated(43000)).toBe(true);
@ -26,8 +28,8 @@ describe("Interpolation / Extrapolation", () => {
y: 150, y: 150,
oldX: 100, oldX: 100,
oldY: 200, oldY: 200,
direction: 'up', direction: "up",
moving: true moving: true,
}); });
expect(playerMovement.getPosition(42200)).toEqual({ expect(playerMovement.getPosition(42200)).toEqual({
@ -35,8 +37,8 @@ describe("Interpolation / Extrapolation", () => {
y: 100, y: 100,
oldX: 100, oldX: 100,
oldY: 200, oldY: 200,
direction: 'up', direction: "up",
moving: true moving: true,
}); });
expect(playerMovement.getPosition(42300)).toEqual({ expect(playerMovement.getPosition(42300)).toEqual({
@ -44,22 +46,25 @@ describe("Interpolation / Extrapolation", () => {
y: 50, y: 50,
oldX: 100, oldX: 100,
oldY: 200, oldY: 200,
direction: 'up', direction: "up",
moving: true moving: true,
}); });
}); });
it("should not extrapolate if we stop", () => { it("should not extrapolate if we stop", () => {
const playerMovement = new PlayerMovement({ const playerMovement = new PlayerMovement(
x: 100, y: 200 {
}, 42000, x: 100,
y: 200,
},
42000,
{ {
x: 200, x: 200,
y: 100, y: 100,
oldX: 100, oldX: 100,
oldY: 200, oldY: 200,
moving: false, moving: false,
direction: "up" direction: "up",
}, },
42200 42200
); );
@ -69,22 +74,25 @@ describe("Interpolation / Extrapolation", () => {
y: 100, y: 100,
oldX: 100, oldX: 100,
oldY: 200, oldY: 200,
direction: 'up', direction: "up",
moving: false moving: false,
}); });
}); });
it("should keep moving until it stops", () => { it("should keep moving until it stops", () => {
const playerMovement = new PlayerMovement({ const playerMovement = new PlayerMovement(
x: 100, y: 200 {
}, 42000, x: 100,
y: 200,
},
42000,
{ {
x: 200, x: 200,
y: 100, y: 100,
oldX: 100, oldX: 100,
oldY: 200, oldY: 200,
moving: false, moving: false,
direction: "up" direction: "up",
}, },
42200 42200
); );
@ -94,8 +102,8 @@ describe("Interpolation / Extrapolation", () => {
y: 150, y: 150,
oldX: 100, oldX: 100,
oldY: 200, oldY: 200,
direction: 'up', direction: "up",
moving: false moving: false,
});
}); });
}); });
})