Skip to content
Snippets Groups Projects
Verified Commit 288cf94f authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Implement first part of map loading code

parent 6d666b17
No related branches found
No related tags found
No related merge requests found
Pipeline #7318 passed
......@@ -23,6 +23,33 @@ class BaseBackend {
constructor(userId) {
this.userId = userId;
}
setMapData(mapData) {
this.game.loadMap(mapData);
}
setMapDataFromUrl(url) {
if (url.substr(0, 6) === 'mxc://') {
url = this.resolveMxcUrl(url);
}
fetch(url)
.then((response) => response.json())
.then(this.setMapData);
}
getMap(mapName) {
if (mapName.indexOf('://') > -1) {
this.setMapDataFromUrl(mapName);
} else {
const state = this.getState(EventTypes.map, mapName);
if (state.url !== undefined) {
this.setMapDataFromUrl(state.url);
} else {
this.setMapData(state);
}
}
}
}
export default BaseBackend;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment