2017-11-09 14:06:35 +01:00
|
|
|
/*
|
|
|
|
|
* 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/>.
|
|
|
|
|
*/
|
2017-11-08 18:41:56 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author kcf <vidofnir@folksprak.org>
|
|
|
|
|
*/
|
2017-11-09 14:06:35 +01:00
|
|
|
function aufgaben_laden(behandler : (aufgabe : mod_vtm_aufbau.schnittstelle_aufgabe)=>void) : void
|
2017-11-08 18:41:56 +01:00
|
|
|
{
|
2017-11-09 14:06:35 +01:00
|
|
|
let aufgaben_roh_ : schnittstelle_fehlermonade<Array<any>> = mod_vtm_daten.lesen("aufgaben");
|
|
|
|
|
if (aufgaben_roh_.ist_schlicht())
|
2017-11-08 18:41:56 +01:00
|
|
|
{
|
2017-11-09 14:06:35 +01:00
|
|
|
let aufgaben_roh : Array<any> = aufgaben_roh_.lesen();
|
|
|
|
|
let dom_auswahl : Element = document.querySelector("#aufgabe_auswahl");
|
|
|
|
|
aufgaben_roh.forEach
|
2017-11-08 18:41:56 +01:00
|
|
|
(
|
2017-11-09 14:06:35 +01:00
|
|
|
(aufgabe_roh, index) =>
|
|
|
|
|
{
|
|
|
|
|
let titel : string = aufgabe_roh["parameter"]["titel"];
|
|
|
|
|
let dom_option : Element = document.createElement("option");
|
|
|
|
|
dom_option.setAttribute("value", index.toFixed(0));
|
|
|
|
|
dom_option.textContent = titel;
|
|
|
|
|
dom_auswahl.appendChild(dom_option);
|
|
|
|
|
}
|
2017-11-08 18:41:56 +01:00
|
|
|
)
|
|
|
|
|
;
|
2017-11-09 14:06:35 +01:00
|
|
|
dom_auswahl.addEventListener
|
|
|
|
|
(
|
|
|
|
|
"change",
|
|
|
|
|
event =>
|
|
|
|
|
{
|
|
|
|
|
let index : int = dom_auswahl["value"];
|
|
|
|
|
let aufgabe_roh : any = aufgaben_roh[index];
|
|
|
|
|
let aufgabe : mod_vtm_aufbau.schnittstelle_aufgabe = mod_vtm_aufbau.aufgabe_erstellen(aufgabe_roh);
|
|
|
|
|
behandler(aufgabe);
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
console.warn("Daten nicht auffindbar");
|
2017-11-08 18:41:56 +01:00
|
|
|
}
|
2017-11-09 14:06:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author kcf <vidofnir@folksprak.org>
|
|
|
|
|
*/
|
|
|
|
|
function haupt() : void
|
|
|
|
|
{
|
|
|
|
|
let aufbau : mod_vtm_aufbau.klasse_partie;
|
|
|
|
|
let manifestationen : Array<any>;
|
|
|
|
|
let aktualisieren = function () : void
|
|
|
|
|
{
|
|
|
|
|
manifestationen.forEach
|
|
|
|
|
(
|
|
|
|
|
manifestation =>
|
|
|
|
|
{
|
|
|
|
|
manifestation.darstellen();
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
let intervall : any = null;
|
|
|
|
|
aufgaben_laden
|
|
|
|
|
(
|
|
|
|
|
aufgabe =>
|
|
|
|
|
{
|
|
|
|
|
document.querySelector("#aufgabe_text").textContent = aufgabe.text();
|
|
|
|
|
aufbau = (new mod_vtm_aufbau.klasse_partie(aufgabe));
|
|
|
|
|
manifestationen = (
|
|
|
|
|
[
|
|
|
|
|
new mod_vtm_manifestation.klasse_web_partie(aufbau, document.querySelector("#bereich_mitte")),
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
manifestationen.forEach
|
|
|
|
|
(
|
|
|
|
|
manifestation =>
|
|
|
|
|
{
|
|
|
|
|
manifestation.einrichten();
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
aktualisieren();
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
;
|
|
|
|
|
document.querySelector("#knopf_testen").addEventListener
|
|
|
|
|
(
|
|
|
|
|
"click",
|
|
|
|
|
event =>
|
|
|
|
|
{
|
|
|
|
|
intervall = setInterval
|
|
|
|
|
(
|
|
|
|
|
() =>
|
|
|
|
|
{
|
|
|
|
|
// console.log("-- tick");
|
|
|
|
|
aufbau.fortfahren();
|
|
|
|
|
let modus : mod_vtm_aufbau.typ_modus = aufbau.modus_lesen();
|
|
|
|
|
if (modus <= 1)
|
|
|
|
|
{
|
|
|
|
|
// nichts tun
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
clearInterval(intervall); intervall = null;
|
|
|
|
|
}
|
|
|
|
|
aktualisieren();
|
|
|
|
|
}
|
|
|
|
|
,
|
|
|
|
|
500
|
|
|
|
|
)
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
;
|
|
|
|
|
document.querySelector("#knopf_anhalten").addEventListener
|
|
|
|
|
(
|
|
|
|
|
"click",
|
|
|
|
|
event =>
|
|
|
|
|
{
|
|
|
|
|
clearInterval(intervall); intervall = null;
|
|
|
|
|
}
|
|
|
|
|
)
|
2017-11-08 18:41:56 +01:00
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author kcf <vidofnir@folksprak.org>
|
|
|
|
|
*/
|
|
|
|
|
function eingang_web() : void
|
|
|
|
|
{
|
|
|
|
|
document.addEventListener
|
|
|
|
|
(
|
|
|
|
|
"DOMContentLoaded",
|
|
|
|
|
event => {haupt();}
|
|
|
|
|
)
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|