remove confusing newGame function
This commit is contained in:
parent
7e0bb8357d
commit
85e9d14b02
4 changed files with 12 additions and 21 deletions
|
|
@ -27,19 +27,6 @@ function __createPlayerObject(id, ts) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function newGame({id, rng, puzzle, players, evtInfos, scoreMode}) {
|
|
||||||
const game = {
|
|
||||||
id: id,
|
|
||||||
rng: rng,
|
|
||||||
puzzle: puzzle,
|
|
||||||
players: players,
|
|
||||||
evtInfos: evtInfos,
|
|
||||||
scoreMode: scoreMode,
|
|
||||||
}
|
|
||||||
setGame(id, game)
|
|
||||||
return game
|
|
||||||
}
|
|
||||||
|
|
||||||
function setGame(gameId, game) {
|
function setGame(gameId, game) {
|
||||||
GAMES[gameId] = game
|
GAMES[gameId] = game
|
||||||
}
|
}
|
||||||
|
|
@ -740,7 +727,7 @@ function handleInput(gameId, playerId, input, ts) {
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
__createPlayerObject,
|
__createPlayerObject,
|
||||||
newGame,
|
setGame,
|
||||||
exists,
|
exists,
|
||||||
playerExists,
|
playerExists,
|
||||||
getRelevantPlayers,
|
getRelevantPlayers,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import GameCommon from './../common/GameCommon.js'
|
import GameCommon from './../common/GameCommon.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
newGame: GameCommon.newGame,
|
setGame: GameCommon.setGame,
|
||||||
getRelevantPlayers: GameCommon.getRelevantPlayers,
|
getRelevantPlayers: GameCommon.getRelevantPlayers,
|
||||||
getActivePlayers: GameCommon.getActivePlayers,
|
getActivePlayers: GameCommon.getActivePlayers,
|
||||||
addPlayer: GameCommon.addPlayer,
|
addPlayer: GameCommon.addPlayer,
|
||||||
|
|
|
||||||
|
|
@ -527,10 +527,12 @@ async function main() {
|
||||||
|
|
||||||
if (MODE === MODE_PLAY) {
|
if (MODE === MODE_PLAY) {
|
||||||
const game = await Communication.connect(gameId, CLIENT_ID)
|
const game = await Communication.connect(gameId, CLIENT_ID)
|
||||||
Game.newGame(Util.decodeGame(game))
|
const gameObject = Util.decodeGame(game)
|
||||||
|
Game.setGame(gameObject.id, gameObject)
|
||||||
} else if (MODE === MODE_REPLAY) {
|
} else if (MODE === MODE_REPLAY) {
|
||||||
const {game, log} = await Communication.connectReplay(gameId, CLIENT_ID)
|
const {game, log} = await Communication.connectReplay(gameId, CLIENT_ID)
|
||||||
Game.newGame(Util.decodeGame(game))
|
const gameObject = Util.decodeGame(game)
|
||||||
|
Game.setGame(gameObject.id, gameObject)
|
||||||
REPLAY.log = log
|
REPLAY.log = log
|
||||||
REPLAY.lastRealTs = Time.timestamp()
|
REPLAY.lastRealTs = Time.timestamp()
|
||||||
REPLAY.gameStartTs = REPLAY.log[0][REPLAY.log[0].length - 1]
|
REPLAY.gameStartTs = REPLAY.log[0][REPLAY.log[0].length - 1]
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ function loadGame(gameId) {
|
||||||
if (!Array.isArray(game.players)) {
|
if (!Array.isArray(game.players)) {
|
||||||
game.players = Object.values(game.players)
|
game.players = Object.values(game.players)
|
||||||
}
|
}
|
||||||
GameCommon.newGame({
|
const gameObject = {
|
||||||
id: game.id,
|
id: game.id,
|
||||||
rng: {
|
rng: {
|
||||||
type: game.rng ? game.rng.type : '_fake_',
|
type: game.rng ? game.rng.type : '_fake_',
|
||||||
|
|
@ -50,7 +50,8 @@ function loadGame(gameId) {
|
||||||
players: game.players,
|
players: game.players,
|
||||||
evtInfos: {},
|
evtInfos: {},
|
||||||
scoreMode: game.scoreMode || GameCommon.SCORE_MODE_FINAL,
|
scoreMode: game.scoreMode || GameCommon.SCORE_MODE_FINAL,
|
||||||
})
|
}
|
||||||
|
GameCommon.setGame(gameObject.id, gameObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
const changedGames = {}
|
const changedGames = {}
|
||||||
|
|
@ -67,11 +68,12 @@ async function createGameObject(gameId, targetTiles, image, ts, scoreMode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function createGame(gameId, targetTiles, image, ts, scoreMode) {
|
async function createGame(gameId, targetTiles, image, ts, scoreMode) {
|
||||||
|
const gameObject = await createGameObject(gameId, targetTiles, image, ts, scoreMode)
|
||||||
|
|
||||||
GameLog.create(gameId)
|
GameLog.create(gameId)
|
||||||
GameLog.log(gameId, Protocol.LOG_HEADER, 1, targetTiles, image, ts, scoreMode)
|
GameLog.log(gameId, Protocol.LOG_HEADER, 1, targetTiles, image, ts, scoreMode)
|
||||||
|
|
||||||
const gameObject = await createGameObject(gameId, targetTiles, image, ts, scoreMode)
|
GameCommon.setGame(gameObject.id, gameObject)
|
||||||
GameCommon.newGame(gameObject)
|
|
||||||
|
|
||||||
changedGames[gameId] = true
|
changedGames[gameId] = true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue