vtm/quelldatein/manifestation/speicher/partie.ts

125 lines
3 KiB
TypeScript
Raw Normal View History

/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* 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 <https://www.gnu.org/licenses/>.
*/
module mod_vtm_manifestation
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export class klasse_speicher_partie
extends klasse_manifestation<mod_vtm_aufbau.klasse_partie, void>
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
public constructor(aufbau : mod_vtm_aufbau.klasse_partie)
{
super(aufbau);
}
/**
* @author kcf <vidofnir@folksprak.org>
* @override
*/
public einrichten() : void
{
this.aufbau.lauschen
(
"aenderung_aufgabe",
(angaben) =>
{
// console.info("aenderung_aufgabe", angaben);
let id : string = this.aufbau.aufgabe_lesen().id_lesen();
let key : string = ("vtm_" + id);
if (key in localStorage)
{
let item : string = localStorage.getItem(key);
let welt : mod_vtm_aufbau.klasse_welt = mod_vtm_aufbau.klasse_welt.importieren(JSON.parse(item));
this.aufbau.welt_setzen(welt, false);
}
else
{
this.aufbau.welt_leeren();
// nichts tun
}
}
)
;
this.aufbau.lauschen
(
"aenderung_welt",
(angaben) =>
{
let id : string = this.aufbau.aufgabe_lesen().id_lesen();
let key : string = ("vtm_" + id);
let item : string = JSON.stringify(this.aufbau.welt_lesen().exportieren());
localStorage.setItem(key, item);
}
)
;
this.aufbau.lauschen
(
"aenderung_figur",
(angaben) =>
{
// console.info("aenderung_figur", angaben);
}
)
;
this.aufbau.lauschen
(
"aenderung_modus",
(angaben) =>
{
// console.info("aenderung_modus", angaben);
}
)
;
this.darstellen();
this.binden();
}
/**
* @author kcf <vidofnir@folksprak.org>
* @implementation
*/
public darstellen() : void
{
console.warn("empty");
}
/**
* @author kcf <vidofnir@folksprak.org>
* @implementation
*/
public binden() : void
{
console.warn("empty");
}
}
}