rewrote the login workflow

This commit is contained in:
arp 2020-09-25 18:29:22 +02:00
parent 783d58d3cb
commit af4611ed29
20 changed files with 290 additions and 278 deletions

View file

@ -1,9 +1,10 @@
import {GameScene} from "./GameScene";
import {
StartMapInterface
} from "../../Connection";
} from "../../Connexion/ConnexionModels";
import Axios from "axios";
import {API_URL} from "../../Enum/EnvironmentVariable";
import {adminDataFetchPromise} from "../../register";
export interface HasMovedEvent {
direction: string;
@ -29,13 +30,23 @@ export class GameManager {
}
loadStartMap() : Promise<StartMapInterface> {
return Axios.get(`${API_URL}/start-map`)
.then((res) => {
return res.data;
}).catch((err) => {
console.error(err);
throw err;
});
if (adminDataFetchPromise) {
return adminDataFetchPromise.then(data => {
return {
mapUrlStart: data.mapUrlStart,
startInstance: data.startInstance,
}
})
} else {
//todo: remove this call, merge with the admin workflow?
return Axios.get(`${API_URL}/start-map`)
.then((res) => {
return res.data;
}).catch((err) => {
console.error(err);
throw err;
});
}
}
getPlayerName(): string {