diff options
Diffstat (limited to 'client/src/logic/logic.ts')
-rw-r--r-- | client/src/logic/logic.ts | 50 |
1 files changed, 14 insertions, 36 deletions
diff --git a/client/src/logic/logic.ts b/client/src/logic/logic.ts index 1cca2b7..dd6e21d 100644 --- a/client/src/logic/logic.ts +++ b/client/src/logic/logic.ts @@ -1,10 +1,13 @@ -import { genItems, loadMap, getMap } from "../map.js"; +import { genItems, genMap, getMap, decompressMap } from "../map.js"; import { updatePlayers } from "./players.js" import { updateUI } from "./ui.js" import { updateMovement } from "./movement.js" import { updateItems } from "./items.js" import { GameState, Input } from "../types.js"; +const maps = { + [0]: 'EwRgPqYgNDew+TEuW6AGT2u59mPI/PeLZclSys1AhSgThJcJb2bdq7p5rupV2DYaVFCKI9HwFDiWACyxyK5WpCqArOPSCeuqfUnzDwaGbMyT3FAGZT0ABznD9ybWv0LLq61kz4S0M9WRMANnVVDUi1AHYdQxt+dyNEhJNiNk8A3npkiVSmcUEM6E5C/wL86rlivLqxaVymltggA=' +} export const InitialState: GameState = { started: false, @@ -32,7 +35,7 @@ export const onLogic = ( } if (startPressed && !data.started) { - initMap(data) + initMap(data, 0) data.started = true; } @@ -40,41 +43,16 @@ export const onLogic = ( } -const initMap = (data: GameState) => { - - document.getElementById("lobby").style.display = "none" - - data.mapId = 0 +const initMap = (gameData: GameState, mapId: number) => { - if (getMap(0)) return + gameData.mapId = mapId - let width = 21 - let height = 21 - let m_data = [ - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1, - 1,0,1,1,1,0,1,1,1,0,1,0,1,1,1,0,1,1,1,0,1, - 1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1, - 1,0,1,0,1,1,1,1,1,0,1,0,1,1,1,1,1,0,1,0,1, - 1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1, - 1,0,1,1,1,0,1,0,1,1,1,1,1,0,1,0,1,1,1,0,1, - 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, - 1,1,1,0,1,0,1,0,1,1,1,1,1,0,1,0,1,0,1,1,1, - 1,0,0,0,0,0,1,0,1,2,2,2,1,0,1,0,0,0,0,0,1, - 1,0,1,1,1,0,1,0,1,2,2,2,1,0,1,0,1,1,1,0,1, - 1,0,0,0,0,0,1,0,1,2,2,2,1,0,1,0,0,0,0,0,1, - 1,1,1,0,1,0,1,0,1,1,2,1,1,0,1,0,1,0,1,1,1, - 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, - 1,0,1,1,1,0,1,0,1,1,1,1,1,0,1,0,1,1,1,0,1, - 1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1, - 1,0,1,0,1,1,1,1,1,0,1,0,1,1,1,1,1,0,1,0,1, - 1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1, - 1,0,1,1,1,0,1,1,1,0,1,0,1,1,1,0,1,1,1,0,1, - 1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 - ] - - loadMap(width, height, m_data) // cursed temp thing - data.items = genItems(getMap(0)) + let map = getMap(mapId) + if (!map) { + let {width, height, data} = decompressMap(maps[mapId]) + map = genMap(width, height, data, mapId) + } + + gameData.items = genItems(map) } |