MAPG-235 new challenge can be created and is prepared

This commit is contained in:
balazs committed 2021-05-12 13:51:06 +02:00
1 parent 99244e93d2
commit d7147b30d6
14 files changed
+289 -17

No files matched your search

+24 -2
View File
@@ -1,10 +1,13 @@
'use strict';
const GameType = Object.freeze({'SINGLE': 0, 'MULTI': 1, 'CHALLENGE': 2});
(function () {
var Game = {
NUMBER_OF_ROUNDS: 5,
MAX_SCORE: 1000,
type: GameType.SINGLE,
mapBounds: null,
multi: { token: null, owner: false },
rounds: [],
@@ -211,6 +214,19 @@
}
},
getGameIdentifier: function() {
switch(Game.type) {
case GameType.SINGLE:
return '/game/' + mapId;
case GameType.MULTI:
return '/multiGame/' + roomId;
case GameType.CHALLENGE:
return '/challenge/' + challengeToken;
default:
return '/game/' + mapId;
}
},
prepare: function () {
var data = new FormData();
var userNames;
@@ -226,7 +242,7 @@
}
document.getElementById('loading').style.visibility = 'visible';
var url = roomId ? '/multiGame/' + roomId + '/prepare.json' : '/game/' + mapId + '/prepare.json';
var url = Game.getGameIdentifier() + '/prepare.json';
MapGuesser.httpRequest('POST', url, function () {
document.getElementById('loading').style.visibility = 'hidden';
@@ -269,7 +285,7 @@
}
document.getElementById('loading').style.visibility = 'visible';
MapGuesser.httpRequest('POST', '/game/' + mapId + '/initialData.json', function () {
MapGuesser.httpRequest('POST', Game.getGameIdentifier() + '/initialData.json', function () {
document.getElementById('loading').style.visibility = 'hidden';
document.getElementById('panoCover').style.visibility = 'hidden';
@@ -876,6 +892,12 @@
document.getElementById("compass").style.transform = "translateY(-50%) rotate(" + heading + "deg)";
});
if(roomId !== null) {
Game.type = GameType.MULTI;
} else if(challengeToken !== null) {
Game.type = GameType.CHALLENGE;
}
if (COOKIES_CONSENT) {
Game.prepare();
}