/* * Verrückte Turing-Maschinen — A turing complete game * Copyright (C) 2016 Christian Fraß * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ module mod_vtm_manifestation { /** * @author kcf */ export type typ_speicher_partie = { aufbau : mod_vtm_aufbau.typ_partie; } ; /** * @author kcf */ export function speicher_partie_erstellen ( aufbau : mod_vtm_aufbau.typ_partie ) : typ_speicher_partie { return { "aufbau": aufbau }; } /** * @author kcf */ export function speicher_partie_erstellen_erweitert ( aufbau : mod_vtm_aufbau.typ_partie ) : typ_manifestation { return { "art": "speicher_partie", "angaben": speicher_partie_erstellen(aufbau) }; } /** * @author kcf */ function speicher_partie_darstellen(speicher_partie : typ_speicher_partie) : void { } /** * @author kcf */ function speicher_partie_binden(speicher_partie : typ_speicher_partie) : void { mod_vtm_aufbau.partie_lauschen ( this.aufbau, "aenderung_aufgabe", (angaben) => { // console.info("aenderung_aufgabe", angaben); let id : string = mod_vtm_aufbau.aufgabe_id(mod_vtm_aufbau.partie_aufgabe_lesen(this.aufbau)) let key : string = ("vtm_" + id); if (key in localStorage) { let item : string = localStorage.getItem(key); let welt : mod_vtm_aufbau.typ_welt = mod_vtm_aufbau.welt_importieren(JSON.parse(item)); mod_vtm_aufbau.partie_welt_setzen(this.aufbau, welt, false); } else { mod_vtm_aufbau.partie_welt_leeren(this.aufbau); // nichts tun } } ) ; mod_vtm_aufbau.partie_lauschen ( this.aufbau, "aenderung_welt", (angaben) => { let id : string = mod_vtm_aufbau.aufgabe_id(mod_vtm_aufbau.partie_aufgabe_lesen(this.aufbau)) let key : string = ("vtm_" + id); let item : string = JSON.stringify(mod_vtm_aufbau.welt_exportieren(mod_vtm_aufbau.partie_welt_lesen(this.aufbau))); localStorage.setItem(key, item); } ) ; mod_vtm_aufbau.partie_lauschen ( this.aufbau, "aenderung_figur", (angaben) => { // console.info("aenderung_figur", angaben); } ) ; mod_vtm_aufbau.partie_lauschen ( this.aufbau, "aenderung_modus", (angaben) => { // console.info("aenderung_modus", angaben); } ) ; } /** * @author kcf */ implementierung_manifestation["speicher_partie"] = { "darstellen": (manifestation) => speicher_partie_darstellen(manifestation.angaben), "binden": (manifestation) => speicher_partie_binden(manifestation.angaben), } ; }