/* * Copyright (c) 2020. Antonio Martinez Casadesus and Pascal Syma. * All rights reserved. */ export default class Storage { static get() { if (!window.localStorage.getItem(Storage.KEY)) this.reset(); return JSON.parse(atob(window.localStorage.getItem(Storage.KEY))); } static set(value) { window.localStorage.setItem(Storage.KEY, btoa(JSON.stringify(value))); } static clear() { window.localStorage.removeItem(Storage.KEY); } static reset() { this.set({ controls: { jump: {name: "Jump", bind: Phaser.Input.Keyboard.KeyCodes.W}, w_left: {name: "Walk left", bind: Phaser.Input.Keyboard.KeyCodes.A}, w_right: {name: "Walk right", bind: Phaser.Input.Keyboard.KeyCodes.D}, use_left: {name: "Use left item", bind: Phaser.Input.Keyboard.KeyCodes.Q}, use_right: {name: "Use right item", bind: Phaser.Input.Keyboard.KeyCodes.E}, attack: {name: "Attack", bind: Phaser.Input.Keyboard.KeyCodes.SPACE}, block: {name: "Block", bind: Phaser.Input.Keyboard.KeyCodes.F}, pickup: {name: "Pickup", bind: Phaser.Input.Keyboard.KeyCodes.S} } }) } } Storage.KEY = "save";