Merge remote-tracking branch 'remotes/upstream/develop' into trigger-message-refv3
This commit is contained in:
commit
369d453455
202 changed files with 15971 additions and 4927 deletions
|
@ -1,58 +1,89 @@
|
|||
import "jasmine";
|
||||
import {Room} from "../../../src/Connexion/Room";
|
||||
import { Room } from "../../../src/Connexion/Room";
|
||||
|
||||
describe("Room getIdFromIdentifier()", () => {
|
||||
it("should work with an absolute room id and no hash as parameter", () => {
|
||||
const {roomId, hash} = Room.getIdFromIdentifier('/_/global/maps.workadventu.re/test2.json', '', '');
|
||||
expect(roomId).toEqual('_/global/maps.workadventu.re/test2.json');
|
||||
expect(hash).toEqual('');
|
||||
const { roomId, hash } = Room.getIdFromIdentifier("/_/global/maps.workadventu.re/test2.json", "", "");
|
||||
expect(roomId).toEqual("_/global/maps.workadventu.re/test2.json");
|
||||
expect(hash).toEqual(null);
|
||||
});
|
||||
it("should work with an absolute room id and a hash as parameters", () => {
|
||||
const {roomId, hash} = Room.getIdFromIdentifier('/_/global/maps.workadventu.re/test2.json#start', '', '');
|
||||
expect(roomId).toEqual('_/global/maps.workadventu.re/test2.json');
|
||||
const { roomId, hash } = Room.getIdFromIdentifier("/_/global/maps.workadventu.re/test2.json#start", "", "");
|
||||
expect(roomId).toEqual("_/global/maps.workadventu.re/test2.json");
|
||||
expect(hash).toEqual("start");
|
||||
});
|
||||
it("should work with an absolute room id, regardless of baseUrl or instance", () => {
|
||||
const {roomId, hash} = Room.getIdFromIdentifier('/_/global/maps.workadventu.re/test2.json', 'https://another.domain/_/global/test.json', 'lol');
|
||||
expect(roomId).toEqual('_/global/maps.workadventu.re/test2.json');
|
||||
expect(hash).toEqual('');
|
||||
const { roomId, hash } = Room.getIdFromIdentifier(
|
||||
"/_/global/maps.workadventu.re/test2.json",
|
||||
"https://another.domain/_/global/test.json",
|
||||
"lol"
|
||||
);
|
||||
expect(roomId).toEqual("_/global/maps.workadventu.re/test2.json");
|
||||
expect(hash).toEqual(null);
|
||||
});
|
||||
|
||||
|
||||
|
||||
it("should work with a relative file link and no hash as parameters", () => {
|
||||
const {roomId, hash} = Room.getIdFromIdentifier('./test2.json', 'https://maps.workadventu.re/test.json', 'global');
|
||||
expect(roomId).toEqual('_/global/maps.workadventu.re/test2.json');
|
||||
expect(hash).toEqual('');
|
||||
const { roomId, hash } = Room.getIdFromIdentifier(
|
||||
"./test2.json",
|
||||
"https://maps.workadventu.re/test.json",
|
||||
"global"
|
||||
);
|
||||
expect(roomId).toEqual("_/global/maps.workadventu.re/test2.json");
|
||||
expect(hash).toEqual(null);
|
||||
});
|
||||
it("should work with a relative file link with no dot", () => {
|
||||
const {roomId, hash} = Room.getIdFromIdentifier('test2.json', 'https://maps.workadventu.re/test.json', 'global');
|
||||
expect(roomId).toEqual('_/global/maps.workadventu.re/test2.json');
|
||||
expect(hash).toEqual('');
|
||||
const { roomId, hash } = Room.getIdFromIdentifier(
|
||||
"test2.json",
|
||||
"https://maps.workadventu.re/test.json",
|
||||
"global"
|
||||
);
|
||||
expect(roomId).toEqual("_/global/maps.workadventu.re/test2.json");
|
||||
expect(hash).toEqual(null);
|
||||
});
|
||||
it("should work with a relative file link two levels deep", () => {
|
||||
const {roomId, hash} = Room.getIdFromIdentifier('../floor1/Floor1.json', 'https://maps.workadventu.re/floor0/Floor0.json', 'global');
|
||||
expect(roomId).toEqual('_/global/maps.workadventu.re/floor1/Floor1.json');
|
||||
expect(hash).toEqual('');
|
||||
const { roomId, hash } = Room.getIdFromIdentifier(
|
||||
"../floor1/Floor1.json",
|
||||
"https://maps.workadventu.re/floor0/Floor0.json",
|
||||
"global"
|
||||
);
|
||||
expect(roomId).toEqual("_/global/maps.workadventu.re/floor1/Floor1.json");
|
||||
expect(hash).toEqual(null);
|
||||
});
|
||||
it("should work with a relative file link that rewrite the map domain", () => {
|
||||
const {roomId, hash} = Room.getIdFromIdentifier('../../maps.workadventure.localhost/Floor1/floor1.json', 'https://maps.workadventu.re/floor0/Floor0.json', 'global');
|
||||
expect(roomId).toEqual('_/global/maps.workadventure.localhost/Floor1/floor1.json');
|
||||
expect(hash).toEqual('');
|
||||
const { roomId, hash } = Room.getIdFromIdentifier(
|
||||
"../../maps.workadventure.localhost/Floor1/floor1.json",
|
||||
"https://maps.workadventu.re/floor0/Floor0.json",
|
||||
"global"
|
||||
);
|
||||
expect(roomId).toEqual("_/global/maps.workadventure.localhost/Floor1/floor1.json");
|
||||
expect(hash).toEqual(null);
|
||||
});
|
||||
it("should work with a relative file link that rewrite the map instance", () => {
|
||||
const {roomId, hash} = Room.getIdFromIdentifier('../../../notglobal/maps.workadventu.re/Floor1/floor1.json', 'https://maps.workadventu.re/floor0/Floor0.json', 'global');
|
||||
expect(roomId).toEqual('_/notglobal/maps.workadventu.re/Floor1/floor1.json');
|
||||
expect(hash).toEqual('');
|
||||
const { roomId, hash } = Room.getIdFromIdentifier(
|
||||
"../../../notglobal/maps.workadventu.re/Floor1/floor1.json",
|
||||
"https://maps.workadventu.re/floor0/Floor0.json",
|
||||
"global"
|
||||
);
|
||||
expect(roomId).toEqual("_/notglobal/maps.workadventu.re/Floor1/floor1.json");
|
||||
expect(hash).toEqual(null);
|
||||
});
|
||||
it("should work with a relative file link that change the map type", () => {
|
||||
const {roomId, hash} = Room.getIdFromIdentifier('../../../../@/tcm/is/great', 'https://maps.workadventu.re/floor0/Floor0.json', 'global');
|
||||
expect(roomId).toEqual('@/tcm/is/great');
|
||||
expect(hash).toEqual('');
|
||||
const { roomId, hash } = Room.getIdFromIdentifier(
|
||||
"../../../../@/tcm/is/great",
|
||||
"https://maps.workadventu.re/floor0/Floor0.json",
|
||||
"global"
|
||||
);
|
||||
expect(roomId).toEqual("@/tcm/is/great");
|
||||
expect(hash).toEqual(null);
|
||||
});
|
||||
|
||||
|
||||
it("should work with a relative file link and a hash as parameters", () => {
|
||||
const {roomId, hash} = Room.getIdFromIdentifier('./test2.json#start', 'https://maps.workadventu.re/test.json', 'global');
|
||||
expect(roomId).toEqual('_/global/maps.workadventu.re/test2.json');
|
||||
const { roomId, hash } = Room.getIdFromIdentifier(
|
||||
"./test2.json#start",
|
||||
"https://maps.workadventu.re/test.json",
|
||||
"global"
|
||||
);
|
||||
expect(roomId).toEqual("_/global/maps.workadventu.re/test2.json");
|
||||
expect(hash).toEqual("start");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,150 +1,155 @@
|
|||
import "jasmine";
|
||||
import {Room} from "../../../src/Connexion/Room";
|
||||
import {flattenGroupLayersMap} from "../../../src/Phaser/Map/LayersFlattener";
|
||||
import type {ITiledMapLayer} from "../../../src/Phaser/Map/ITiledMap";
|
||||
import { Room } from "../../../src/Connexion/Room";
|
||||
import { flattenGroupLayersMap } from "../../../src/Phaser/Map/LayersFlattener";
|
||||
import type { ITiledMapLayer } from "../../../src/Phaser/Map/ITiledMap";
|
||||
|
||||
describe("Layers flattener", () => {
|
||||
it("should iterate maps with no group", () => {
|
||||
let flatLayers:ITiledMapLayer[] = [];
|
||||
let flatLayers: ITiledMapLayer[] = [];
|
||||
flatLayers = flattenGroupLayersMap({
|
||||
"compressionlevel": -1,
|
||||
"height": 2,
|
||||
"infinite": false,
|
||||
"layers": [
|
||||
compressionlevel: -1,
|
||||
height: 2,
|
||||
infinite: false,
|
||||
layers: [
|
||||
{
|
||||
"data": [0, 0, 0, 0],
|
||||
"height": 2,
|
||||
"id": 1,
|
||||
"name": "Tile Layer 1",
|
||||
"opacity": 1,
|
||||
"type": "tilelayer",
|
||||
"visible": true,
|
||||
"width": 2,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
data: [0, 0, 0, 0],
|
||||
height: 2,
|
||||
id: 1,
|
||||
name: "Tile Layer 1",
|
||||
opacity: 1,
|
||||
type: "tilelayer",
|
||||
visible: true,
|
||||
width: 2,
|
||||
x: 0,
|
||||
y: 0,
|
||||
},
|
||||
{
|
||||
"data": [0, 0, 0, 0],
|
||||
"height": 2,
|
||||
"id": 1,
|
||||
"name": "Tile Layer 2",
|
||||
"opacity": 1,
|
||||
"type": "tilelayer",
|
||||
"visible": true,
|
||||
"width": 2,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}],
|
||||
"nextlayerid": 2,
|
||||
"nextobjectid": 1,
|
||||
"orientation": "orthogonal",
|
||||
"renderorder": "right-down",
|
||||
"tiledversion": "2021.03.23",
|
||||
"tileheight": 32,
|
||||
"tilesets": [],
|
||||
"tilewidth": 32,
|
||||
"type": "map",
|
||||
"version": 1.5,
|
||||
"width": 2
|
||||
})
|
||||
data: [0, 0, 0, 0],
|
||||
height: 2,
|
||||
id: 1,
|
||||
name: "Tile Layer 2",
|
||||
opacity: 1,
|
||||
type: "tilelayer",
|
||||
visible: true,
|
||||
width: 2,
|
||||
x: 0,
|
||||
y: 0,
|
||||
},
|
||||
],
|
||||
nextlayerid: 2,
|
||||
nextobjectid: 1,
|
||||
orientation: "orthogonal",
|
||||
renderorder: "right-down",
|
||||
tiledversion: "2021.03.23",
|
||||
tileheight: 32,
|
||||
tilesets: [],
|
||||
tilewidth: 32,
|
||||
type: "map",
|
||||
version: 1.5,
|
||||
width: 2,
|
||||
});
|
||||
|
||||
const layers = [];
|
||||
for (const layer of flatLayers) {
|
||||
layers.push(layer.name);
|
||||
}
|
||||
expect(layers).toEqual(['Tile Layer 1', 'Tile Layer 2']);
|
||||
expect(layers).toEqual(["Tile Layer 1", "Tile Layer 2"]);
|
||||
});
|
||||
|
||||
it("should iterate maps with recursive groups", () => {
|
||||
let flatLayers:ITiledMapLayer[] = [];
|
||||
let flatLayers: ITiledMapLayer[] = [];
|
||||
flatLayers = flattenGroupLayersMap({
|
||||
"compressionlevel": -1,
|
||||
"height": 2,
|
||||
"infinite": false,
|
||||
"layers": [
|
||||
compressionlevel: -1,
|
||||
height: 2,
|
||||
infinite: false,
|
||||
layers: [
|
||||
{
|
||||
"id": 6,
|
||||
"layers": [
|
||||
id: 6,
|
||||
layers: [
|
||||
{
|
||||
"id": 5,
|
||||
"layers": [
|
||||
id: 5,
|
||||
layers: [
|
||||
{
|
||||
"data": [0, 0, 0, 0],
|
||||
"height": 2,
|
||||
"id": 10,
|
||||
"name": "Tile3",
|
||||
"opacity": 1,
|
||||
"type": "tilelayer",
|
||||
"visible": true,
|
||||
"width": 2,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
data: [0, 0, 0, 0],
|
||||
height: 2,
|
||||
id: 10,
|
||||
name: "Tile3",
|
||||
opacity: 1,
|
||||
type: "tilelayer",
|
||||
visible: true,
|
||||
width: 2,
|
||||
x: 0,
|
||||
y: 0,
|
||||
},
|
||||
{
|
||||
"data": [0, 0, 0, 0],
|
||||
"height": 2,
|
||||
"id": 9,
|
||||
"name": "Tile2",
|
||||
"opacity": 1,
|
||||
"type": "tilelayer",
|
||||
"visible": true,
|
||||
"width": 2,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}],
|
||||
"name": "Group 3",
|
||||
"opacity": 1,
|
||||
"type": "group",
|
||||
"visible": true,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
data: [0, 0, 0, 0],
|
||||
height: 2,
|
||||
id: 9,
|
||||
name: "Tile2",
|
||||
opacity: 1,
|
||||
type: "tilelayer",
|
||||
visible: true,
|
||||
width: 2,
|
||||
x: 0,
|
||||
y: 0,
|
||||
},
|
||||
],
|
||||
name: "Group 3",
|
||||
opacity: 1,
|
||||
type: "group",
|
||||
visible: true,
|
||||
x: 0,
|
||||
y: 0,
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"layers": [
|
||||
id: 7,
|
||||
layers: [
|
||||
{
|
||||
"data": [0, 0, 0, 0],
|
||||
"height": 2,
|
||||
"id": 8,
|
||||
"name": "Tile1",
|
||||
"opacity": 1,
|
||||
"type": "tilelayer",
|
||||
"visible": true,
|
||||
"width": 2,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}],
|
||||
"name": "Group 2",
|
||||
"opacity": 1,
|
||||
"type": "group",
|
||||
"visible": true,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}],
|
||||
"name": "Group 1",
|
||||
"opacity": 1,
|
||||
"type": "group",
|
||||
"visible": true,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}],
|
||||
"nextlayerid": 11,
|
||||
"nextobjectid": 1,
|
||||
"orientation": "orthogonal",
|
||||
"renderorder": "right-down",
|
||||
"tiledversion": "2021.03.23",
|
||||
"tileheight": 32,
|
||||
"tilesets": [],
|
||||
"tilewidth": 32,
|
||||
"type": "map",
|
||||
"version": 1.5,
|
||||
"width": 2
|
||||
})
|
||||
data: [0, 0, 0, 0],
|
||||
height: 2,
|
||||
id: 8,
|
||||
name: "Tile1",
|
||||
opacity: 1,
|
||||
type: "tilelayer",
|
||||
visible: true,
|
||||
width: 2,
|
||||
x: 0,
|
||||
y: 0,
|
||||
},
|
||||
],
|
||||
name: "Group 2",
|
||||
opacity: 1,
|
||||
type: "group",
|
||||
visible: true,
|
||||
x: 0,
|
||||
y: 0,
|
||||
},
|
||||
],
|
||||
name: "Group 1",
|
||||
opacity: 1,
|
||||
type: "group",
|
||||
visible: true,
|
||||
x: 0,
|
||||
y: 0,
|
||||
},
|
||||
],
|
||||
nextlayerid: 11,
|
||||
nextobjectid: 1,
|
||||
orientation: "orthogonal",
|
||||
renderorder: "right-down",
|
||||
tiledversion: "2021.03.23",
|
||||
tileheight: 32,
|
||||
tilesets: [],
|
||||
tilewidth: 32,
|
||||
type: "map",
|
||||
version: 1.5,
|
||||
width: 2,
|
||||
});
|
||||
|
||||
const layers = [];
|
||||
for (const layer of flatLayers) {
|
||||
layers.push(layer.name);
|
||||
}
|
||||
expect(layers).toEqual(['Group 1/Group 3/Tile3', 'Group 1/Group 3/Tile2', 'Group 1/Group 2/Tile1']);
|
||||
expect(layers).toEqual(["Group 1/Group 3/Tile3", "Group 1/Group 3/Tile2", "Group 1/Group 2/Tile1"]);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue