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

@ -1,15 +1,15 @@
// lib/server.ts
import App from "./src/App";
import grpc from "grpc";
import {roomManager} from "./src/RoomManager";
import {IRoomManagerServer, RoomManagerService} from "./src/Messages/generated/messages_grpc_pb";
import {HTTP_PORT, GRPC_PORT} from "./src/Enum/EnvironmentVariable";
import { roomManager } from "./src/RoomManager";
import { IRoomManagerServer, RoomManagerService } from "./src/Messages/generated/messages_grpc_pb";
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();
server.addService<IRoomManagerServer>(RoomManagerService, roomManager);
server.bind(`0.0.0.0:${GRPC_PORT}`, grpc.ServerCredentials.createInsecure());
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

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