/* * 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 { export module mod_manifestation { export module mod_speicher { export module mod_partie { /** * @author kcf */ export type typ_partie = { aufbau : mod_vtm.mod_aufbau.mod_partie.typ_partie; } ; /** * @author kcf */ export function erstellen ( aufbau : mod_vtm.mod_aufbau.mod_partie.typ_partie ) : typ_partie { return { "aufbau": aufbau }; } /** * @author kcf */ export function erstellen_erweitert ( aufbau : mod_vtm.mod_aufbau.mod_partie.typ_partie ) : typ_manifestation { return { "art": "partie", "angaben": erstellen(aufbau) }; } /** * @author kcf */ function darstellen(partie : typ_partie) : void { } /** * @author kcf */ function binden(partie : typ_partie) : void { mod_vtm.mod_aufbau.mod_partie.lauschen ( partie.aufbau, "aenderung_aufgabe", (angaben) => { // console.info("aenderung_aufgabe", angaben); let aufgabe : mod_vtm.mod_aufbau.mod_aufgabe.typ_aufgabe = mod_vtm.mod_aufbau.mod_partie.aufgabe_lesen(partie.aufbau); let id : string = mod_vtm.mod_aufbau.mod_aufgabe.id(aufgabe); let key : string = ("vtm_" + id); // if (key in localStorage) { let item : string = localStorage.getItem(key); let welt_ : any = JSON.parse(item); let welt : mod_vtm.mod_aufbau.mod_welt.typ_welt = mod_vtm.mod_aufbau.mod_welt.importieren(welt_); mod_vtm.mod_aufbau.mod_partie.welt_setzen(partie.aufbau, welt, false); } else { mod_vtm.mod_aufbau.mod_partie.welt_leeren(partie.aufbau); // nichts tun } } ) ; mod_vtm.mod_aufbau.mod_partie.lauschen ( partie.aufbau, "aenderung_welt", (angaben) => { let aufgabe : mod_vtm.mod_aufbau.mod_aufgabe.typ_aufgabe = mod_vtm.mod_aufbau.mod_partie.aufgabe_lesen(partie.aufbau); let id : string = mod_vtm.mod_aufbau.mod_aufgabe.id(aufgabe); let key : string = ("vtm_" + id); // let welt : mod_vtm.mod_aufbau.mod_welt.typ_welt = mod_vtm.mod_aufbau.mod_partie.welt_lesen(partie.aufbau); let welt_ : any = mod_vtm.mod_aufbau.mod_welt.exportieren(welt); let item : string = JSON.stringify(welt_); localStorage.setItem(key, item); } ) ; mod_vtm.mod_aufbau.mod_partie.lauschen ( partie.aufbau, "aenderung_figur", (angaben) => { // console.info("aenderung_figur", angaben); } ) ; mod_vtm.mod_aufbau.mod_partie.lauschen ( partie.aufbau, "aenderung_modus", (angaben) => { // console.info("aenderung_modus", angaben); } ) ; } /** * @author kcf */ implementierung_manifestation["partie"] = { "darstellen": (manifestation) => darstellen(manifestation.angaben), "binden": (manifestation) => binden(manifestation.angaben), } ; } } } }