diff --git a/makefile b/makefile index e1d0619..81300f9 100644 --- a/makefile +++ b/makefile @@ -52,11 +52,14 @@ ${dir_erzeugnis}/vtm.dat.js: \ ${dir_erzeugnis}/vtm.js: \ ${dir_quelldatein}/basis/typen.ts \ ${dir_quelldatein}/basis/fehlermonade.ts \ + ${dir_quelldatein}/basis/aufruf.ts \ ${dir_quelldatein}/helfer/verschiedenes.ts \ ${dir_quelldatein}/helfer/mathematik.ts \ ${dir_quelldatein}/helfer/vektor.ts \ ${dir_quelldatein}/helfer/hashmap.ts \ - ${dir_quelldatein}/helfer/xmlknoten.ts \ + ${dir_quelldatein}/helfer/xmlknoten/_xmlknoten.ts \ + ${dir_quelldatein}/helfer/xmlknoten/text.ts \ + ${dir_quelldatein}/helfer/xmlknoten/normal.ts \ ${dir_quelldatein}/helfer/uebersetzung.ts \ ${dir_quelldatein}/daten.ts \ ${dir_quelldatein}/aufbau/richtung.ts \ @@ -64,21 +67,20 @@ ${dir_erzeugnis}/vtm.js: \ ${dir_quelldatein}/aufbau/stelle.ts \ ${dir_quelldatein}/aufbau/zustand.ts \ ${dir_quelldatein}/aufbau/figur.ts \ + ${dir_quelldatein}/aufbau/aktoren/_aktor.ts \ ${dir_quelldatein}/aufbau/aktoren/erzeuger.ts \ ${dir_quelldatein}/aufbau/aktoren/annehmer.ts \ ${dir_quelldatein}/aufbau/aktoren/verwerfer.ts \ ${dir_quelldatein}/aufbau/aktoren/befoerderer.ts \ ${dir_quelldatein}/aufbau/aktoren/schreiber.ts \ ${dir_quelldatein}/aufbau/aktoren/leser.ts \ - ${dir_quelldatein}/aufbau/aktoren/aktor.ts \ ${dir_quelldatein}/aufbau/welt.ts \ ${dir_quelldatein}/aufbau/aufgaben/test.ts \ ${dir_quelldatein}/aufbau/aufgaben/akzeptortest.ts \ ${dir_quelldatein}/aufbau/aufgaben/transduktortest.ts \ - ${dir_quelldatein}/aufbau/aufgaben/aufgabe.ts \ ${dir_quelldatein}/aufbau/aufgaben/akzeptoraufgabe.ts \ ${dir_quelldatein}/aufbau/aufgaben/transduktoraufgabe.ts \ - ${dir_quelldatein}/aufbau/aufgaben/aufgabe_.ts \ + ${dir_quelldatein}/aufbau/aufgaben/aufgabe.ts \ ${dir_quelldatein}/aufbau/modus.ts \ ${dir_quelldatein}/aufbau/partie.ts \ ${dir_quelldatein}/manifestation/manifestation.ts \ @@ -95,11 +97,14 @@ ${dir_erzeugnis}/vtm.js: \ @ ${cmd_tsc} \ ${dir_quelldatein}/basis/typen.ts \ ${dir_quelldatein}/basis/fehlermonade.ts \ + ${dir_quelldatein}/basis/aufruf.ts \ ${dir_quelldatein}/helfer/verschiedenes.ts \ ${dir_quelldatein}/helfer/mathematik.ts \ ${dir_quelldatein}/helfer/vektor.ts \ ${dir_quelldatein}/helfer/hashmap.ts \ - ${dir_quelldatein}/helfer/xmlknoten.ts \ + ${dir_quelldatein}/helfer/xmlknoten/_xmlknoten.ts \ + ${dir_quelldatein}/helfer/xmlknoten/text.ts \ + ${dir_quelldatein}/helfer/xmlknoten/normal.ts \ ${dir_quelldatein}/helfer/uebersetzung.ts \ ${dir_quelldatein}/daten.ts \ ${dir_quelldatein}/aufbau/richtung.ts \ @@ -107,21 +112,20 @@ ${dir_erzeugnis}/vtm.js: \ ${dir_quelldatein}/aufbau/stelle.ts \ ${dir_quelldatein}/aufbau/zustand.ts \ ${dir_quelldatein}/aufbau/figur.ts \ + ${dir_quelldatein}/aufbau/aktoren/_aktor.ts \ ${dir_quelldatein}/aufbau/aktoren/erzeuger.ts \ ${dir_quelldatein}/aufbau/aktoren/annehmer.ts \ ${dir_quelldatein}/aufbau/aktoren/verwerfer.ts \ ${dir_quelldatein}/aufbau/aktoren/befoerderer.ts \ ${dir_quelldatein}/aufbau/aktoren/schreiber.ts \ ${dir_quelldatein}/aufbau/aktoren/leser.ts \ - ${dir_quelldatein}/aufbau/aktoren/aktor.ts \ ${dir_quelldatein}/aufbau/welt.ts \ ${dir_quelldatein}/aufbau/aufgaben/test.ts \ ${dir_quelldatein}/aufbau/aufgaben/akzeptortest.ts \ ${dir_quelldatein}/aufbau/aufgaben/transduktortest.ts \ - ${dir_quelldatein}/aufbau/aufgaben/aufgabe.ts \ ${dir_quelldatein}/aufbau/aufgaben/akzeptoraufgabe.ts \ ${dir_quelldatein}/aufbau/aufgaben/transduktoraufgabe.ts \ - ${dir_quelldatein}/aufbau/aufgaben/aufgabe_.ts \ + ${dir_quelldatein}/aufbau/aufgaben/aufgabe.ts \ ${dir_quelldatein}/aufbau/modus.ts \ ${dir_quelldatein}/aufbau/partie.ts \ ${dir_quelldatein}/manifestation/manifestation.ts \ diff --git a/quelldatein/aufbau/aktoren/_aktor.ts b/quelldatein/aufbau/aktoren/_aktor.ts new file mode 100644 index 0000000..252042a --- /dev/null +++ b/quelldatein/aufbau/aktoren/_aktor.ts @@ -0,0 +1,103 @@ +/* + * 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_aufbau + { + + /** + * @author kcf + */ + export type typ_aktor = typ_komplex; + + + /** + * @author kcf + */ + export type schnittstelle_aktor = + { + beispiel : ()=>typ_aktor; + drehen : (aktor : typ_aktor, inkrement : int)=>void; + verwenden : (aktor : typ_aktor, figur : typ_figur)=>void; + exportieren : (aktor : typ_aktor)=>any; + importieren : (roh : any)=>typ_aktor; + } + ; + + + /** + * @author kcf + */ + export var implementierung_aktor : {[art : string] : schnittstelle_aktor} = {}; + + + /** + * @author kcf + */ + export function aktor_erstellen(art : string, kern : any) : typ_aktor + { + return {"art": art, "angaben": kern}; + } + + + /** + * @author kcf + */ + export function aktor_beispiel(art : string) : typ_aktor + { + return implementierung_aktor[art].beispiel(); + } + + + /** + * @author kcf + */ + export function aktor_drehen(aktor : typ_aktor, inkrement ?: int) : void + { + return implementierung_aktor[aktor.art].drehen(aktor, inkrement); + } + + + /** + * @author kcf + */ + export function aktor_verwenden(aktor : typ_aktor, figur : typ_figur) : void + { + return implementierung_aktor[aktor.art].verwenden(aktor, figur); + } + + + /** + * @author kcf + */ + export function aktor_exportieren(aktor : typ_aktor) : any + { + return implementierung_aktor[aktor.art].exportieren(aktor); + } + + + /** + * @author kcf + */ + export function aktor_importieren(roh : any) : typ_aktor + { + return implementierung_aktor[roh.art].importieren(roh); + } + + } + + diff --git a/quelldatein/aufbau/aktoren/aktor.ts b/quelldatein/aufbau/aktoren/aktor.ts deleted file mode 100644 index 19d9fc4..0000000 --- a/quelldatein/aufbau/aktoren/aktor.ts +++ /dev/null @@ -1,329 +0,0 @@ -/* - * 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_aufbau - { - - /** - * @author kcf - */ - export type typ_aktor = - { - art : string; - angaben ?: any; - } - ; - - - /** - * @author kcf - */ - export function aktor_erstellen - ( - art : string, - angaben : any = {} - ) - : typ_aktor - { - switch (art) - { - case "erzeuger": - { - return { - "art": art, - "angaben": aktor_erzeuger_erstellen(angaben["richtung"]), - }; - break; - } - case "annehmer": - { - return { - "art": art, - "angaben": aktor_annehmer_erstellen(), - }; - break; - } - case "verwerfer": - { - return { - "art": art, - "angaben": aktor_verwerfer_erstellen(), - }; - break; - } - case "befoerderer": - { - return { - "art": art, - "angaben": aktor_befoerderer_erstellen(angaben["richtung"]), - }; - break; - } - case "schreiber": - { - return { - "art": art, - "angaben": aktor_schreiber_erstellen(angaben["richtung"], angaben["symbol"]), - }; - break; - } - case "leser": - { - return { - "art": art, - "angaben": aktor_leser_erstellen(angaben["richtung"], angaben["symbol_links"], angaben["symbol_rechts"]), - }; - break; - } - default: - { - let meldung : string = "unbehandelte Art"; - throw (new Error(meldung)); - break; - } - } - } - - - /** - * @author kcf - */ - export function aktor_drehen - ( - aktor : typ_aktor, - inkrement ?: int - ) - : void - { - switch (aktor.art) - { - case "erzeuger": - { - return aktor_erzeuger_drehen(aktor.angaben, inkrement); - break; - } - case "annehmer": - { - return aktor_annehmer_drehen(aktor.angaben, inkrement); - break; - } - case "verwerfer": - { - return aktor_verwerfer_drehen(aktor.angaben, inkrement); - break; - } - case "befoerderer": - { - return aktor_befoerderer_drehen(aktor.angaben, inkrement); - break; - } - case "schreiber": - { - return aktor_schreiber_drehen(aktor.angaben, inkrement); - break; - } - case "leser": - { - return aktor_leser_drehen(aktor.angaben, inkrement); - break; - } - default: - { - let meldung : string = "unbehandelt"; - throw (new Error(meldung)); - break; - } - } - } - - - /** - * @author kcf - */ - export function aktor_verwenden - ( - aktor : typ_aktor, - figur : typ_figur - ) - : void - { - switch (aktor.art) - { - case "erzeuger": - { - return aktor_erzeuger_verwenden(aktor.angaben, figur); - break; - } - case "annehmer": - { - return aktor_annehmer_verwenden(aktor.angaben, figur); - break; - } - case "verwerfer": - { - return aktor_verwerfer_verwenden(aktor.angaben, figur); - break; - } - case "befoerderer": - { - return aktor_befoerderer_verwenden(aktor.angaben, figur); - break; - } - case "schreiber": - { - return aktor_schreiber_verwenden(aktor.angaben, figur); - break; - } - case "leser": - { - return aktor_leser_verwenden(aktor.angaben, figur); - break; - } - default: - { - let meldung : string = "unbehandelt"; - throw (new Error(meldung)); - break; - } - } - } - - - - /** - * @author kcf - */ - export function aktor_exportieren - ( - aktor : typ_aktor - ) - : any - { - switch (aktor.art) - { - case "erzeuger": - { - return aktor_erzeuger_exportieren(aktor.angaben); - break; - } - case "annehmer": - { - return aktor_annehmer_exportieren(aktor.angaben); - break; - } - case "verwerfer": - { - return aktor_verwerfer_exportieren(aktor.angaben); - break; - } - case "befoerderer": - { - return aktor_befoerderer_exportieren(aktor.angaben); - break; - } - case "schreiber": - { - return aktor_schreiber_exportieren(aktor.angaben); - break; - } - case "leser": - { - return aktor_leser_exportieren(aktor.angaben); - break; - } - default: - { - let meldung : string = "unbehandelt"; - throw (new Error(meldung)); - break; - } - } - } - - - /** - * @author kcf - */ - export function aktor_importieren - ( - roh : any - ) - : typ_aktor - { - switch (roh["art"]) - { - case "erzeuger": - { - return { - "art": roh["art"], - "angaben": aktor_erzeuger_importieren(roh["angaben"]), - }; - break; - } - case "annehmer": - { - return { - "art": roh["art"], - "angaben": aktor_annehmer_importieren(roh["angaben"]), - }; - break; - } - case "verwerfer": - { - return { - "art": roh["art"], - "angaben": aktor_verwerfer_importieren(roh["angaben"]), - }; - break; - } - case "befoerderer": - { - return { - "art": roh["art"], - "angaben": aktor_befoerderer_importieren(roh["angaben"]), - }; - break; - } - case "schreiber": - { - return { - "art": roh["art"], - "angaben": aktor_schreiber_importieren(roh["angaben"]), - }; - break; - } - case "leser": - { - return { - "art": roh["art"], - "angaben": aktor_leser_importieren(roh["angaben"]), - }; - break; - } - default: - { - let meldung : string = "unbehandelte Art"; - throw (new Error(meldung)); - break; - } - } - } - - } - - diff --git a/quelldatein/aufbau/aktoren/annehmer.ts b/quelldatein/aufbau/aktoren/annehmer.ts index 241b47e..552c29f 100644 --- a/quelldatein/aufbau/aktoren/annehmer.ts +++ b/quelldatein/aufbau/aktoren/annehmer.ts @@ -3,16 +3,16 @@ * 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 export function aktor_annehmer_License as published by + * 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 export function aktor_annehmer_License for more details. + * GNU General Public License for more details. * - * You should have received a copy of the GNU General export function aktor_annehmer_License + * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -22,7 +22,7 @@ module mod_vtm_aufbau /** * @author kcf */ - export type typ_aktor_annehmer = + export type typ_annehmer = { } ; @@ -31,10 +31,10 @@ module mod_vtm_aufbau /** * @author kcf */ - export function aktor_annehmer_erstellen + function annehmer_erstellen ( ) - : typ_aktor_annehmer + : typ_annehmer { return { }; @@ -44,7 +44,36 @@ module mod_vtm_aufbau /** * @author kcf */ - export function aktor_annehmer_drehen(aktor_annehmer : typ_aktor_annehmer, inkrement ?: int) : void + export function annehmer_erstellen_aktor + ( + ) + : typ_aktor + { + return {"art": "annehmer", "angaben": annehmer_erstellen()}; + } + + + /** + * @author kcf + */ + function annehmer_beispiel + ( + ) + : typ_annehmer + { + return annehmer_erstellen(); + } + + + /** + * @author kcf + */ + function annehmer_drehen + ( + annehmer : typ_annehmer, + inkrement ?: int + ) + : void { } @@ -52,7 +81,12 @@ module mod_vtm_aufbau /** * @author kcf */ - export function aktor_annehmer_verwenden(aktor_annehmer : typ_aktor_annehmer, figur : typ_figur) : void + function annehmer_verwenden + ( + annehmer : typ_annehmer, + figur : typ_figur + ) + : void { figur_annehmen(figur); } @@ -61,7 +95,11 @@ module mod_vtm_aufbau /** * @author kcf */ - export function aktor_annehmer_exportieren(aktor_annehmer : typ_aktor_annehmer) : any + function annehmer_exportieren + ( + annehmer : typ_annehmer + ) + : any { return { }; @@ -71,15 +109,35 @@ module mod_vtm_aufbau /** * @author kcf */ - export function aktor_annehmer_importieren(roh : any) : typ_aktor_annehmer + function annehmer_importieren + ( + roh : any + ) + : typ_annehmer { return ( - aktor_annehmer_erstellen + annehmer_erstellen ( ) ); } + + /** + * @author kcf + */ + let wrap = (angaben => ({"art": "annehmer", "angaben": angaben})); + let unwrap = (aktor => aktor.angaben); + implementierung_aktor["annehmer"] = + { + "beispiel": () => wrap(annehmer_beispiel()), + "drehen": (aktor, inkrement) => annehmer_drehen(unwrap(aktor), inkrement), + "verwenden": (aktor, figur) => annehmer_verwenden(unwrap(aktor), figur), + "exportieren": (aktor) => ({"art": "annehmer_", "angaben": annehmer_exportieren(aktor.angaben)}), + "importieren": (roh) => wrap(annehmer_importieren(roh)), + } + ; + } diff --git a/quelldatein/aufbau/aktoren/befoerderer.ts b/quelldatein/aufbau/aktoren/befoerderer.ts index 6792f2a..388450c 100644 --- a/quelldatein/aufbau/aktoren/befoerderer.ts +++ b/quelldatein/aufbau/aktoren/befoerderer.ts @@ -3,16 +3,16 @@ * 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 export function aktor_befoerderer_License as published by + * 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 export function aktor_befoerderer_License for more details. + * GNU General Public License for more details. * - * You should have received a copy of the GNU General export function aktor_befoerderer_License + * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -22,7 +22,7 @@ module mod_vtm_aufbau /** * @author kcf */ - export type typ_aktor_befoerderer = + export type typ_befoerderer = { richtung : typ_richtung; } @@ -32,7 +32,11 @@ module mod_vtm_aufbau /** * @author kcf */ - export function aktor_befoerderer_erstellen(richtung : typ_richtung = 0) : typ_aktor_befoerderer + function befoerderer_erstellen + ( + richtung : typ_richtung + ) + : typ_befoerderer { return { "richtung": richtung, @@ -43,37 +47,80 @@ module mod_vtm_aufbau /** * @author kcf */ - export function aktor_befoerderer_richtung_lesen(aktor_befoerderer : typ_aktor_befoerderer) : typ_richtung + export function befoerderer_erstellen_aktor + ( + richtung : typ_richtung + ) + : typ_aktor { - return aktor_befoerderer.richtung; + return {"art": "befoerderer", "angaben": befoerderer_erstellen(richtung)}; } /** * @author kcf */ - export function aktor_befoerderer_drehen(aktor_befoerderer : typ_aktor_befoerderer, inkrement : int = +1) : void + function befoerderer_beispiel + ( + ) + : typ_befoerderer { - aktor_befoerderer.richtung = richtung_addieren(aktor_befoerderer.richtung, inkrement); + return befoerderer_erstellen(0); } /** * @author kcf */ - export function aktor_befoerderer_verwenden(aktor_befoerderer : typ_aktor_befoerderer, figur : typ_figur) : void + export function befoerderer_richtung_lesen + ( + befoerderer : typ_befoerderer + ) + : typ_richtung { - figur_bewegen(figur, aktor_befoerderer.richtung); + return befoerderer.richtung; } /** * @author kcf */ - export function aktor_befoerderer_exportieren(aktor_befoerderer : typ_aktor_befoerderer) : any + function befoerderer_drehen + ( + befoerderer : typ_befoerderer, + inkrement : int = +1 + ) + : void + { + befoerderer.richtung = richtung_addieren(befoerderer.richtung, inkrement); + } + + + /** + * @author kcf + */ + function befoerderer_verwenden + ( + befoerderer : typ_befoerderer, + figur : typ_figur + ) + : void + { + figur_bewegen(figur, befoerderer.richtung); + } + + + /** + * @author kcf + */ + function befoerderer_exportieren + ( + befoerderer : typ_befoerderer + ) + : any { return { - "richtung": richtung_exportieren(aktor_befoerderer.richtung), + "richtung": richtung_exportieren(befoerderer.richtung), }; } @@ -81,16 +128,36 @@ module mod_vtm_aufbau /** * @author kcf */ - export function aktor_befoerderer_importieren(roh : any) : typ_aktor_befoerderer + function befoerderer_importieren + ( + roh : any + ) + : typ_befoerderer { return ( - aktor_befoerderer_erstellen + befoerderer_erstellen ( richtung_importieren(roh["richtung"]) ) ); } + + /** + * @author kcf + */ + let wrap = (angaben => ({"art": "befoerderer", "angaben": angaben})); + let unwrap = (aktor => aktor.angaben); + implementierung_aktor["befoerderer"] = + { + "beispiel": () => wrap(befoerderer_beispiel()), + "drehen": (aktor, inkrement) => befoerderer_drehen(unwrap(aktor), inkrement), + "verwenden": (aktor, figur) => befoerderer_verwenden(unwrap(aktor), figur), + "exportieren": (aktor) => ({"art": "befoerderer", "angaben": befoerderer_exportieren(aktor.angaben)}), + "importieren": (roh) => wrap(befoerderer_importieren(roh)), + } + ; + } diff --git a/quelldatein/aufbau/aktoren/erzeuger.ts b/quelldatein/aufbau/aktoren/erzeuger.ts index 706c7d0..2ff8b9f 100644 --- a/quelldatein/aufbau/aktoren/erzeuger.ts +++ b/quelldatein/aufbau/aktoren/erzeuger.ts @@ -22,7 +22,7 @@ module mod_vtm_aufbau /** * @author kcf */ - export type typ_aktor_erzeuger = + export type typ_erzeuger = { richtung : typ_richtung; } @@ -32,11 +32,11 @@ module mod_vtm_aufbau /** * @author kcf */ - export function aktor_erzeuger_erstellen + function erzeuger_erstellen ( - richtung : typ_richtung = 0 + richtung : typ_richtung ) - : typ_aktor_erzeuger + : typ_erzeuger { return { "richtung": richtung, @@ -47,55 +47,80 @@ module mod_vtm_aufbau /** * @author kcf */ - export function aktor_erzeuger_richtung_lesen + export function erzeuger_erstellen_aktor ( - aktor_erzeuger : typ_aktor_erzeuger + richtung : typ_richtung ) - : typ_richtung + : typ_aktor { - return aktor_erzeuger.richtung; + return {"art": "erzeuger", "angaben": erzeuger_erstellen(richtung)}; } /** * @author kcf */ - export function aktor_erzeuger_drehen + function erzeuger_beispiel ( - aktor_erzeuger : typ_aktor_erzeuger, + ) + : typ_erzeuger + { + return erzeuger_erstellen(0); + } + + + /** + * @author kcf + */ + export function erzeuger_richtung_lesen + ( + erzeuger : typ_erzeuger + ) + : typ_richtung + { + return erzeuger.richtung; + } + + + /** + * @author kcf + */ + function erzeuger_drehen + ( + erzeuger : typ_erzeuger, inkrement : int = +1 ) : void { - aktor_erzeuger.richtung = richtung_addieren(aktor_erzeuger.richtung, inkrement); + erzeuger.richtung = richtung_addieren(erzeuger.richtung, inkrement); } /** * @author kcf */ - export function aktor_erzeuger_verwenden + function erzeuger_verwenden ( - aktor_erzeuger : typ_aktor_erzeuger, + erzeuger : typ_erzeuger, figur : typ_figur ) : void { - figur_bewegen(figur, aktor_erzeuger.richtung); + figur_bewegen(figur, erzeuger.richtung); } /** * @author kcf */ - export function aktor_erzeuger_exportieren + function erzeuger_exportieren ( - aktor_erzeuger : typ_aktor_erzeuger + erzeuger : typ_erzeuger ) : any { return { - "richtung": richtung_exportieren(aktor_erzeuger.richtung), + "richtung": richtung_exportieren(erzeuger.richtung), }; } @@ -103,20 +128,36 @@ module mod_vtm_aufbau /** * @author kcf */ - export function aktor_erzeuger_importieren + function erzeuger_importieren ( roh : any ) - : typ_aktor_erzeuger + : typ_erzeuger { return ( - aktor_erzeuger_erstellen + erzeuger_erstellen ( richtung_importieren(roh["richtung"]) ) ); } + + /** + * @author kcf + */ + let wrap = (angaben => ({"art": "erzeuger", "angaben": angaben})); + let unwrap = (aktor => aktor.angaben); + implementierung_aktor["erzeuger"] = + { + "beispiel": () => wrap(erzeuger_beispiel()), + "drehen": (aktor, inkrement) => erzeuger_drehen(unwrap(aktor), inkrement), + "verwenden": (aktor, figur) => erzeuger_verwenden(unwrap(aktor), figur), + "exportieren": (aktor) => ({"art": "erzeuger", "angaben": erzeuger_exportieren(aktor.angaben)}), + "importieren": (roh) => wrap(erzeuger_importieren(roh)), + } + ; + } diff --git a/quelldatein/aufbau/aktoren/leser.ts b/quelldatein/aufbau/aktoren/leser.ts index 5e5a7ce..49dbe53 100644 --- a/quelldatein/aufbau/aktoren/leser.ts +++ b/quelldatein/aufbau/aktoren/leser.ts @@ -3,16 +3,16 @@ * 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 export function aktor_leser_License as published by + * 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 export function aktor_leser_License for more details. + * GNU General Public License for more details. * - * You should have received a copy of the GNU General export function aktor_leser_License + * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -22,7 +22,7 @@ module mod_vtm_aufbau /** * @author kcf */ - export type typ_aktor_leser = + export type typ_leser = { "richtung": typ_richtung, "symbol_links": typ_symbol, @@ -34,7 +34,13 @@ module mod_vtm_aufbau /** * @author kcf */ - export function aktor_leser_erstellen(richtung : typ_richtung = 0, symbol_links : typ_symbol = 0, symbol_rechts : typ_symbol = 1) : typ_aktor_leser + function leser_erstellen + ( + richtung : typ_richtung, + symbol_links : typ_symbol, + symbol_rechts : typ_symbol + ) + : typ_leser { return { "richtung": richtung, @@ -47,55 +53,104 @@ module mod_vtm_aufbau /** * @author kcf */ - export function aktor_leser_richtung_lesen(aktor_leser : typ_aktor_leser) : typ_richtung + export function leser_erstellen_aktor + ( + richtung : typ_richtung, + symbol_links : typ_symbol, + symbol_rechts : typ_symbol + ) + : typ_aktor { - return aktor_leser.richtung; + return {"art": "leser", "angaben": leser_erstellen(richtung, symbol_links, symbol_rechts)}; } /** * @author kcf */ - export function aktor_leser_symbol_links_lesen(aktor_leser : typ_aktor_leser) : typ_symbol + function leser_beispiel + ( + ) + : typ_leser { - return aktor_leser.symbol_links; + return leser_erstellen(0, 0, 1); } /** * @author kcf */ - export function aktor_leser_symbol_rechts_lesen(aktor_leser : typ_aktor_leser) : typ_symbol + export function leser_richtung_lesen + ( + leser : typ_leser + ) + : typ_richtung { - return aktor_leser.symbol_rechts; + return leser.richtung; } /** * @author kcf */ - export function aktor_leser_drehen(aktor_leser : typ_aktor_leser, inkrement : int = +1) : void + export function leser_symbol_links_lesen + ( + leser : typ_leser + ) + : typ_symbol { - aktor_leser.richtung = richtung_addieren(aktor_leser.richtung, inkrement); + return leser.symbol_links; } /** * @author kcf */ - export function aktor_leser_verwenden(aktor_leser : typ_aktor_leser, figur : typ_figur) : void + export function leser_symbol_rechts_lesen + ( + leser : typ_leser + ) + : typ_symbol + { + return leser.symbol_rechts; + } + + + /** + * @author kcf + */ + function leser_drehen + ( + leser : typ_leser, + inkrement : int = +1 + ) + : void + { + leser.richtung = richtung_addieren(leser.richtung, inkrement); + } + + + /** + * @author kcf + */ + function leser_verwenden + ( + leser : typ_leser, + figur : typ_figur + ) + : void { let symbol_ : schnittstelle_fehlermonade = figur_lesen(figur); let summand : typ_richtung; if (symbol_.ist_schlicht()) { let symbol : typ_symbol = symbol_.lesen(); - if (symbol === aktor_leser.symbol_links) + if (symbol === leser.symbol_links) { figur_schieben(figur); summand = +2; } - else if (symbol === aktor_leser.symbol_rechts) + else if (symbol === leser.symbol_rechts) { figur_schieben(figur); summand = -2; @@ -109,7 +164,7 @@ module mod_vtm_aufbau { summand = 0; } - let richtung : typ_richtung = richtung_addieren(aktor_leser.richtung, summand); + let richtung : typ_richtung = richtung_addieren(leser.richtung, summand); figur_bewegen(figur, richtung); } @@ -117,12 +172,16 @@ module mod_vtm_aufbau /** * @author kcf */ - export function aktor_leser_exportieren(aktor_leser : typ_aktor_leser) : any + function leser_exportieren + ( + leser : typ_leser + ) + : any { return { - "richtung": richtung_exportieren(aktor_leser.richtung), - "symbol_links": symbol_exportieren(aktor_leser.symbol_links), - "symbol_rechts": symbol_exportieren(aktor_leser.symbol_rechts), + "richtung": richtung_exportieren(leser.richtung), + "symbol_links": symbol_exportieren(leser.symbol_links), + "symbol_rechts": symbol_exportieren(leser.symbol_rechts), }; } @@ -130,10 +189,14 @@ module mod_vtm_aufbau /** * @author kcf */ - export function aktor_leser_importieren(roh : any) : typ_aktor_leser + function leser_importieren + ( + roh : any + ) + : typ_leser { return ( - aktor_leser_erstellen + leser_erstellen ( richtung_importieren(roh["richtung"]), symbol_importieren(roh["symbol_links"]), @@ -142,6 +205,22 @@ module mod_vtm_aufbau ); } + + /** + * @author kcf + */ + let wrap = (angaben => ({"art": "leser", "angaben": angaben})); + let unwrap = (aktor => aktor.angaben); + implementierung_aktor["leser"] = + { + "beispiel": () => wrap(leser_beispiel()), + "drehen": (aktor, inkrement) => leser_drehen(unwrap(aktor), inkrement), + "verwenden": (aktor, figur) => leser_verwenden(unwrap(aktor), figur), + "exportieren": (aktor) => ({"art": "leser", "angaben": leser_exportieren(aktor.angaben)}), + "importieren": (roh) => wrap(leser_importieren(roh)), + } + ; + } diff --git a/quelldatein/aufbau/aktoren/schreiber.ts b/quelldatein/aufbau/aktoren/schreiber.ts index 9ce0ea7..90c222c 100644 --- a/quelldatein/aufbau/aktoren/schreiber.ts +++ b/quelldatein/aufbau/aktoren/schreiber.ts @@ -3,16 +3,16 @@ * 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 export function aktor_schreiber_License as published by + * 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 export function aktor_schreiber_License for more details. + * GNU General Public License for more details. * - * You should have received a copy of the GNU General export function aktor_schreiber_License + * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -22,7 +22,7 @@ module mod_vtm_aufbau /** * @author kcf */ - export type typ_aktor_schreiber = + export type typ_schreiber = { richtung : typ_richtung; symbol : typ_symbol; @@ -33,60 +33,16 @@ module mod_vtm_aufbau /** * @author kcf */ - export function aktor_schreiber_erstellen(richtung : typ_richtung = 0, symbol : typ_symbol = 0) : typ_aktor_schreiber + function schreiber_erstellen + ( + richtung : typ_richtung, + symbol : typ_symbol + ) + : typ_schreiber { return { "richtung": richtung, "symbol": symbol, - } - } - - - /** - * @author kcf - */ - export function aktor_schreiber_richtung_lesen(aktor_schreiber : typ_aktor_schreiber) : typ_richtung - { - return aktor_schreiber.richtung; - } - - - /** - * @author kcf - */ - export function aktor_schreiber_symbol_lesen(aktor_schreiber : typ_aktor_schreiber) : typ_symbol - { - return aktor_schreiber.symbol; - } - - - /** - * @author kcf - */ - export function aktor_schreiber_drehen(aktor_schreiber : typ_aktor_schreiber, inkrement : int = +1) : void - { - aktor_schreiber.richtung = richtung_addieren(aktor_schreiber.richtung, inkrement); - } - - - /** - * @author kcf - */ - export function aktor_schreiber_verwenden(aktor_schreiber : typ_aktor_schreiber, figur : typ_figur) : void - { - figur_schreiben(figur, aktor_schreiber.symbol); - figur_bewegen(figur, aktor_schreiber.richtung); - } - - - /** - * @author kcf - */ - export function aktor_schreiber_exportieren(aktor_schreiber : typ_aktor_schreiber) : any - { - return { - "richtung": richtung_exportieren(aktor_schreiber.richtung), - "symbol": symbol_exportieren(aktor_schreiber.symbol), }; } @@ -94,10 +50,111 @@ module mod_vtm_aufbau /** * @author kcf */ - export function aktor_schreiber_importieren(roh : any) : typ_aktor_schreiber + export function schreiber_erstellen_aktor + ( + richtung : typ_richtung, + symbol : typ_symbol + ) + : typ_aktor + { + return {"art": "schreiber", "angaben": schreiber_erstellen(richtung, symbol)}; + } + + + /** + * @author kcf + */ + function schreiber_beispiel + ( + ) + : typ_schreiber + { + return schreiber_erstellen(0, 0); + } + + + /** + * @author kcf + */ + export function schreiber_richtung_lesen + ( + schreiber : typ_schreiber + ) + : typ_richtung + { + return schreiber.richtung; + } + + + /** + * @author kcf + */ + export function schreiber_symbol_lesen + ( + schreiber : typ_schreiber + ) + : typ_symbol + { + return schreiber.symbol; + } + + + /** + * @author kcf + */ + function schreiber_drehen + ( + schreiber : typ_schreiber, + inkrement : int = +1 + ) + : void + { + schreiber.richtung = richtung_addieren(schreiber.richtung, inkrement); + } + + + /** + * @author kcf + */ + function schreiber_verwenden + ( + schreiber : typ_schreiber, + figur : typ_figur + ) + : void + { + figur_schreiben(figur, schreiber.symbol); + figur_bewegen(figur, schreiber.richtung); + } + + + /** + * @author kcf + */ + function schreiber_exportieren + ( + schreiber : typ_schreiber + ) + : any + { + return { + "richtung": richtung_exportieren(schreiber.richtung), + "symbol": symbol_exportieren(schreiber.symbol), + }; + } + + + /** + * @author kcf + */ + function schreiber_importieren + ( + roh : any + ) + : typ_schreiber { return ( - aktor_schreiber_erstellen + schreiber_erstellen ( richtung_importieren(roh["richtung"]), symbol_importieren(roh["symbol"]) @@ -105,6 +162,22 @@ module mod_vtm_aufbau ); } + + /** + * @author kcf + */ + let wrap = (angaben => ({"art": "schreiber", "angaben": angaben})); + let unwrap = (aktor => aktor.angaben); + implementierung_aktor["schreiber"] = + { + "beispiel": () => wrap(schreiber_beispiel()), + "drehen": (aktor, inkrement) => schreiber_drehen(unwrap(aktor), inkrement), + "verwenden": (aktor, figur) => schreiber_verwenden(unwrap(aktor), figur), + "exportieren": (aktor) => ({"art": "schreiber", "angaben": schreiber_exportieren(aktor.angaben)}), + "importieren": (roh) => wrap(schreiber_importieren(roh)), + } + ; + } diff --git a/quelldatein/aufbau/aktoren/verwerfer.ts b/quelldatein/aufbau/aktoren/verwerfer.ts index 4808e8c..cc364f2 100644 --- a/quelldatein/aufbau/aktoren/verwerfer.ts +++ b/quelldatein/aufbau/aktoren/verwerfer.ts @@ -3,16 +3,16 @@ * 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 export function aktor_verwerfer_License as published by + * 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 export function aktor_verwerfer_License for more details. + * GNU General Public License for more details. * - * You should have received a copy of the GNU General export function aktor_verwerfer_License + * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -22,7 +22,7 @@ module mod_vtm_aufbau /** * @author kcf */ - export type typ_aktor_verwerfer = + export type typ_verwerfer = { } ; @@ -31,7 +31,10 @@ module mod_vtm_aufbau /** * @author kcf */ - export function aktor_verwerfer_erstellen() : typ_aktor_verwerfer + function verwerfer_erstellen + ( + ) + : typ_verwerfer { return { }; @@ -41,7 +44,36 @@ module mod_vtm_aufbau /** * @author kcf */ - export function aktor_verwerfer_drehen(aktor_verwerfer : typ_aktor_verwerfer, inkrement ?: int) : void + export function verwerfer_erstellen_aktor + ( + ) + : typ_aktor + { + return {"art": "verwerfer", "angaben": verwerfer_erstellen()}; + } + + + /** + * @author kcf + */ + function verwerfer_beispiel + ( + ) + : typ_verwerfer + { + return verwerfer_erstellen(); + } + + + /** + * @author kcf + */ + function verwerfer_drehen + ( + verwerfer : typ_verwerfer, + inkrement ?: int + ) + : void { } @@ -49,7 +81,12 @@ module mod_vtm_aufbau /** * @author kcf */ - export function aktor_verwerfer_verwenden(aktor_verwerfer : typ_aktor_verwerfer, figur : typ_figur) : void + function verwerfer_verwenden + ( + verwerfer : typ_verwerfer, + figur : typ_figur + ) + : void { figur_verwerfen(figur); } @@ -58,7 +95,11 @@ module mod_vtm_aufbau /** * @author kcf */ - export function aktor_verwerfer_exportieren(aktor_verwerfer : typ_aktor_verwerfer) : any + function verwerfer_exportieren + ( + verwerfer : typ_verwerfer + ) + : any { return { }; @@ -68,15 +109,35 @@ module mod_vtm_aufbau /** * @author kcf */ - export function aktor_verwerfer_importieren(roh : any) : typ_aktor_verwerfer + function verwerfer_importieren + ( + roh : any + ) + : typ_verwerfer { return ( - aktor_verwerfer_erstellen + verwerfer_erstellen ( ) ); } + + /** + * @author kcf + */ + let wrap = (angaben => ({"art": "verwerfer", "angaben": angaben})); + let unwrap = (aktor => aktor.angaben); + implementierung_aktor["verwerfer"] = + { + "beispiel": () => wrap(verwerfer_beispiel()), + "drehen": (aktor, inkrement) => verwerfer_drehen(unwrap(aktor), inkrement), + "verwenden": (aktor, figur) => verwerfer_verwenden(unwrap(aktor), figur), + "exportieren": (aktor) => ({"art": "verwerfer", "angaben": verwerfer_exportieren(aktor.angaben)}), + "importieren": (roh) => wrap(verwerfer_importieren(roh)), + } + ; + } diff --git a/quelldatein/aufbau/aufgaben/akzeptoraufgabe.ts b/quelldatein/aufbau/aufgaben/akzeptoraufgabe.ts index ea8d985..666f46f 100644 --- a/quelldatein/aufbau/aufgaben/akzeptoraufgabe.ts +++ b/quelldatein/aufbau/aufgaben/akzeptoraufgabe.ts @@ -22,85 +22,86 @@ module mod_vtm_aufbau /** * @author kcf */ - export class klasse_akzeptoraufgabe - implements schnittstelle_aufgabe + export type typ_akzeptoraufgabe = { - - /** - * @author kcf - */ - private id : string; - - - /** - * @author kcf - */ - private titel_ : string; - - - /** - * @author kcf - */ - private text_ : string; - - - /** - * @author kcf - */ - private tests_ : Array; - - - /** - * @author kcf - */ - public constructor(id : string, titel : string, text : string, tests : Array) - { - this.id = id; - this.titel_ = titel; - this.text_ = text; - this.tests_ = tests; - } - - - /** - * @author kcf - * @implementation - */ - public id_lesen() : string - { - return this.id; - } - - - /** - * @author kcf - * @implementation - */ - public titel() : string - { - return this.titel_; - } - - - /** - * @author kcf - * @implementation - */ - public text() : string - { - return this.text_; - } - - - /** - * @author kcf - * @implementation - */ - public tests() : Array - { - return this.tests_; - } - + id : string; + titel : string; + text : string; + tests : Array; + } + ; + + + /** + * @author kcf + */ + export function akzeptoraufgabe_erstellen + ( + id : string, + titel : string, + text : string, + tests : Array + ) + : typ_akzeptoraufgabe + { + return { + "id": id, + "titel": titel, + "text": text, + "tests": tests, + }; + } + + + /** + * @author kcf + */ + export function akzeptoraufgabe_id + ( + akzeptoraufgabe : typ_akzeptoraufgabe + ) + : string + { + return akzeptoraufgabe.id; + } + + + /** + * @author kcf + */ + export function akzeptoraufgabe_titel + ( + akzeptoraufgabe : typ_akzeptoraufgabe + ) + : string + { + return akzeptoraufgabe.titel; + } + + + /** + * @author kcf + */ + export function akzeptoraufgabe_text + ( + akzeptoraufgabe : typ_akzeptoraufgabe + ) + : string + { + return akzeptoraufgabe.text; + } + + + /** + * @author kcf + */ + export function akzeptoraufgabe_tests + ( + akzeptoraufgabe : typ_akzeptoraufgabe + ) + : Array + { + return akzeptoraufgabe.tests; } } diff --git a/quelldatein/aufbau/aufgaben/akzeptortest.ts b/quelldatein/aufbau/aufgaben/akzeptortest.ts index 5078ac5..daef64f 100644 --- a/quelldatein/aufbau/aufgaben/akzeptortest.ts +++ b/quelldatein/aufbau/aufgaben/akzeptortest.ts @@ -22,51 +22,56 @@ module mod_vtm_aufbau /** * @author kcf */ - export class klasse_akzeptortest - implements schnittstelle_test + export type typ_akzeptortest = { - - /** - * @author kcf - */ - private eingabe_ : Array; - - - /** - * @author kcf - */ - private annehmen : boolean; - - - /** - * @author kcf - */ - public constructor(eingabe : Array, annehmen : boolean) - { - this.eingabe_ = eingabe; - this.annehmen = annehmen; - } - - - /** - * @author kcf - * @implementation - */ - public eingabe() : Array - { - return this.eingabe_; - } - - - /** - * @author kcf - * @implementation - */ - public pruefen(angenommen : boolean, ausgabe : Array) : boolean - { - return (this.annehmen === angenommen); - } - + eingabe : Array; + annehmen : boolean; + } + ; + + + /** + * @author kcf + */ + export function akzeptortest_erstellen + ( + eingabe : Array, + annehmen : boolean + ) + : typ_akzeptortest + { + return { + "eingabe": eingabe, + "annehmen": annehmen, + }; + } + + + /** + * @author kcf + */ + export function akzeptortest_eingabe + ( + akzeptortest : typ_akzeptortest + ) + : Array + { + return akzeptortest.eingabe; + } + + + /** + * @author kcf + */ + export function akzeptortest_pruefen + ( + akzeptortest : typ_akzeptortest, + angenommen : boolean, + ausgabe : Array + ) + : boolean + { + return (akzeptortest.annehmen === angenommen); } } diff --git a/quelldatein/aufbau/aufgaben/aufgabe.ts b/quelldatein/aufbau/aufgaben/aufgabe.ts index 4ef4b54..bf7a793 100644 --- a/quelldatein/aufbau/aufgaben/aufgabe.ts +++ b/quelldatein/aufbau/aufgaben/aufgabe.ts @@ -22,32 +22,191 @@ module mod_vtm_aufbau /** * @author kcf */ - export interface schnittstelle_aufgabe + export type typ_aufgabe = typ_komplex; + + + /** + * @author kcf + */ + var _liste : Array = []; + + + /** + * @author kcf + */ + export function aufgabe_id + ( + aufgabe : typ_aufgabe + ) + : string { - - /** - * @author kcf - */ - id_lesen() : string; - - - /** - * @author kcf - */ - titel() : string; - - - /** - * @author kcf - */ - text() : string; - - - /** - * @author kcf - */ - tests() : Array; - + return ( + fallunterscheidung + ( + aufgabe, + { + "akzeptoraufgabe": (angaben) => akzeptoraufgabe_id(angaben), + "transduktoraufgabe": (angaben) => transduktoraufgabe_id(angaben), + } + ) + ); + } + + + /** + * @author kcf + */ + export function aufgabe_titel + ( + aufgabe : typ_aufgabe + ) + : string + { + return ( + fallunterscheidung + ( + aufgabe, + { + "akzeptoraufgabe": (angaben) => akzeptoraufgabe_titel(angaben), + "transduktoraufgabe": (angaben) => transduktoraufgabe_titel(angaben), + } + ) + ); + } + + + /** + * @author kcf + */ + export function aufgabe_text + ( + aufgabe : typ_aufgabe + ) + : string + { + return ( + fallunterscheidung + ( + aufgabe, + { + "akzeptoraufgabe": (angaben) => akzeptoraufgabe_text(angaben), + "transduktoraufgabe": (angaben) => transduktoraufgabe_text(angaben), + } + ) + ); + } + + + /** + * @author kcf + */ + export function aufgabe_tests + ( + aufgabe : typ_aufgabe + ) + : Array + { + return ( + fallunterscheidung> + ( + aufgabe, + { + "akzeptoraufgabe": (angaben) => ( + akzeptoraufgabe_tests(angaben) + .map(angaben_ => ({"art": "akzeptortest", "angaben": angaben_})) + ), + "transduktoraufgabe": (angaben) => ( + transduktoraufgabe_tests(angaben) + .map(angaben_ => ({"art": "transduktortest", "angaben": angaben_})) + ), + } + ) + ); + } + + + /** + * @author kcf + */ + export function aufgabe_importieren(aufgabe_roh : any) : typ_aufgabe + { + switch (aufgabe_roh["art"]) + { + case "akzeptor": + { + return { + "art": "akzeptoraufgabe", + "angaben": ( + akzeptoraufgabe_erstellen + ( + aufgabe_roh["id"], + aufgabe_roh["parameter"]["titel"], + aufgabe_roh["parameter"]["text"], + aufgabe_roh["parameter"]["tests"].map + ( + test_roh => ( + akzeptortest_erstellen + ( + test_roh["eingabe"], + test_roh["annehmen"] + ) + ) + ) + ) + ) + }; + break; + } + case "transduktor": + { + return { + "art": "transduktoraufgabe", + "angaben": ( + transduktoraufgabe_erstellen + ( + aufgabe_roh["id"], + aufgabe_roh["parameter"]["titel"], + aufgabe_roh["parameter"]["text"], + aufgabe_roh["parameter"]["tests"].map + ( + test_roh => ( + transduktortest_erstellen + ( + test_roh["eingabe"], + test_roh["ausgabe"] + ) + ) + ) + ) + ) + }; + break; + } + default: + { + let meldung : string = "unbehandelte Art"; + throw (new Error(meldung)); + break; + } + } + } + + + /** + * @author kcf + */ + export function aufgabe_registrieren(aufgabe : typ_aufgabe) : void + { + _liste.push(aufgabe); + } + + + /** + * @author kcf + */ + export function aufgabe_holen(index : int) : typ_aufgabe + { + return _liste[index]; } } diff --git a/quelldatein/aufbau/aufgaben/aufgabe_.ts b/quelldatein/aufbau/aufgaben/aufgabe_.ts deleted file mode 100644 index 9b94236..0000000 --- a/quelldatein/aufbau/aufgaben/aufgabe_.ts +++ /dev/null @@ -1,95 +0,0 @@ -/* - * 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_aufbau - { - - /** - * @author kcf - */ - var _liste : Array = []; - - - /** - * @author kcf - */ - export function aufgabe_erstellen(aufgabe_roh : any) : schnittstelle_aufgabe - { - switch (aufgabe_roh["art"]) - { - case "akzeptor": - { - return ( - new klasse_akzeptoraufgabe - ( - aufgabe_roh["id"], - aufgabe_roh["parameter"]["titel"], - aufgabe_roh["parameter"]["text"], - aufgabe_roh["parameter"]["tests"].map - ( - test_roh => (new klasse_akzeptortest(test_roh["eingabe"], test_roh["annehmen"])) - ) - ) - ); - break; - } - case "transduktor": - { - return ( - new klasse_transduktoraufgabe - ( - aufgabe_roh["id"], - aufgabe_roh["parameter"]["titel"], - aufgabe_roh["parameter"]["text"], - aufgabe_roh["parameter"]["tests"].map - ( - test_roh => (new klasse_transduktortest(test_roh["eingabe"], test_roh["ausgabe"])) - ) - ) - ); - break; - } - default: - { - let meldung : string = "unbehandelte Art"; - throw (new Error(meldung)); - break; - } - } - } - - - /** - * @author kcf - */ - export function aufgabe_registrieren(aufgabe : schnittstelle_aufgabe) : void - { - _liste.push(aufgabe); - } - - - /** - * @author kcf - */ - export function aufgabe_holen(index : int) : schnittstelle_aufgabe - { - return _liste[index]; - } - - } - diff --git a/quelldatein/aufbau/aufgaben/test.ts b/quelldatein/aufbau/aufgaben/test.ts index e9764fc..d86953f 100644 --- a/quelldatein/aufbau/aufgaben/test.ts +++ b/quelldatein/aufbau/aufgaben/test.ts @@ -22,21 +22,100 @@ module mod_vtm_aufbau /** * @author kcf */ - export interface schnittstelle_test + export type typ_test = typ_komplex; + + + /** + * @author kcf + */ + export function test_eingabe + ( + test : typ_test + ) + : Array { - - /** - * @author kcf - * @implementation - */ - eingabe() : Array; - - - /** - * @author kcf - */ - pruefen(angenommen : boolean, ausgabe : Array) : boolean; - + return ( + fallunterscheidung> + ( + test, + { + "akzeptortest": (angaben) => akzeptortest_eingabe(angaben), + "transduktortest": (angaben) => transduktortest_eingabe(angaben), + } + ) + ); + } + + + /** + * @author kcf + */ + export function test_pruefen + ( + test : typ_test, + angenommen : boolean, + ausgabe : Array + ) + : boolean + { + return ( + fallunterscheidung + ( + test, + { + "akzeptortest": (angaben) => akzeptortest_pruefen(angaben, angenommen, ausgabe), + "transduktortest": (angaben) => transduktortest_pruefen(angaben, angenommen, ausgabe), + } + ) + ); + } + + + /** + * @author kcf + */ + export function test_importieren + ( + test_roh : any + ) + : typ_test + { + switch (test_roh["art"]) + { + case "akzeptortest": + { + return { + "art": "akzeptortest", + "angaben": ( + akzeptortest_erstellen + ( + test_roh["angaben"]["eingabe"], + test_roh["angaben"]["annehmen"] + ) + ), + }; + break; + } + case "transduktortest": + { + return { + "art": "transduktortest", + "angaben": ( + transduktortest_erstellen + ( + test_roh["angaben"]["eingabe"], + test_roh["angaben"]["ausgabe"] + ) + ), + }; + break; + } + default: + { + throw (new Error("unbehandelt")); + break; + } + } } } diff --git a/quelldatein/aufbau/aufgaben/transduktoraufgabe.ts b/quelldatein/aufbau/aufgaben/transduktoraufgabe.ts index 9fdec85..2073374 100644 --- a/quelldatein/aufbau/aufgaben/transduktoraufgabe.ts +++ b/quelldatein/aufbau/aufgaben/transduktoraufgabe.ts @@ -22,85 +22,86 @@ module mod_vtm_aufbau /** * @author kcf */ - export class klasse_transduktoraufgabe - implements schnittstelle_aufgabe + export type typ_transduktoraufgabe = { - - /** - * @author kcf - */ - private id : string; - - - /** - * @author kcf - */ - private titel_ : string; - - - /** - * @author kcf - */ - private text_ : string; - - - /** - * @author kcf - */ - private tests_ : Array; - - - /** - * @author kcf - */ - public constructor(id : string, titel : string, text : string, tests : Array) - { - this.id = id; - this.titel_ = titel; - this.text_ = text; - this.tests_ = tests; - } - - - /** - * @author kcf - * @implementation - */ - public id_lesen() : string - { - return this.id; - } - - - /** - * @author kcf - * @implementation - */ - public titel() : string - { - return this.titel_; - } - - - /** - * @author kcf - * @implementation - */ - public text() : string - { - return this.text_; - } - - - /** - * @author kcf - * @implementation - */ - public tests() : Array - { - return this.tests_; - } - + id : string; + titel : string; + text : string; + tests : Array; + } + ; + + + /** + * @author kcf + */ + export function transduktoraufgabe_erstellen + ( + id : string, + titel : string, + text : string, + tests : Array + ) + : typ_transduktoraufgabe + { + return { + "id": id, + "titel": titel, + "text": text, + "tests": tests, + }; + } + + + /** + * @author kcf + */ + export function transduktoraufgabe_id + ( + transduktoraufgabe : typ_transduktoraufgabe + ) + : string + { + return transduktoraufgabe.id; + } + + + /** + * @author kcf + */ + export function transduktoraufgabe_titel + ( + transduktoraufgabe : typ_transduktoraufgabe + ) + : string + { + return transduktoraufgabe.titel; + } + + + /** + * @author kcf + */ + export function transduktoraufgabe_text + ( + transduktoraufgabe : typ_transduktoraufgabe + ) + : string + { + return transduktoraufgabe.text; + } + + + /** + * @author kcf + */ + export function transduktoraufgabe_tests + ( + transduktoraufgabe : typ_transduktoraufgabe + ) + : Array + { + return transduktoraufgabe.tests; } } diff --git a/quelldatein/aufbau/aufgaben/transduktortest.ts b/quelldatein/aufbau/aufgaben/transduktortest.ts index 28c8ba3..a2701c9 100644 --- a/quelldatein/aufbau/aufgaben/transduktortest.ts +++ b/quelldatein/aufbau/aufgaben/transduktortest.ts @@ -22,72 +22,77 @@ module mod_vtm_aufbau /** * @author kcf */ - export class klasse_transduktortest - implements schnittstelle_test + export type typ_transduktortest = { - - /** - * @author kcf - */ - private eingabe_ : Array; - - - /** - * @author kcf - */ - private ausgabe : Array; - - - /** - * @author kcf - */ - public constructor(eingabe : Array, ausgabe : Array) - { - this.eingabe_ = eingabe; - this.ausgabe = ausgabe; - } - - - /** - * @author kcf - * @implementation - */ - public eingabe() : Array - { - return this.eingabe_; - } - - - /** - * @author kcf - * @implementation - */ - public pruefen(angenommen : boolean, ausgabe : Array) : boolean - { - if (this.ausgabe.length !== ausgabe.length) - { - return false; - } - else - { - let gleich : boolean = true; - for (let index : int = 0; index < this.ausgabe.length; index += 1) - { - if (! symbol_vergleichen(this.ausgabe[index], ausgabe[index])) - { - gleich = false; - break; - } - else - { - // nichts tun - } - } - return gleich; - } - } - + eingabe : Array; + ausgabe : Array; + } + ; + + + /** + * @author kcf + */ + export function transduktortest_erstellen + ( + eingabe : Array, + ausgabe : Array + ) + : typ_transduktortest + { + return { + "eingabe": eingabe, + "ausgabe": ausgabe, + }; } + + /** + * @author kcf + */ + export function transduktortest_eingabe + ( + transduktortest : typ_transduktortest + ) + : Array + { + return transduktortest.eingabe; + } + + + /** + * @author kcf + */ + export function transduktortest_pruefen + ( + transduktortest : typ_transduktortest, + angenommen : boolean, + ausgabe : Array + ) + : boolean + { + if (transduktortest.ausgabe.length !== ausgabe.length) + { + return false; + } + else + { + let gleich : boolean = true; + for (let index : int = 0; index < transduktortest.ausgabe.length; index += 1) + { + if (! symbol_vergleichen(transduktortest.ausgabe[index], ausgabe[index])) + { + gleich = false; + break; + } + else + { + // nichts tun + } + } + return gleich; + } + } + } diff --git a/quelldatein/aufbau/partie.ts b/quelldatein/aufbau/partie.ts index 2901ec3..601e7f3 100644 --- a/quelldatein/aufbau/partie.ts +++ b/quelldatein/aufbau/partie.ts @@ -26,7 +26,7 @@ module mod_vtm_aufbau { welt : typ_welt; figur : schnittstelle_fehlermonade; - aufgabe : schnittstelle_aufgabe; + aufgabe : typ_aufgabe; testindex : schnittstelle_fehlermonade; modus : typ_modus; lauscher : {[ereignis : string] : Array<(angaben ?: any)=>void>}; @@ -39,7 +39,7 @@ module mod_vtm_aufbau */ export function partie_erstellen ( - aufgabe : schnittstelle_aufgabe + aufgabe : typ_aufgabe ) : typ_partie { @@ -127,7 +127,7 @@ module mod_vtm_aufbau /** * @author kcf */ - export function partie_aufgabe_lesen(partie : typ_partie) : schnittstelle_aufgabe + export function partie_aufgabe_lesen(partie : typ_partie) : typ_aufgabe { return partie.aufgabe; } @@ -136,7 +136,7 @@ module mod_vtm_aufbau /** * @author kcf */ - export function partie_aufgabe_setzen(partie : typ_partie, aufgabe : schnittstelle_aufgabe) : void + export function partie_aufgabe_setzen(partie : typ_partie, aufgabe : typ_aufgabe) : void { partie.aufgabe = aufgabe; // partie.welt_leeren(); @@ -272,8 +272,8 @@ module mod_vtm_aufbau { if (! partie.figur.ist_schlicht()) { - let test : schnittstelle_test = partie.aufgabe.tests()[partie.testindex.lesen()]; - let band : Array = mod_vtm_helfer.liste_kopieren(test.eingabe()); + let test : typ_test = aufgabe_tests(partie.aufgabe)[partie.testindex.lesen()]; + let band : Array = mod_vtm_helfer.liste_kopieren(test_eingabe(test)); let stelle : typ_stelle = welt_erzeuger_finden(partie.welt); partie.figur = ( new klasse_schlicht @@ -291,7 +291,7 @@ module mod_vtm_aufbau let figur : typ_figur = partie.figur.lesen(); let stelle : typ_stelle = figur_stelle_lesen(figur); let aktor_ : schnittstelle_fehlermonade = welt_feld_holen(partie.welt, stelle); - let aktor : typ_aktor = (aktor_.ist_schlicht() ? aktor_.lesen() : aktor_erstellen("verwerfer", {})); + let aktor : typ_aktor = (aktor_.ist_schlicht() ? aktor_.lesen() : verwerfer_erstellen_aktor()); aktor_verwenden(aktor, figur); let zustand : typ_zustand = figur_zustand_lesen(figur); if (zustand === zustand_laufend) @@ -304,9 +304,9 @@ module mod_vtm_aufbau let ausgabe : Array = figur_band_lesen(figur); partie.figur = (new klasse_nichts()); let testindex : int = partie.testindex.lesen(); - let tests : Array = partie.aufgabe.tests(); - let test : schnittstelle_test = tests[testindex]; - if (! test.pruefen(angenommen, ausgabe)) + let tests : Array = aufgabe_tests(partie.aufgabe); + let test : typ_test = tests[testindex]; + if (! test_pruefen(test, angenommen, ausgabe)) { partie.modus = modus_fehlerhaft; partie_benachrichtigen(partie, "aenderung_modus", {}); diff --git a/quelldatein/aufbau/welt.ts b/quelldatein/aufbau/welt.ts index 31bcb2f..db1902b 100644 --- a/quelldatein/aufbau/welt.ts +++ b/quelldatein/aufbau/welt.ts @@ -90,7 +90,7 @@ module mod_vtm_aufbau [ { "pruefer": (aktor) => (aktor.art === "befoerderer"), - "ersteller": () => aktor_erstellen("befoerderer"), + "ersteller": () => befoerderer_erstellen_aktor(0), }, ] ) @@ -104,7 +104,7 @@ module mod_vtm_aufbau { if (aktor.art === "schreiber") { - return (aktor_schreiber_symbol_lesen(aktor.angaben) === symbol); + return (schreiber_symbol_lesen(aktor.angaben) === symbol); } else { @@ -112,7 +112,7 @@ module mod_vtm_aufbau } } , - "ersteller": () => aktor_erstellen("schreiber", {"richtung": 0, "symbol": symbol}) + "ersteller": () => schreiber_erstellen_aktor(0, symbol) } ) ) @@ -132,9 +132,9 @@ module mod_vtm_aufbau if (aktor.art === "leser") { return ( - (aktor_leser_symbol_links_lesen(aktor.angaben) === symbol_links) + (leser_symbol_links_lesen(aktor.angaben) === symbol_links) && - (aktor_leser_symbol_links_lesen(aktor.angaben) === symbol_rechts) + (leser_symbol_rechts_lesen(aktor.angaben) === symbol_rechts) ); } else @@ -143,7 +143,7 @@ module mod_vtm_aufbau } } , - "ersteller": () => aktor_erstellen("leser", {"richtung": 0, "symbol_links": symbol_links, "symbol_rechts": (2*index+1)}), + "ersteller": () => leser_erstellen_aktor(0, symbol_links, symbol_rechts) } ); } @@ -154,32 +154,33 @@ module mod_vtm_aufbau [ { "pruefer": (aktor) => (aktor.art === "verwerfer"), - "ersteller": () => aktor_erstellen("verwerfer"), + "ersteller": () => verwerfer_erstellen_aktor(), }, ] ) ); let index_alt : schnittstelle_fehlermonade; let aktor_alt_ : schnittstelle_fehlermonade = welt.felder.holen(stelle); - if (aktor_alt_.ist_schlicht) + if (aktor_alt_.ist_schlicht()) { let aktor_alt : typ_aktor = aktor_alt_.lesen(); - let gefunden : boolean = liste.some - ( - (eintrag, index) => - { - if (eintrag.pruefer(aktor_alt)) - { - index_alt = (new klasse_schlicht(index)); - return true; - } - else - { - return false; - } - } - ) - ; + let gefunden : boolean = ( + liste.some + ( + (eintrag, index) => + { + if (eintrag.pruefer(aktor_alt)) + { + index_alt = (new klasse_schlicht(index)); + return true; + } + else + { + return false; + } + } + ) + ); if (! gefunden) { index_alt = (new klasse_nichts()); @@ -281,15 +282,15 @@ module mod_vtm_aufbau let aktor : typ_aktor; if ((u === -groesse) && (v === 0)) { - aktor = aktor_erstellen("erzeuger", {"richtung": 0}); + aktor = erzeuger_erstellen_aktor(0); } else if ((u === +groesse) && (v === 0)) { - aktor = aktor_erstellen("annehmer", {}); + aktor = annehmer_erstellen_aktor(); } else { - aktor = aktor_erstellen("verwerfer", {}); + aktor = verwerfer_erstellen_aktor(); } welt.felder.setzen(stelle, aktor); } diff --git a/quelldatein/basis/aufruf.ts b/quelldatein/basis/aufruf.ts new file mode 100644 index 0000000..3b3c4f0 --- /dev/null +++ b/quelldatein/basis/aufruf.ts @@ -0,0 +1,58 @@ +/* + * 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 . + */ + +/** + * @author kcf + */ +type typ_komplex = {art : string; angaben ?: typ_angaben;}; + + +/** + * @author kcf + */ +function fallunterscheidung + ( + komplex : typ_komplex, + faelle : {[art : string] : (angaben ?: any)=>typ_ergebnis}, + ersatz : schnittstelle_fehlermonade<(komplex : typ_komplex)=>typ_ergebnis> = (new klasse_nichts<(komplex : typ_komplex)=>typ_ergebnis>()) + ) + : typ_ergebnis + { + if (komplex.art in faelle) + { + let funktion : (angaben ?: any)=>typ_ergebnis = faelle[komplex.art]; + let ergebnis : typ_ergebnis = funktion(komplex.angaben); + return ergebnis; + } + else + { + let meldung : string = ("unbehandelte Art '" + komplex.art + "'"); + console.warn(meldung); + if (ersatz.ist_schlicht()) + { + let ergebnis : typ_ergebnis = ersatz.lesen()(komplex); + return ergebnis; + } + else + { + throw (new Error("unbehandelt")); + } + } + } + + diff --git a/quelldatein/haupt.ts b/quelldatein/haupt.ts index 1e342e7..871f033 100644 --- a/quelldatein/haupt.ts +++ b/quelldatein/haupt.ts @@ -19,7 +19,7 @@ /** * @author kcf */ -function aufgaben_eintragen(behandler : (aufgabe : mod_vtm_aufbau.schnittstelle_aufgabe)=>void) : void +function aufgaben_eintragen(behandler : (aufgabe : mod_vtm_aufbau.typ_aufgabe)=>void) : void { let aufgaben_roh_ : schnittstelle_fehlermonade> = mod_vtm_daten.lesen("aufgaben"); if (aufgaben_roh_.ist_schlicht()) @@ -32,7 +32,7 @@ function aufgaben_eintragen(behandler : (aufgabe : mod_vtm_aufbau.schnittstelle_ { // Aufgabe registrieren { - let aufgabe : mod_vtm_aufbau.schnittstelle_aufgabe = mod_vtm_aufbau.aufgabe_erstellen(aufgabe_roh); + let aufgabe : mod_vtm_aufbau.typ_aufgabe = mod_vtm_aufbau.aufgabe_importieren(aufgabe_roh); mod_vtm_aufbau.aufgabe_registrieren(aufgabe); } // Option eintragen @@ -60,7 +60,7 @@ function aufgaben_eintragen(behandler : (aufgabe : mod_vtm_aufbau.schnittstelle_ { let value : string = dom_auswahl["value"]; let index : int = parseInt(value); - let aufgabe : mod_vtm_aufbau.schnittstelle_aufgabe = mod_vtm_aufbau.aufgabe_holen(index); + let aufgabe : mod_vtm_aufbau.typ_aufgabe = mod_vtm_aufbau.aufgabe_holen(index); behandler(aufgabe); } ) @@ -115,27 +115,27 @@ function haupt() : void let hoehe : float = 80; [ { - "aufbau": mod_vtm_aufbau.aktor_erstellen("erzeuger"), + "aufbau": mod_vtm_aufbau.aktor_beispiel("erzeuger"), "bereich": document.querySelector("#hilfe_aktoren_aktor_erzeuger"), }, { - "aufbau": mod_vtm_aufbau.aktor_erstellen("annehmer"), + "aufbau": mod_vtm_aufbau.aktor_beispiel("annehmer"), "bereich": document.querySelector("#hilfe_aktoren_aktor_annehmer"), }, { - "aufbau": mod_vtm_aufbau.aktor_erstellen("verwerfer"), + "aufbau": mod_vtm_aufbau.aktor_beispiel("verwerfer"), "bereich": document.querySelector("#hilfe_aktoren_aktor_verwerfer"), }, { - "aufbau": mod_vtm_aufbau.aktor_erstellen("befoerderer"), + "aufbau": mod_vtm_aufbau.aktor_beispiel("befoerderer"), "bereich": document.querySelector("#hilfe_aktoren_aktor_befoerderer"), }, { - "aufbau": mod_vtm_aufbau.aktor_erstellen("schreiber"), + "aufbau": mod_vtm_aufbau.aktor_beispiel("schreiber"), "bereich": document.querySelector("#hilfe_aktoren_aktor_schreiber"), }, { - "aufbau": mod_vtm_aufbau.aktor_erstellen("leser"), + "aufbau": mod_vtm_aufbau.aktor_beispiel("leser"), "bereich": document.querySelector("#hilfe_aktoren_aktor_leser"), }, ] @@ -143,9 +143,23 @@ function haupt() : void ( eintrag => { - let manifestor = (new mod_vtm_manifestation.klasse_svg_aktor(eintrag.aufbau, mod_vtm_aufbau.stelle_null())); - let xmlknoten : mod_vtm_helfer.schnittstelle_xmlknoten = mod_vtm_manifestation.svg_wurzel(von_x, von_y, bis_x, bis_y, breite, hoehe, [manifestor.darstellen()]); - eintrag.bereich.querySelector(".hilfe_aktoren_aktor_bild").innerHTML = xmlknoten.darstellen(); + let manifestor = ( + mod_vtm_manifestation.svg_aktor_erstellen_manifestation + ( + eintrag.aufbau, + mod_vtm_aufbau.stelle_null() + ) + ); + let xmlknoten : mod_vtm_helfer.typ_xmlknoten = ( + mod_vtm_manifestation.svg_wurzel + ( + von_x, von_y, + bis_x, bis_y, + breite, hoehe, + [mod_vtm_manifestation.manifestation_darstellen(manifestor)] + ) + ); + eintrag.bereich.querySelector(".hilfe_aktoren_aktor_bild").innerHTML = mod_vtm_helfer.xmlknoten_darstellen(xmlknoten); } ) ; @@ -154,17 +168,33 @@ function haupt() : void } // Spiel { - let aufbau : mod_vtm_aufbau.typ_partie; + // let aufbau : mod_vtm_aufbau.typ_partie; aufgaben_eintragen ( - function (aufgabe : mod_vtm_aufbau.schnittstelle_aufgabe) : void {mod_vtm_aufbau.partie_aufgabe_setzen(aufbau, aufgabe);} + function (aufgabe : mod_vtm_aufbau.typ_aufgabe) : void {mod_vtm_aufbau.partie_aufgabe_setzen(aufbau, aufgabe);} ) ; aufbau = mod_vtm_aufbau.partie_erstellen(mod_vtm_aufbau.aufgabe_holen(0)); - (new mod_vtm_manifestation.klasse_web_partie(aufbau, document.querySelector("#bereich_mitte"))).einrichten(); - (new mod_vtm_manifestation.klasse_speicher_partie(aufbau)).einrichten(); + mod_vtm_manifestation.manifestation_einrichten + ( + mod_vtm_manifestation.web_partie_erstellen_erweitert + ( + aufbau, + document.querySelector("#bereich_mitte") + ) + ) + ; + mod_vtm_manifestation.manifestation_einrichten + ( + mod_vtm_manifestation.speicher_partie_erstellen_erweitert + ( + aufbau + ) + ) + ; } } +var aufbau : mod_vtm_aufbau.typ_partie = null; /** diff --git a/quelldatein/helfer/xmlknoten.ts b/quelldatein/helfer/xmlknoten.ts deleted file mode 100644 index 769fe4a..0000000 --- a/quelldatein/helfer/xmlknoten.ts +++ /dev/null @@ -1,160 +0,0 @@ -/* - * 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_helfer - { - - /** - * @author kcf - */ - function einrueckung(tiefe : int, zeichen : string = "\t") : string - { - return ((tiefe === 0) ? "" : (zeichen + einrueckung(tiefe-1))); - } - - - /** - * @author kcf - */ - export interface schnittstelle_xmlknoten - { - - /** - * @author kcf - */ - darstellen(tiefe ?: int) : string; - - } - - - /** - * @author kcf - */ - export class klasse_xmlknoten_text - implements schnittstelle_xmlknoten - { - - /** - * @author kcf - */ - private inhalt : string; - - - /** - * @author kcf - */ - public constructor(inhalt : string) - { - this.inhalt = inhalt; - } - - - /** - * @author kcf - * @implementation - */ - public darstellen(tiefe : int = 0) : string - { - return this.inhalt; - } - - } - - - /** - * @author kcf - */ - export class klasse_xmlknoten_normal - implements schnittstelle_xmlknoten - { - - /** - * @author kcf - */ - private name : string; - - - /** - * @author kcf - */ - private attribute : {[schluessel : string] : string} = {}; - - - /** - * @author kcf - */ - private kinder : Array = []; - - - /** - * @author kcf - */ - public constructor(name : string, attribute : {[schluessel : string] : string} = {}, kinder : Array = []) - { - this.name = name; - this.attribute = attribute; - this.kinder = kinder; - } - - - /** - * @author kcf - * @implementation - */ - public darstellen(tiefe : int = 0) : string - { - let str : string = ""; - // anfang - { - let str_anfang : string = ""; - str_anfang += this.name; - // attribute - { - let str_attribute : string = ""; - Object.keys(this.attribute).forEach - ( - schluessel => - { - let wert : string = this.attribute[schluessel]; - str_attribute += (" " + schluessel + "=" + "\"" + wert + "\""); - } - ) - ; - str_anfang += str_attribute; - } - str_anfang = (einrueckung(tiefe) + "<" + str_anfang + ">" + "\n"); - str += str_anfang; - } - // kinder - { - this.kinder.forEach(kind => (str += kind.darstellen(tiefe+1))); - } - // ende - { - let str_ende : string = ""; - str_ende += this.name; - str_ende = (einrueckung(tiefe) + "<" + "/" + str_ende + ">" + "\n"); - str += str_ende; - } - return str; - } - - } - - } - diff --git a/quelldatein/helfer/xmlknoten/_xmlknoten.ts b/quelldatein/helfer/xmlknoten/_xmlknoten.ts new file mode 100644 index 0000000..b3a1c62 --- /dev/null +++ b/quelldatein/helfer/xmlknoten/_xmlknoten.ts @@ -0,0 +1,53 @@ +/* + * 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_helfer + { + + /** + * @author kcf + */ + export type typ_xmlknoten = typ_komplex; + + + /** + * @author kcf + */ + export type schnittstelle_xmlknoten = + { + darstellen : (xmlknoten : typ_xmlknoten, tiefe : int)=>string; + } + ; + + + /** + * @author kcf + */ + export var implementierung_xmlknoten : {[art : string] : schnittstelle_xmlknoten} = {}; + + + /** + * @author kcf + */ + export function xmlknoten_darstellen(xmlknoten : typ_xmlknoten, tiefe : int = 0) : string + { + return implementierung_xmlknoten[xmlknoten.art].darstellen(xmlknoten, tiefe); + } + + } + diff --git a/quelldatein/helfer/xmlknoten/normal.ts b/quelldatein/helfer/xmlknoten/normal.ts new file mode 100644 index 0000000..b070275 --- /dev/null +++ b/quelldatein/helfer/xmlknoten/normal.ts @@ -0,0 +1,132 @@ +/* + * 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_helfer + { + + /** + * @author kcf + */ + function einrueckung(tiefe : int, zeichen : string = "\t") : string + { + return ((tiefe === 0) ? "" : (zeichen + einrueckung(tiefe-1))); + } + + + /** + * @author kcf + */ + export type typ_xmlknoten_normal = + { + name : string; + attribute : {[schluessel : string] : string}; + kinder : Array; + } + ; + + + /** + * @author kcf + */ + function xmlknoten_normal_erstellen + ( + name : string, + attribute : {[schluessel : string] : string} = {}, + kinder : Array = [] + ) + : typ_xmlknoten_normal + { + return { + "name": name, + "attribute": attribute, + "kinder": kinder + }; + } + + + /** + * @author kcf + */ + export function xmlknoten_normal_erstellen_erweitert + ( + name : string, + attribute : {[schluessel : string] : string} = {}, + kinder : Array = [] + ) + : typ_xmlknoten + { + return { + "art": "normal", + "angaben": xmlknoten_normal_erstellen(name, attribute, kinder) + }; + } + + + /** + * @author kcf + */ + function xmlknoten_normal_darstellen(xmlknoten_normal : typ_xmlknoten_normal, tiefe : int) : string + { + let str : string = ""; + // anfang + { + let str_anfang : string = ""; + str_anfang += xmlknoten_normal.name; + // attribute + { + let str_attribute : string = ""; + Object.keys(xmlknoten_normal.attribute).forEach + ( + schluessel => + { + let wert : string = xmlknoten_normal.attribute[schluessel]; + str_attribute += (" " + schluessel + "=" + "\"" + wert + "\""); + } + ) + ; + str_anfang += str_attribute; + } + str_anfang = (einrueckung(tiefe) + "<" + str_anfang + ">" + "\n"); + str += str_anfang; + } + // kinder + { + xmlknoten_normal.kinder.forEach(kind => (str += xmlknoten_darstellen(kind, tiefe+1))); + } + // ende + { + let str_ende : string = ""; + str_ende += xmlknoten_normal.name; + str_ende = (einrueckung(tiefe) + "<" + "/" + str_ende + ">" + "\n"); + str += str_ende; + } + return str; + } + + + /** + * @author kcf + */ + implementierung_xmlknoten["normal"] = + { + "darstellen": (xmlknoten, tiefe) => xmlknoten_normal_darstellen(xmlknoten.angaben, tiefe), + } + ; + + } + diff --git a/quelldatein/helfer/xmlknoten/text.ts b/quelldatein/helfer/xmlknoten/text.ts new file mode 100644 index 0000000..e285df6 --- /dev/null +++ b/quelldatein/helfer/xmlknoten/text.ts @@ -0,0 +1,69 @@ +/* + * 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_helfer + { + + /** + * @author kcf + */ + export type typ_xmlknoten_text = + { + inhalt : string + } + ; + + + /** + * @author kcf + */ + function xmlknoten_text_erstellen(inhalt : string) : typ_xmlknoten_text + { + return {"inhalt": inhalt}; + } + + + /** + * @author kcf + */ + export function xmlknoten_text_erstellen_erweitert(inhalt : string) : typ_xmlknoten + { + return {"art": "text", "angaben": xmlknoten_text_erstellen(inhalt)}; + } + + + /** + * @author kcf + */ + function xmlknoten_text_darstellen(xmlknoten_text : typ_xmlknoten_text, tiefe : int) : string + { + return xmlknoten_text.inhalt; + } + + + /** + * @author kcf + */ + implementierung_xmlknoten["text"] = + { + "darstellen": (xmlknoten, tiefe) => xmlknoten_text_darstellen(xmlknoten.angaben, tiefe), + } + ; + + } + diff --git a/quelldatein/manifestation/manifestation.ts b/quelldatein/manifestation/manifestation.ts index 72653ee..e103ffc 100644 --- a/quelldatein/manifestation/manifestation.ts +++ b/quelldatein/manifestation/manifestation.ts @@ -22,46 +22,52 @@ module mod_vtm_manifestation /** * @author kcf */ - export abstract class klasse_manifestation + export type typ_manifestation = typ_komplex; + + + /** + * @author kcf + */ + export type schnittstelle_manifestation = { - - /** - * @author kcf - */ - protected aufbau : typ_aufbau; - - - /** - * @author kcf - */ - public constructor(aufbau : typ_aufbau) - { - this.aufbau = aufbau; - } - - - /** - * @author kcf - */ - public abstract darstellen() : typ_ausgabe; - - - /** - * @author kcf - */ - public abstract binden() : void; - - - /** - * @author kcf - */ - public einrichten() : void - { - this.darstellen(); - this.binden(); - } - + darstellen : (manifestation : typ_manifestation)=>typ_ausgabe; + binden : (manifestation : typ_manifestation)=>void; } - + ; + + + /** + * @author kcf + */ + export var implementierung_manifestation : {[art : string] : schnittstelle_manifestation} = {}; + + + /** + * @author kcf + */ + export function manifestation_darstellen(manifestation : typ_manifestation) : typ_ausgabe + { + return implementierung_manifestation[manifestation.art].darstellen(manifestation); + } + + + /** + * @author kcf + */ + export function manifestation_binden(manifestation : typ_manifestation) : void + { + return implementierung_manifestation[manifestation.art].binden(manifestation); + } + + + /** + * @author kcf + */ + export function manifestation_einrichten(manifestation : typ_manifestation) : void + { + manifestation_darstellen(manifestation); + manifestation_binden(manifestation); + } + } diff --git a/quelldatein/manifestation/position.ts b/quelldatein/manifestation/position.ts index cb4b3f0..d9f892a 100644 --- a/quelldatein/manifestation/position.ts +++ b/quelldatein/manifestation/position.ts @@ -28,8 +28,8 @@ module mod_vtm_manifestation /** * @author kcf */ - var position_basis1 : typ_position = mod_vtm_helfer.vektor_polar(0/6.0 * (2*Math.PI)); - var position_basis2 : typ_position = mod_vtm_helfer.vektor_polar(2/6.0 * (2*Math.PI)); + var position_basis1 : typ_position = mod_vtm_helfer.vektor_polar((0/6) * (2*Math.PI)); + var position_basis2 : typ_position = mod_vtm_helfer.vektor_polar((2/6) * (2*Math.PI)); /** diff --git a/quelldatein/manifestation/speicher/partie.ts b/quelldatein/manifestation/speicher/partie.ts index ea2393b..deff396 100644 --- a/quelldatein/manifestation/speicher/partie.ts +++ b/quelldatein/manifestation/speicher/partie.ts @@ -22,107 +22,125 @@ module mod_vtm_manifestation /** * @author kcf */ - export class klasse_speicher_partie - extends klasse_manifestation + export type typ_speicher_partie = { - - /** - * @author kcf - */ - public constructor(aufbau : mod_vtm_aufbau.typ_partie) - { - super(aufbau); - } - - - /** - * @author kcf - * @override - */ - public einrichten() : void - { - mod_vtm_aufbau.partie_lauschen - ( - this.aufbau, - "aenderung_aufgabe", - (angaben) => - { - // console.info("aenderung_aufgabe", angaben); - let id : string = mod_vtm_aufbau.partie_aufgabe_lesen(this.aufbau).id_lesen(); - 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.partie_aufgabe_lesen(this.aufbau).id_lesen(); - 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); - } - ) - ; - this.darstellen(); - this.binden(); - } - - - /** - * @author kcf - * @implementation - */ - public darstellen() : void - { - console.warn("empty"); - } - - - - /** - * @author kcf - * @implementation - */ - public binden() : void - { - console.warn("empty"); - } - + 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), + } + ; } diff --git a/quelldatein/manifestation/svg/aktor.ts b/quelldatein/manifestation/svg/aktor.ts index afaaa0c..4a57031 100644 --- a/quelldatein/manifestation/svg/aktor.ts +++ b/quelldatein/manifestation/svg/aktor.ts @@ -22,277 +22,296 @@ module mod_vtm_manifestation /** * @author kcf */ - export class klasse_svg_aktor - extends klasse_manifestation + export type typ_svg_aktor = { - - /** - * @author kcf - */ - private stelle : mod_vtm_aufbau.typ_stelle; - - - /** - * @author kcf - */ - public constructor(aufbau : mod_vtm_aufbau.typ_aktor, stelle : mod_vtm_aufbau.typ_stelle) + aufbau : mod_vtm_aufbau.typ_aktor; + stelle : mod_vtm_aufbau.typ_stelle; + } + ; + + + /** + * @author kcf + */ + function svg_aktor_erstellen + ( + aufbau : mod_vtm_aufbau.typ_aktor, + stelle : mod_vtm_aufbau.typ_stelle + ) + : typ_svg_aktor + { + return { + "aufbau": aufbau, + "stelle": stelle + }; + } + + + /** + * @author kcf + */ + export function svg_aktor_erstellen_manifestation + ( + aufbau : mod_vtm_aufbau.typ_aktor, + stelle : mod_vtm_aufbau.typ_stelle + ) + : typ_manifestation + { + return { + "art": "svg_aktor", + "angaben": svg_aktor_erstellen(aufbau, stelle), + }; + } + + + /** + * @author kcf + */ + function svg_aktor_darstellen(svg_aktor : typ_svg_aktor) : mod_vtm_helfer.typ_xmlknoten + { + let aktor : mod_vtm_aufbau.typ_aktor = svg_aktor.aufbau; + let knoten_rahmen = function () : mod_vtm_helfer.typ_xmlknoten { - super(aufbau); - this.stelle = stelle; - } - - - /** - * @author kcf - * @implementation - */ - public darstellen() : mod_vtm_helfer.schnittstelle_xmlknoten - { - let aktor : mod_vtm_aufbau.typ_aktor = this.aufbau; - let knoten_rahmen = function () : mod_vtm_helfer.schnittstelle_xmlknoten - { - return ( - svg_pfad - ( - mod_vtm_helfer.sequenz(6).map(i => mod_vtm_helfer.vektor_polar(((i+0.5)/6.0) * (2*Math.PI), 0.5)), - true, - { - "class": "rahmen" - } - ) - ); - } - ; - let kinder_feld : Array = []; - switch (aktor.art) - { - case "erzeuger": - { - kinder_feld.push(knoten_rahmen()); - let richtung : mod_vtm_aufbau.typ_richtung = mod_vtm_aufbau.aktor_erzeuger_richtung_lesen(aktor.angaben); - let knoten_pfeil : mod_vtm_helfer.schnittstelle_xmlknoten = ( - new mod_vtm_helfer.klasse_xmlknoten_normal - ( - "path", - { - "d": svg_form_pfeil, - "class": ( - [ - "pfeil", - "erzeuger", - ].join(" ") - ), - "transform": ( - [ - "rotate(" + ((richtung/6.0) * 360).toFixed(svg_float_praezission) + ")", - "translate(-0.2, 0)", - "scale(0.12)", - ].join(" ") - ), - } - ) - ); - kinder_feld.push(knoten_pfeil); - break; - } - case "befoerderer": - { - kinder_feld.push(knoten_rahmen()); - let richtung : mod_vtm_aufbau.typ_richtung = mod_vtm_aufbau.aktor_befoerderer_richtung_lesen(aktor.angaben); - let knoten_pfeil : mod_vtm_helfer.schnittstelle_xmlknoten = ( - new mod_vtm_helfer.klasse_xmlknoten_normal - ( - "path", - { - "d": svg_form_pfeil, - "class": ( - [ - "pfeil", - "neutral", - ].join(" ") - ), - "transform": ( - [ - "rotate(" + ((richtung/6.0) * 360).toFixed(svg_float_praezission) + ")", - "translate(-0.2, 0)", - "scale(0.12)", - ].join(" ") - ), - } - ) - ); - kinder_feld.push(knoten_pfeil); - break; - } - case "schreiber": - { - kinder_feld.push(knoten_rahmen()); - let richtung : mod_vtm_aufbau.typ_richtung = mod_vtm_aufbau.aktor_schreiber_richtung_lesen(aktor.angaben); - let symbol : mod_vtm_aufbau.typ_symbol = mod_vtm_aufbau.aktor_schreiber_symbol_lesen(aktor.angaben); - let knoten_pfeil : mod_vtm_helfer.schnittstelle_xmlknoten = ( - new mod_vtm_helfer.klasse_xmlknoten_normal - ( - "path", - { - "d": svg_form_pfeil, - "class": ( - [ - "pfeil", - "symbol_" + symbol.toFixed(0), - ].join(" ") - ), - "transform": ( - [ - "rotate(" + ((richtung/6.0) * 360).toFixed(svg_float_praezission) + ")", - "translate(-0.2, 0)", - "scale(0.12)", - ].join(" ") - ), - } - ) - ); - kinder_feld.push(knoten_pfeil); - break; - } - case "leser": - { - kinder_feld.push(knoten_rahmen()); - let richtung : mod_vtm_aufbau.typ_richtung = mod_vtm_aufbau.aktor_leser_richtung_lesen(aktor.angaben); - let symbol_links : mod_vtm_aufbau.typ_symbol = mod_vtm_aufbau.aktor_leser_symbol_links_lesen(aktor.angaben); - let symbol_rechts : mod_vtm_aufbau.typ_symbol = mod_vtm_aufbau.aktor_leser_symbol_rechts_lesen(aktor.angaben); - let ausgaenge : Array<{summand : mod_vtm_aufbau.typ_richtung, symbol : schnittstelle_fehlermonade;}> = - [ - { - "summand": 0, - "symbol": new klasse_nichts(), - }, - { - "summand": +2, - "symbol": new klasse_schlicht(symbol_links), - }, - { - "summand": -2, - "symbol": new klasse_schlicht(symbol_rechts), - }, - ] - ; - ausgaenge.forEach - ( - eintrag => - { - let winkel : float = ((mod_vtm_aufbau.richtung_addieren(richtung, eintrag.summand) / 6.0) * 360); - let knoten_pfeil : mod_vtm_helfer.schnittstelle_xmlknoten = ( - new mod_vtm_helfer.klasse_xmlknoten_normal - ( - "path", - { - "d": svg_form_pfeil, - "class": ( - [ - "pfeil", - ( - eintrag.symbol.ist_schlicht() - ? "symbol_" + eintrag.symbol.lesen().toFixed(0) - : "neutral" - ), - ].join(" ") - ), - "transform": ( - [ - - "rotate(" + winkel.toFixed(svg_float_praezission) + ")", - "translate(0.1, 0)", - "scale(0.075)", - ].join(" ") - ), - } - ) - ); - kinder_feld.push(knoten_pfeil); - } - ) - ; - break; - } - case "verwerfer": - { - kinder_feld.push(knoten_rahmen()); - let knoten_kreis : mod_vtm_helfer.schnittstelle_xmlknoten = ( - new mod_vtm_helfer.klasse_xmlknoten_normal - ( - "circle", - { - "cx": (0.0).toFixed(svg_float_praezission), - "cy": (0.0).toFixed(svg_float_praezission), - "r": (0.25).toFixed(svg_float_praezission), - "class": ( - [ - "kreis", - "negativ", - ].join(" ") - ), - } - ) - ); - kinder_feld.push(knoten_kreis); - break; - } - case "annehmer": - { - kinder_feld.push(knoten_rahmen()); - let knoten_kreis : mod_vtm_helfer.schnittstelle_xmlknoten = ( - new mod_vtm_helfer.klasse_xmlknoten_normal - ( - "circle", - { - "cx": (0.0).toFixed(svg_float_praezission), - "cy": (0.0).toFixed(svg_float_praezission), - "r": (0.25).toFixed(svg_float_praezission), - "class": ( - [ - "kreis", - "positiv", - ].join(" ") - ), - } - ) - ); - kinder_feld.push(knoten_kreis); - break; - } - default: - { - let meldung : string = ("unbehandelter Aktor-Typ"); - throw (new Error(meldung)); - break; - } - } - let position : typ_position = position_von_stelle(this.stelle); - let knoten_feld : mod_vtm_helfer.schnittstelle_xmlknoten = ( - new mod_vtm_helfer.klasse_xmlknoten_normal + return ( + svg_pfad ( - "g", + mod_vtm_helfer.sequenz(6).map(i => mod_vtm_helfer.vektor_polar(((i+0.5)/6) * (2*Math.PI), 0.5)), + true, { - "class": "feld", - "rel": mod_vtm_aufbau.stelle_hash(this.stelle), - "transform": ("translate(" + position.x.toFixed(svg_float_praezission) + ", " + position.y.toFixed(svg_float_praezission) + ")"), - }, - kinder_feld + "class": "rahmen" + } ) ); - return knoten_feld; } - - - /** - * @author kcf - * @implementation - */ - public binden() : void - { - } - + ; + let kinder_feld : Array = []; + fallunterscheidung + ( + aktor, + { + "erzeuger": (angaben) => + { + kinder_feld.push(knoten_rahmen()); + let richtung : mod_vtm_aufbau.typ_richtung = mod_vtm_aufbau.erzeuger_richtung_lesen(angaben); + let knoten_pfeil : mod_vtm_helfer.typ_xmlknoten = ( + mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert + ( + "path", + { + "d": svg_form_pfeil, + "class": ( + [ + "pfeil", + "erzeuger", + ].join(" ") + ), + "transform": ( + [ + "rotate(" + ((richtung/6) * 360).toFixed(svg_float_praezission) + ")", + "translate(-0.2, 0)", + "scale(0.12)", + ].join(" ") + ), + } + ) + ); + kinder_feld.push(knoten_pfeil); + } + , + "befoerderer": (angaben) => + { + kinder_feld.push(knoten_rahmen()); + let richtung : mod_vtm_aufbau.typ_richtung = mod_vtm_aufbau.befoerderer_richtung_lesen(angaben); + let knoten_pfeil : mod_vtm_helfer.typ_xmlknoten = ( + mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert + ( + "path", + { + "d": svg_form_pfeil, + "class": ( + [ + "pfeil", + "neutral", + ].join(" ") + ), + "transform": ( + [ + "rotate(" + ((richtung/6) * 360).toFixed(svg_float_praezission) + ")", + "translate(-0.2, 0)", + "scale(0.12)", + ].join(" ") + ), + } + ) + ); + kinder_feld.push(knoten_pfeil); + } + , + "schreiber": (angaben) => + { + kinder_feld.push(knoten_rahmen()); + let richtung : mod_vtm_aufbau.typ_richtung = mod_vtm_aufbau.schreiber_richtung_lesen(angaben); + let symbol : mod_vtm_aufbau.typ_symbol = mod_vtm_aufbau.schreiber_symbol_lesen(angaben); + let knoten_pfeil : mod_vtm_helfer.typ_xmlknoten = ( + mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert + ( + "path", + { + "d": svg_form_pfeil, + "class": ( + [ + "pfeil", + "symbol_" + symbol.toFixed(0), + ].join(" ") + ), + "transform": ( + [ + "rotate(" + ((richtung/6) * 360).toFixed(svg_float_praezission) + ")", + "translate(-0.2, 0)", + "scale(0.12)", + ].join(" ") + ), + } + ) + ); + kinder_feld.push(knoten_pfeil); + } + , + "leser": (angaben) => + { + kinder_feld.push(knoten_rahmen()); + let richtung : mod_vtm_aufbau.typ_richtung = mod_vtm_aufbau.leser_richtung_lesen(angaben); + let symbol_links : mod_vtm_aufbau.typ_symbol = mod_vtm_aufbau.leser_symbol_links_lesen(angaben); + let symbol_rechts : mod_vtm_aufbau.typ_symbol = mod_vtm_aufbau.leser_symbol_rechts_lesen(angaben); + let ausgaenge : Array<{summand : mod_vtm_aufbau.typ_richtung, symbol : schnittstelle_fehlermonade;}> = + [ + { + "summand": 0, + "symbol": new klasse_nichts(), + }, + { + "summand": +2, + "symbol": new klasse_schlicht(symbol_links), + }, + { + "summand": -2, + "symbol": new klasse_schlicht(symbol_rechts), + }, + ] + ; + ausgaenge.forEach + ( + eintrag => + { + let winkel : float = ((mod_vtm_aufbau.richtung_addieren(richtung, eintrag.summand) / 6) * 360); + let knoten_pfeil : mod_vtm_helfer.typ_xmlknoten = ( + mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert + ( + "path", + { + "d": svg_form_pfeil, + "class": ( + [ + "pfeil", + ( + eintrag.symbol.ist_schlicht() + ? "symbol_" + eintrag.symbol.lesen().toFixed(0) + : "neutral" + ), + ].join(" ") + ), + "transform": ( + [ + + "rotate(" + winkel.toFixed(svg_float_praezission) + ")", + "translate(0.1, 0)", + "scale(0.075)", + ].join(" ") + ), + } + ) + ); + kinder_feld.push(knoten_pfeil); + } + ) + ; + } + , + "verwerfer": (angaben) => + { + kinder_feld.push(knoten_rahmen()); + let knoten_kreis : mod_vtm_helfer.typ_xmlknoten = ( + mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert + ( + "circle", + { + "cx": (0.0).toFixed(svg_float_praezission), + "cy": (0.0).toFixed(svg_float_praezission), + "r": (0.25).toFixed(svg_float_praezission), + "class": ( + [ + "kreis", + "negativ", + ].join(" ") + ), + } + ) + ); + kinder_feld.push(knoten_kreis); + } + , + "annehmer": (angaben) => + { + kinder_feld.push(knoten_rahmen()); + let knoten_kreis : mod_vtm_helfer.typ_xmlknoten = ( + mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert + ( + "circle", + { + "cx": (0.0).toFixed(svg_float_praezission), + "cy": (0.0).toFixed(svg_float_praezission), + "r": (0.25).toFixed(svg_float_praezission), + "class": ( + [ + "kreis", + "positiv", + ].join(" ") + ), + } + ) + ); + kinder_feld.push(knoten_kreis); + } + , + } + ) + ; + let position : typ_position = position_von_stelle(svg_aktor.stelle); + let knoten_feld : mod_vtm_helfer.typ_xmlknoten = ( + mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert + ( + "g", + { + "class": "feld", + "rel": mod_vtm_aufbau.stelle_hash(svg_aktor.stelle), + "transform": ("translate" + "(" + position.x.toFixed(svg_float_praezission) + ", " + position.y.toFixed(svg_float_praezission) + ")"), + }, + kinder_feld + ) + ); + return knoten_feld; } + + /** + * @author kcf + */ + implementierung_manifestation["svg_aktor"] = + { + "darstellen": (manifestation) => svg_aktor_darstellen(manifestation.angaben), + "binden": (manifestation) => {}, + } + ; + } diff --git a/quelldatein/manifestation/svg/figur.ts b/quelldatein/manifestation/svg/figur.ts index e403a2d..d9cfa3c 100644 --- a/quelldatein/manifestation/svg/figur.ts +++ b/quelldatein/manifestation/svg/figur.ts @@ -22,118 +22,154 @@ module mod_vtm_manifestation /** * @author kcf */ - export class klasse_svg_figur - extends klasse_manifestation + export type typ_svg_figur = { - - /** - * @author kcf - */ - public constructor(aufbau : mod_vtm_aufbau.typ_figur) - { - super(aufbau); - } - - - /** - * @author kcf - * @implementation - */ - public darstellen() : mod_vtm_helfer.schnittstelle_xmlknoten - { - let figur : mod_vtm_aufbau.typ_figur = this.aufbau; - let kinder_figur : Array = []; - // Stein - { - let knoten_stein : mod_vtm_helfer.schnittstelle_xmlknoten = ( - new mod_vtm_helfer.klasse_xmlknoten_normal - ( - "circle", - { - "cx": (0.0).toFixed(svg_float_praezission), - "cy": (0.0).toFixed(svg_float_praezission), - "r": (0.125).toFixed(svg_float_praezission), - "class": "stein", - } - ) - ); - kinder_figur.push(knoten_stein); - } - // Band - { - let band : Array = mod_vtm_aufbau.figur_band_lesen(figur); - let kinder_band : Array = []; - band.forEach - ( - (symbol, index) => - { - let r : float = 0.06125; - let x : float = (+0.1+(2*r*1.25)*index); - let y : float = (-0.1); - let knoten_eintrag : mod_vtm_helfer.schnittstelle_xmlknoten = ( - new mod_vtm_helfer.klasse_xmlknoten_normal - ( - "circle", - { - "cx": x.toFixed(svg_float_praezission), - "cy": y.toFixed(svg_float_praezission), - "r": r.toFixed(svg_float_praezission), - /* - "x": (x-r).toFixed(svg_float_praezission), - "y": (y-r).toFixed(svg_float_praezission), - "width": (2*r).toFixed(svg_float_praezission), - "height": (2*r).toFixed(svg_float_praezission), - */ - "class": ( - [ - "eintrag", - "symbol_" + symbol.toFixed(0), - ].join(" ") - ), - } - ) - ); - kinder_band.push(knoten_eintrag); - } - ) - ; - let knoten_band = ( - new mod_vtm_helfer.klasse_xmlknoten_normal - ( - "g", - { - "class": "band", - }, - kinder_band - ) - ); - kinder_figur.push(knoten_band); - } - let position : typ_position = position_von_stelle(mod_vtm_aufbau.figur_stelle_lesen(figur)); - let knoten_figur = ( - new mod_vtm_helfer.klasse_xmlknoten_normal - ( - "g", - { - "class": "figur", - "transform": ("translate(" + position.x.toFixed(svg_float_praezission) + "," + position.y.toFixed(svg_float_praezission) + ")"), - }, - kinder_figur - ) - ); - return knoten_figur; - } - - - /** - * @author kcf - * @implementation - */ - public binden() : void - { - } - + aufbau : mod_vtm_aufbau.typ_figur; } + ; + + + /** + * @author kcf + */ + function svg_figur_erstellen + ( + aufbau : mod_vtm_aufbau.typ_figur + ) + : typ_svg_figur + { + return { + "aufbau": aufbau, + }; + } + + + /** + * @author kcf + */ + export function svg_figur_erstellen_manifestation + ( + aufbau : mod_vtm_aufbau.typ_figur + ) + : typ_manifestation + { + return { + "art": "svg_figur", + "angaben": svg_figur_erstellen(aufbau), + }; + } + + + /** + * @author kcf + */ + function svg_figur_darstellen + ( + svg_figur : typ_svg_figur + ) + : mod_vtm_helfer.typ_xmlknoten + { + let figur : mod_vtm_aufbau.typ_figur = svg_figur.aufbau; + let kinder_figur : Array = []; + // Stein + { + let knoten_stein : mod_vtm_helfer.typ_xmlknoten = ( + mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert + ( + "circle", + { + "cx": (0.0).toFixed(svg_float_praezission), + "cy": (0.0).toFixed(svg_float_praezission), + "r": (0.125).toFixed(svg_float_praezission), + "class": "stein", + } + ) + ); + kinder_figur.push(knoten_stein); + } + // Band + { + let band : Array = mod_vtm_aufbau.figur_band_lesen(figur); + let kinder_band : Array = []; + band.forEach + ( + (symbol, index) => + { + let r : float = 0.06125; + let x : float = (+0.1+(2*r*1.25)*index); + let y : float = (-0.1); + let knoten_eintrag : mod_vtm_helfer.typ_xmlknoten = ( + mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert + ( + "circle", + { + "cx": x.toFixed(svg_float_praezission), + "cy": y.toFixed(svg_float_praezission), + "r": r.toFixed(svg_float_praezission), + /* + "x": (x-r).toFixed(svg_float_praezission), + "y": (y-r).toFixed(svg_float_praezission), + "width": (2*r).toFixed(svg_float_praezission), + "height": (2*r).toFixed(svg_float_praezission), + */ + "class": ( + [ + "eintrag", + "symbol_" + symbol.toFixed(0), + ].join(" ") + ), + } + ) + ); + kinder_band.push(knoten_eintrag); + } + ) + ; + let knoten_band = ( + mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert + ( + "g", + { + "class": "band", + }, + kinder_band + ) + ); + kinder_figur.push(knoten_band); + } + let position : typ_position = position_von_stelle(mod_vtm_aufbau.figur_stelle_lesen(figur)); + let knoten_figur = ( + mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert + ( + "g", + { + "class": "figur", + "transform": ("translate(" + position.x.toFixed(svg_float_praezission) + "," + position.y.toFixed(svg_float_praezission) + ")"), + }, + kinder_figur + ) + ); + return knoten_figur; + } + + + /** + * @author kcf + */ + function svg_figur_binden(svg_figur : typ_svg_figur) : void + { + } + + + /** + * @author kcf + */ + implementierung_manifestation["svg_figur"] = + { + "darstellen": (manifestation) => svg_figur_darstellen(manifestation.angaben), + "binden": (manifestation) => svg_figur_binden(manifestation.angaben), + } + ; } diff --git a/quelldatein/manifestation/svg/partie.ts b/quelldatein/manifestation/svg/partie.ts index e9d7ce3..c3b0d52 100644 --- a/quelldatein/manifestation/svg/partie.ts +++ b/quelldatein/manifestation/svg/partie.ts @@ -22,105 +22,129 @@ module mod_vtm_manifestation /** * @author kcf */ - export class klasse_svg_partie - extends klasse_manifestation + export type typ_svg_partie = { - - /** - * @author kcf - */ - public constructor(aufbau : mod_vtm_aufbau.typ_partie) + aufbau : mod_vtm_aufbau.typ_partie; + } + ; + + + /** + * @author kcf + */ + function svg_partie_erstellen(aufbau : mod_vtm_aufbau.typ_partie) : typ_svg_partie + { + return { + "aufbau": aufbau + }; + } + + + /** + * @author kcf + */ + export function svg_partie_erstellen_manifestation(aufbau : mod_vtm_aufbau.typ_partie) : typ_manifestation + { + return { + "art": "svg_partie", + "angaben": svg_partie_erstellen(aufbau) + }; + } + + + /** + * @author kcf + */ + function svg_partie_darstellen(svg_partie : typ_svg_partie) : mod_vtm_helfer.typ_xmlknoten + { + let kinder_partie : Array = []; + // Welt + { + let kinder_welt : Array = []; + // Felder { - super(aufbau); - } - - - /** - * @author kcf - * @implementation - */ - public darstellen() : mod_vtm_helfer.schnittstelle_xmlknoten - { - let kinder_partie : Array = []; - // Welt - { - let kinder_welt : Array = []; - // Felder - { - let kinder_felder : Array = []; - mod_vtm_aufbau.welt_felder_lesen(mod_vtm_aufbau.partie_welt_lesen(this.aufbau)).forEach - ( - ({"stelle": stelle, "aktor": aktor}) => - { - let manifestation_feld : klasse_manifestation = new klasse_svg_aktor(aktor, stelle); - let knoten_feld : mod_vtm_helfer.schnittstelle_xmlknoten = manifestation_feld.darstellen(); - kinder_felder.push(knoten_feld); - } - ) - ; - let knoten_felder : mod_vtm_helfer.schnittstelle_xmlknoten = ( - new mod_vtm_helfer.klasse_xmlknoten_normal - ( - "g", - { - "class": "felder", - }, - kinder_felder - ) - - ); - kinder_welt.push(knoten_felder); - } - let knoten_welt : mod_vtm_helfer.schnittstelle_xmlknoten = ( - new mod_vtm_helfer.klasse_xmlknoten_normal - ( - "g", - { - "class": "welt", - }, - kinder_welt - ) - ); - kinder_partie.push(knoten_welt); - } - // Figur - { - let figur_ : schnittstelle_fehlermonade = mod_vtm_aufbau.partie_figur_lesen(this.aufbau); - if (figur_.ist_schlicht()) - { - let figur : mod_vtm_aufbau.typ_figur = figur_.lesen(); - let manifestation_figur : klasse_manifestation = (new klasse_svg_figur(figur)); - let knoten_figur : mod_vtm_helfer.schnittstelle_xmlknoten = manifestation_figur.darstellen(); - kinder_partie.push(knoten_figur); - } - else - { - // nichts tun - } - } - let knoten_partie : mod_vtm_helfer.schnittstelle_xmlknoten = ( - new mod_vtm_helfer.klasse_xmlknoten_normal + let kinder_felder : Array = []; + mod_vtm_aufbau.welt_felder_lesen(mod_vtm_aufbau.partie_welt_lesen(svg_partie.aufbau)).forEach + ( + ({"stelle": stelle, "aktor": aktor}) => + { + let manifestation_feld : typ_manifestation = svg_aktor_erstellen_manifestation(aktor, stelle); + let knoten_feld : mod_vtm_helfer.typ_xmlknoten = manifestation_darstellen(manifestation_feld); + kinder_felder.push(knoten_feld); + } + ) + ; + let knoten_felder : mod_vtm_helfer.typ_xmlknoten = ( + mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert ( "g", { - "class": "partie", + "class": "felder", }, - kinder_partie + kinder_felder ) + ); - return knoten_partie; + kinder_welt.push(knoten_felder); } - - - /** - * @author kcf - * @implementation - */ - public binden() : void - { - } - + let knoten_welt : mod_vtm_helfer.typ_xmlknoten = ( + mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert + ( + "g", + { + "class": "welt", + }, + kinder_welt + ) + ); + kinder_partie.push(knoten_welt); + } + // Figur + { + let figur_ : schnittstelle_fehlermonade = mod_vtm_aufbau.partie_figur_lesen(svg_partie.aufbau); + if (figur_.ist_schlicht()) + { + let figur : mod_vtm_aufbau.typ_figur = figur_.lesen(); + let manifestation_figur : typ_manifestation = svg_figur_erstellen_manifestation(figur); + let knoten_figur : mod_vtm_helfer.typ_xmlknoten = manifestation_darstellen(manifestation_figur); + kinder_partie.push(knoten_figur); + } + else + { + // nichts tun + } + } + let knoten_partie : mod_vtm_helfer.typ_xmlknoten = ( + mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert + ( + "g", + { + "class": "partie", + }, + kinder_partie + ) + ); + return knoten_partie; } + + /** + * @author kcf + */ + function svg_partie_binden(svg_partie : typ_svg_partie) : void + { + } + + + /** + * @author kcf + */ + implementierung_manifestation["svg_partie"] = + { + "darstellen": (manifestation) => svg_partie_darstellen(manifestation.angaben), + "binden": (manifestation) => svg_partie_binden(manifestation.angaben), + } + ; + } diff --git a/quelldatein/manifestation/svg/svg.ts b/quelldatein/manifestation/svg/svg.ts index 1895a56..ee59bc5 100644 --- a/quelldatein/manifestation/svg/svg.ts +++ b/quelldatein/manifestation/svg/svg.ts @@ -40,7 +40,7 @@ module mod_vtm_manifestation schliessen : boolean = true, attribute : {[schlussel : string] : string} = {}, ) - : mod_vtm_helfer.schnittstelle_xmlknoten + : mod_vtm_helfer.typ_xmlknoten { let d : string = ""; vertices.forEach @@ -57,7 +57,7 @@ module mod_vtm_manifestation if (schliessen) d += "Z"; attribute["d"] = d; - return (new mod_vtm_helfer.klasse_xmlknoten_normal("path", attribute)); + return (mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert("path", attribute)); } @@ -72,12 +72,12 @@ module mod_vtm_manifestation bis_y : float, hoehe : int = 500, breite : int = 500, - kinder : Array = [] + kinder : Array = [] ) - : mod_vtm_helfer.schnittstelle_xmlknoten + : mod_vtm_helfer.typ_xmlknoten { return ( - new mod_vtm_helfer.klasse_xmlknoten_normal + mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert ( "svg", { diff --git a/quelldatein/manifestation/web/partie.ts b/quelldatein/manifestation/web/partie.ts index 64872e2..dde8e66 100644 --- a/quelldatein/manifestation/web/partie.ts +++ b/quelldatein/manifestation/web/partie.ts @@ -32,431 +32,438 @@ module mod_vtm_manifestation /** * @author kcf */ - export class klasse_web_partie - extends klasse_manifestation + export type typ_web_partie = { - - /** - * @author kcf - */ - private bereich : Element; - - - /** - * @author kcf - */ - private intervall : schnittstelle_fehlermonade; - - - /** - * @author kcf - */ - public constructor(aufbau : mod_vtm_aufbau.typ_partie, bereich : Element) + aufbau : mod_vtm_aufbau.typ_partie; + bereich : Element; + intervall : schnittstelle_fehlermonade; + } + ; + + + /** + * @author kcf + */ + function web_partie_erstellen + ( + aufbau : mod_vtm_aufbau.typ_partie, + bereich : Element + ) + : typ_web_partie + { + return { + "aufbau": aufbau, + "bereich": bereich, + "intervall": (new klasse_nichts()), + }; + } + + + /** + * @author kcf + */ + export function web_partie_erstellen_erweitert + ( + aufbau : mod_vtm_aufbau.typ_partie, + bereich : Element + ) + : typ_manifestation + { + return { + "art": "web_partie", + "angaben": web_partie_erstellen(aufbau, bereich) + }; + } + + + /** + * @author kcf + */ + function web_partie_erneuern_aufgabe(web_partie : typ_web_partie) : void + { + document.querySelector("#aufgabe_text").innerHTML = ( + text_nachbearbeiten + ( + mod_vtm_aufbau.aufgabe_text + ( + mod_vtm_aufbau.partie_aufgabe_lesen(web_partie.aufbau) + ) + ) + ); + } + + + /** + * @author kcf + */ + function web_partie_erneuern_welt(web_partie : typ_web_partie) : void + { + let knoten_svg : mod_vtm_helfer.typ_xmlknoten = mod_vtm_manifestation.svg_wurzel + ( + -4, -4, + +4, +4, + 800, 800, + [manifestation_darstellen(svg_partie_erstellen_manifestation(web_partie.aufbau))] + ) + ; + web_partie.bereich.innerHTML = mod_vtm_helfer.xmlknoten_darstellen(knoten_svg); + } + + + /** + * @author kcf + */ + function web_partie_erneuern_figur(web_partie : typ_web_partie) : void + { + let knoten_svg : mod_vtm_helfer.typ_xmlknoten = mod_vtm_manifestation.svg_wurzel + ( + -4, -4, + +4, +4, + 800, 800, + [manifestation_darstellen(svg_partie_erstellen_manifestation(web_partie.aufbau))] + ) + ; + web_partie.bereich.innerHTML = mod_vtm_helfer.xmlknoten_darstellen(knoten_svg); + } + + + /** + * @author kcf + */ + function web_partie_erneuern_modus(web_partie : typ_web_partie) : void + { + let status : string; + switch (mod_vtm_aufbau.partie_modus_lesen(web_partie.aufbau)) { - super(aufbau); - this.bereich = bereich; - this.intervall = (new klasse_nichts()); - /* - mod_vtm_aufbau.partie_lauschen - ( - this.aufbau, - "aenderung_welt", - (angaben) => - { - this.erneuern_welt(); - } - ) - ; - */ - } - - - /** - * @author kcf - * @override - */ - public einrichten() : void - { - mod_vtm_aufbau.partie_lauschen - ( - this.aufbau, - "aenderung_aufgabe", - (angaben) => - { - this.erneuern_aufgabe(); - } - ) - ; - mod_vtm_aufbau.partie_lauschen - ( - this.aufbau, - "aenderung_welt", - (angaben) => - { - this.erneuern_welt(); - } - ) - ; - mod_vtm_aufbau.partie_lauschen - ( - this.aufbau, - "aenderung_figur", - (angaben) => - { - this.erneuern_figur(); - } - ) - ; - mod_vtm_aufbau.partie_lauschen - ( - this.aufbau, - "aenderung_modus", - (angaben) => - { - this.erneuern_modus(); - this.erneuern_knoepfe(); - } - ) - ; - this.darstellen(); - this.binden(); - } - - - /** - * @author kcf - */ - private erneuern_aufgabe() : void - { - document.querySelector("#aufgabe_text").innerHTML = text_nachbearbeiten(mod_vtm_aufbau.partie_aufgabe_lesen(this.aufbau).text()); - } - - - /** - * @author kcf - */ - private erneuern_welt() : void - { - let knoten_svg : mod_vtm_helfer.schnittstelle_xmlknoten = mod_vtm_manifestation.svg_wurzel - ( - -4, -4, - +4, +4, - 800, 800, - [new klasse_svg_partie(this.aufbau).darstellen()] - ) - ; - this.bereich.innerHTML = knoten_svg.darstellen(); - } - - - /** - * @author kcf - */ - private erneuern_figur() : void - { - /* - */ - let knoten_svg : mod_vtm_helfer.schnittstelle_xmlknoten = mod_vtm_manifestation.svg_wurzel - ( - -4, -4, - +4, +4, - 800, 800, - [new klasse_svg_partie(this.aufbau).darstellen()] - ) - ; - this.bereich.innerHTML = knoten_svg.darstellen(); - } - - - /** - * @author kcf - */ - private erneuern_modus() : void - { - let status : string; - switch (mod_vtm_aufbau.partie_modus_lesen(this.aufbau)) + case mod_vtm_aufbau.modus_initial: { - case mod_vtm_aufbau.modus_initial: - { - status = "Maschine aufbauen"; - break; - } - case mod_vtm_aufbau.modus_ungewiss: - { - status = "wird geprüft …"; - break; - } - case mod_vtm_aufbau.modus_fehlerhaft: - { - status = "fehlerhaft :/"; - break; - } - case mod_vtm_aufbau.modus_korrekt: - { - status = "anscheinend korrekt :)"; - break; - } - default: - { - let meldung : string = "unbehandelter Modus"; - throw (new Error(meldung)); - break; - } + status = "Maschine aufbauen"; + break; } - document.querySelector("#aufgabe_status").textContent = status; - } - - - /** - * @author kcf - */ - public erneuern_knoepfe() : void - { - let modus : mod_vtm_aufbau.typ_modus = mod_vtm_aufbau.partie_modus_lesen(this.aufbau); - let klasse : string; - switch (modus) + case mod_vtm_aufbau.modus_ungewiss: { - case mod_vtm_aufbau.modus_initial: - { - klasse = "initial"; - break; - } - case mod_vtm_aufbau.modus_ungewiss: - { - klasse = ( - this.intervall.ist_schlicht() - ? "ungewiss_laufend" - : "ungewiss_stehend" - ); - break; - } - case mod_vtm_aufbau.modus_fehlerhaft: - case mod_vtm_aufbau.modus_korrekt: - { - klasse = "fertig"; - break; - } + status = "wird geprüft …"; + break; } - document.querySelector("#knoepfe").setAttribute("class", klasse); - } - - - /** - * @author kcf - * @implementation - */ - public darstellen() : void - { - this.erneuern_aufgabe(); - this.erneuern_welt(); - this.erneuern_figur(); - this.erneuern_modus(); - this.erneuern_knoepfe(); - } - - - /** - * @author kcf - */ - private anhalten() : void - { - if (this.intervall.ist_schlicht()) + case mod_vtm_aufbau.modus_fehlerhaft: { - clearInterval(this.intervall.lesen()); - this.intervall = (new klasse_nichts()); + status = "fehlerhaft :/"; + break; + } + case mod_vtm_aufbau.modus_korrekt: + { + status = "anscheinend korrekt :)"; + break; + } + default: + { + let meldung : string = "unbehandelter Modus"; + throw (new Error(meldung)); + break; + } + } + document.querySelector("#aufgabe_status").textContent = status; + } + + + /** + * @author kcf + */ + function web_partie_erneuern_knoepfe(web_partie : typ_web_partie) : void + { + let modus : mod_vtm_aufbau.typ_modus = mod_vtm_aufbau.partie_modus_lesen(web_partie.aufbau); + let klasse : string; + switch (modus) + { + case mod_vtm_aufbau.modus_initial: + { + klasse = "initial"; + break; + } + case mod_vtm_aufbau.modus_ungewiss: + { + klasse = ( + web_partie.intervall.ist_schlicht() + ? "ungewiss_laufend" + : "ungewiss_stehend" + ); + break; + } + case mod_vtm_aufbau.modus_fehlerhaft: + case mod_vtm_aufbau.modus_korrekt: + { + klasse = "fertig"; + break; + } + } + document.querySelector("#knoepfe").setAttribute("class", klasse); + } + + + /** + * @author kcf + */ + function web_partie_darstellen(web_partie : typ_web_partie) : void + { + web_partie_erneuern_aufgabe(web_partie); + web_partie_erneuern_welt(web_partie); + web_partie_erneuern_figur(web_partie); + web_partie_erneuern_modus(web_partie); + web_partie_erneuern_knoepfe(web_partie); + } + + + /** + * @author kcf + */ + function web_partie_anhalten(web_partie : typ_web_partie) : void + { + if (web_partie.intervall.ist_schlicht()) + { + clearInterval(web_partie.intervall.lesen()); + web_partie.intervall = (new klasse_nichts()); + } + else + { + let meldung : string = "kein Intervall gesetzt"; + console.warn(meldung); + } + web_partie_erneuern_knoepfe(web_partie); + } + + + /** + * @author kcf + */ + function web_partie_fortfahren(web_partie : typ_web_partie) : void + { + mod_vtm_aufbau.partie_fortfahren(web_partie.aufbau); + let modus : mod_vtm_aufbau.typ_modus = mod_vtm_aufbau.partie_modus_lesen(web_partie.aufbau); + if (modus <= 1) + { + // nichts tun + } + else + { + web_partie_anhalten(web_partie); + } + web_partie_erneuern_knoepfe(web_partie); + } + + + /** + * @author kcf + */ + function web_partie_testen(web_partie : typ_web_partie) : void + { + let handle : any = setInterval(() => web_partie_fortfahren(web_partie), 500); + web_partie.intervall = (new klasse_schlicht(handle)); + } + + + /** + * @author kcf + */ + function web_partie_bearbeiten(web_partie : typ_web_partie) : void + { + web_partie_anhalten(web_partie); + mod_vtm_aufbau.partie_zuruecksetzen(web_partie.aufbau); + } + + + /** + * @author kcf + */ + function web_partie_leeren(web_partie : typ_web_partie) : void + { + mod_vtm_aufbau.partie_welt_leeren(web_partie.aufbau); + mod_vtm_aufbau.partie_zuruecksetzen(web_partie.aufbau); + } + + + /** + * @author kcf + */ + function web_partie_binden(web_partie : typ_web_partie) : void + { + let stelle_ermitteln = (target : EventTarget) => + { + let stelle : schnittstelle_fehlermonade; + let dom_feld : Element = target["closest"](".feld"); + if (dom_feld == null) + { + stelle = (new klasse_nichts()); } else { - let meldung : string = "kein Intervall gesetzt"; - console.warn(meldung); + let rel : string = dom_feld.getAttribute("rel") + stelle = (new klasse_schlicht(mod_vtm_aufbau.stelle_von_hash(rel))); } - this.erneuern_knoepfe(); + return stelle; } - - - /** - * @author kcf - */ - private fortfahren() : void - { - mod_vtm_aufbau.partie_fortfahren(this.aufbau); - let modus : mod_vtm_aufbau.typ_modus = mod_vtm_aufbau.partie_modus_lesen(this.aufbau); - if (modus <= 1) + ; + mod_vtm_aufbau.partie_lauschen + ( + web_partie.aufbau, + "aenderung_aufgabe", + (angaben) => { - // nichts tun + web_partie_erneuern_aufgabe(web_partie); } - else + ) + ; + mod_vtm_aufbau.partie_lauschen + ( + web_partie.aufbau, + "aenderung_welt", + (angaben) => { - this.anhalten(); + web_partie_erneuern_welt(web_partie); } - this.erneuern_knoepfe(); - } - - - /** - * @author kcf - */ - private testen() : void - { - let handle : any = setInterval(() => this.fortfahren(), 500); - this.intervall = (new klasse_schlicht(handle)); - } - - - /** - * @author kcf - */ - private bearbeiten() : void - { - this.anhalten(); - mod_vtm_aufbau.partie_zuruecksetzen(this.aufbau); - } - - - /** - * @author kcf - */ - private leeren() : void - { - mod_vtm_aufbau.partie_welt_leeren(this.aufbau); - mod_vtm_aufbau.partie_zuruecksetzen(this.aufbau); - } - - - /** - * @author kcf - * @implementation - */ - public binden() : void - { - let stelle_ermitteln = (target : EventTarget) => + ) + ; + mod_vtm_aufbau.partie_lauschen + ( + web_partie.aufbau, + "aenderung_figur", + (angaben) => { - let stelle : schnittstelle_fehlermonade; - let dom_feld : Element = target["closest"](".feld"); - if (dom_feld == null) + web_partie_erneuern_figur(web_partie); + } + ) + ; + mod_vtm_aufbau.partie_lauschen + ( + web_partie.aufbau, + "aenderung_modus", + (angaben) => + { + web_partie_erneuern_modus(web_partie); + web_partie_erneuern_knoepfe(web_partie); + } + ) + ; + // Links-Klick + web_partie.bereich.addEventListener + ( + "click", + event => + { + event.preventDefault(); + let stelle_ : schnittstelle_fehlermonade = stelle_ermitteln(event.target); + if (stelle_.ist_schlicht()) { - stelle = (new klasse_nichts()); + mod_vtm_aufbau.partie_welt_feld_wechseln(web_partie.aufbau, stelle_.lesen(), false); } else { - let rel : string = dom_feld.getAttribute("rel") - stelle = (new klasse_schlicht(mod_vtm_aufbau.stelle_von_hash(rel))); + console.info("-- kein Feld"); } - return stelle; } - ; - // Links-Klick - this.bereich.addEventListener - ( - "click", - event => + ) + ; + // Rechts-Klick + web_partie.bereich.addEventListener + ( + "contextmenu", + event => + { + event.preventDefault(); + let stelle_ : schnittstelle_fehlermonade = stelle_ermitteln(event.target); + if (stelle_.ist_schlicht()) { - event.preventDefault(); - let stelle_ : schnittstelle_fehlermonade = stelle_ermitteln(event.target); - if (stelle_.ist_schlicht()) - { - mod_vtm_aufbau.partie_welt_feld_wechseln(this.aufbau, stelle_.lesen(), false); - } - else - { - console.info("-- kein Feld"); - } + mod_vtm_aufbau.partie_welt_feld_wechseln(web_partie.aufbau, stelle_.lesen(), true); } - ) - ; - // Rechts-Klick - this.bereich.addEventListener - ( - "contextmenu", - event => + else { - event.preventDefault(); - let stelle_ : schnittstelle_fehlermonade = stelle_ermitteln(event.target); - if (stelle_.ist_schlicht()) - { - mod_vtm_aufbau.partie_welt_feld_wechseln(this.aufbau, stelle_.lesen(), true); - } - else - { - console.info("-- kein Feld"); - } + console.info("-- kein Feld"); } - ) - ; - // Mausrad - this.bereich.addEventListener - ( - "wheel", - event => + } + ) + ; + // Mausrad + web_partie.bereich.addEventListener + ( + "wheel", + event => + { + event.preventDefault(); + let stelle_ : schnittstelle_fehlermonade = stelle_ermitteln(event.target); + if (stelle_.ist_schlicht()) { - event.preventDefault(); - let stelle_ : schnittstelle_fehlermonade = stelle_ermitteln(event.target); - if (stelle_.ist_schlicht()) - { - let inkrement : int = ((event["deltaY"] < 0) ? -1 : +1); - mod_vtm_aufbau.partie_welt_feld_drehen(this.aufbau, stelle_.lesen(), inkrement); - } - else - { - console.info("-- kein Feld"); - } + let inkrement : int = ((event["deltaY"] < 0) ? -1 : +1); + mod_vtm_aufbau.partie_welt_feld_drehen(web_partie.aufbau, stelle_.lesen(), inkrement); } - ) - ; - // Schritt - document.querySelector("#knopf_schritt").addEventListener - ( - "click", - event => + else { - this.anhalten(); - this.fortfahren(); + console.info("-- kein Feld"); } - ) - ; - // Testen - document.querySelector("#knopf_testen").addEventListener - ( - "click", - event => - { - this.testen(); - } - ) - ; - // Anhalten - document.querySelector("#knopf_anhalten").addEventListener - ( - "click", - event => - { - this.anhalten(); - } - ) - ; - // Bearbeiten - document.querySelector("#knopf_bearbeiten").addEventListener - ( - "click", - event => - { - this.bearbeiten(); - } - ) - ; - // Leeren - document.querySelector("#knopf_leeren").addEventListener - ( - "click", - event => - { - this.leeren(); - } - ) - ; - } - + } + ) + ; + // Schritt + document.querySelector("#knopf_schritt").addEventListener + ( + "click", + event => + { + web_partie_anhalten(web_partie); + web_partie_fortfahren(web_partie); + } + ) + ; + // Testen + document.querySelector("#knopf_testen").addEventListener + ( + "click", + event => + { + web_partie_testen(web_partie); + } + ) + ; + // Anhalten + document.querySelector("#knopf_anhalten").addEventListener + ( + "click", + event => + { + web_partie_anhalten(web_partie); + } + ) + ; + // Bearbeiten + document.querySelector("#knopf_bearbeiten").addEventListener + ( + "click", + event => + { + web_partie_bearbeiten(web_partie); + } + ) + ; + // Leeren + document.querySelector("#knopf_leeren").addEventListener + ( + "click", + event => + { + web_partie_leeren(web_partie); + } + ) + ; } + + /** + * @author kcf + */ + implementierung_manifestation["web_partie"] = + { + "darstellen": (manifestation) => web_partie_darstellen(manifestation.angaben), + "binden": (manifestation) => web_partie_binden(manifestation.angaben), + } + ; + }