fast fertig

This commit is contained in:
Christian Fraß 2018-03-26 00:41:10 +02:00
parent 6012730288
commit 74a9792bbf
32 changed files with 2688 additions and 2083 deletions

View file

@ -52,11 +52,14 @@ ${dir_erzeugnis}/vtm.dat.js: \
${dir_erzeugnis}/vtm.js: \ ${dir_erzeugnis}/vtm.js: \
${dir_quelldatein}/basis/typen.ts \ ${dir_quelldatein}/basis/typen.ts \
${dir_quelldatein}/basis/fehlermonade.ts \ ${dir_quelldatein}/basis/fehlermonade.ts \
${dir_quelldatein}/basis/aufruf.ts \
${dir_quelldatein}/helfer/verschiedenes.ts \ ${dir_quelldatein}/helfer/verschiedenes.ts \
${dir_quelldatein}/helfer/mathematik.ts \ ${dir_quelldatein}/helfer/mathematik.ts \
${dir_quelldatein}/helfer/vektor.ts \ ${dir_quelldatein}/helfer/vektor.ts \
${dir_quelldatein}/helfer/hashmap.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}/helfer/uebersetzung.ts \
${dir_quelldatein}/daten.ts \ ${dir_quelldatein}/daten.ts \
${dir_quelldatein}/aufbau/richtung.ts \ ${dir_quelldatein}/aufbau/richtung.ts \
@ -64,21 +67,20 @@ ${dir_erzeugnis}/vtm.js: \
${dir_quelldatein}/aufbau/stelle.ts \ ${dir_quelldatein}/aufbau/stelle.ts \
${dir_quelldatein}/aufbau/zustand.ts \ ${dir_quelldatein}/aufbau/zustand.ts \
${dir_quelldatein}/aufbau/figur.ts \ ${dir_quelldatein}/aufbau/figur.ts \
${dir_quelldatein}/aufbau/aktoren/_aktor.ts \
${dir_quelldatein}/aufbau/aktoren/erzeuger.ts \ ${dir_quelldatein}/aufbau/aktoren/erzeuger.ts \
${dir_quelldatein}/aufbau/aktoren/annehmer.ts \ ${dir_quelldatein}/aufbau/aktoren/annehmer.ts \
${dir_quelldatein}/aufbau/aktoren/verwerfer.ts \ ${dir_quelldatein}/aufbau/aktoren/verwerfer.ts \
${dir_quelldatein}/aufbau/aktoren/befoerderer.ts \ ${dir_quelldatein}/aufbau/aktoren/befoerderer.ts \
${dir_quelldatein}/aufbau/aktoren/schreiber.ts \ ${dir_quelldatein}/aufbau/aktoren/schreiber.ts \
${dir_quelldatein}/aufbau/aktoren/leser.ts \ ${dir_quelldatein}/aufbau/aktoren/leser.ts \
${dir_quelldatein}/aufbau/aktoren/aktor.ts \
${dir_quelldatein}/aufbau/welt.ts \ ${dir_quelldatein}/aufbau/welt.ts \
${dir_quelldatein}/aufbau/aufgaben/test.ts \ ${dir_quelldatein}/aufbau/aufgaben/test.ts \
${dir_quelldatein}/aufbau/aufgaben/akzeptortest.ts \ ${dir_quelldatein}/aufbau/aufgaben/akzeptortest.ts \
${dir_quelldatein}/aufbau/aufgaben/transduktortest.ts \ ${dir_quelldatein}/aufbau/aufgaben/transduktortest.ts \
${dir_quelldatein}/aufbau/aufgaben/aufgabe.ts \
${dir_quelldatein}/aufbau/aufgaben/akzeptoraufgabe.ts \ ${dir_quelldatein}/aufbau/aufgaben/akzeptoraufgabe.ts \
${dir_quelldatein}/aufbau/aufgaben/transduktoraufgabe.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/modus.ts \
${dir_quelldatein}/aufbau/partie.ts \ ${dir_quelldatein}/aufbau/partie.ts \
${dir_quelldatein}/manifestation/manifestation.ts \ ${dir_quelldatein}/manifestation/manifestation.ts \
@ -95,11 +97,14 @@ ${dir_erzeugnis}/vtm.js: \
@ ${cmd_tsc} \ @ ${cmd_tsc} \
${dir_quelldatein}/basis/typen.ts \ ${dir_quelldatein}/basis/typen.ts \
${dir_quelldatein}/basis/fehlermonade.ts \ ${dir_quelldatein}/basis/fehlermonade.ts \
${dir_quelldatein}/basis/aufruf.ts \
${dir_quelldatein}/helfer/verschiedenes.ts \ ${dir_quelldatein}/helfer/verschiedenes.ts \
${dir_quelldatein}/helfer/mathematik.ts \ ${dir_quelldatein}/helfer/mathematik.ts \
${dir_quelldatein}/helfer/vektor.ts \ ${dir_quelldatein}/helfer/vektor.ts \
${dir_quelldatein}/helfer/hashmap.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}/helfer/uebersetzung.ts \
${dir_quelldatein}/daten.ts \ ${dir_quelldatein}/daten.ts \
${dir_quelldatein}/aufbau/richtung.ts \ ${dir_quelldatein}/aufbau/richtung.ts \
@ -107,21 +112,20 @@ ${dir_erzeugnis}/vtm.js: \
${dir_quelldatein}/aufbau/stelle.ts \ ${dir_quelldatein}/aufbau/stelle.ts \
${dir_quelldatein}/aufbau/zustand.ts \ ${dir_quelldatein}/aufbau/zustand.ts \
${dir_quelldatein}/aufbau/figur.ts \ ${dir_quelldatein}/aufbau/figur.ts \
${dir_quelldatein}/aufbau/aktoren/_aktor.ts \
${dir_quelldatein}/aufbau/aktoren/erzeuger.ts \ ${dir_quelldatein}/aufbau/aktoren/erzeuger.ts \
${dir_quelldatein}/aufbau/aktoren/annehmer.ts \ ${dir_quelldatein}/aufbau/aktoren/annehmer.ts \
${dir_quelldatein}/aufbau/aktoren/verwerfer.ts \ ${dir_quelldatein}/aufbau/aktoren/verwerfer.ts \
${dir_quelldatein}/aufbau/aktoren/befoerderer.ts \ ${dir_quelldatein}/aufbau/aktoren/befoerderer.ts \
${dir_quelldatein}/aufbau/aktoren/schreiber.ts \ ${dir_quelldatein}/aufbau/aktoren/schreiber.ts \
${dir_quelldatein}/aufbau/aktoren/leser.ts \ ${dir_quelldatein}/aufbau/aktoren/leser.ts \
${dir_quelldatein}/aufbau/aktoren/aktor.ts \
${dir_quelldatein}/aufbau/welt.ts \ ${dir_quelldatein}/aufbau/welt.ts \
${dir_quelldatein}/aufbau/aufgaben/test.ts \ ${dir_quelldatein}/aufbau/aufgaben/test.ts \
${dir_quelldatein}/aufbau/aufgaben/akzeptortest.ts \ ${dir_quelldatein}/aufbau/aufgaben/akzeptortest.ts \
${dir_quelldatein}/aufbau/aufgaben/transduktortest.ts \ ${dir_quelldatein}/aufbau/aufgaben/transduktortest.ts \
${dir_quelldatein}/aufbau/aufgaben/aufgabe.ts \
${dir_quelldatein}/aufbau/aufgaben/akzeptoraufgabe.ts \ ${dir_quelldatein}/aufbau/aufgaben/akzeptoraufgabe.ts \
${dir_quelldatein}/aufbau/aufgaben/transduktoraufgabe.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/modus.ts \
${dir_quelldatein}/aufbau/partie.ts \ ${dir_quelldatein}/aufbau/partie.ts \
${dir_quelldatein}/manifestation/manifestation.ts \ ${dir_quelldatein}/manifestation/manifestation.ts \

View file

@ -0,0 +1,103 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
module mod_vtm_aufbau
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type typ_aktor = typ_komplex<any>;
/**
* @author kcf <vidofnir@folksprak.org>
*/
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 <vidofnir@folksprak.org>
*/
export var implementierung_aktor : {[art : string] : schnittstelle_aktor} = {};
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function aktor_erstellen(art : string, kern : any) : typ_aktor
{
return {"art": art, "angaben": kern};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function aktor_beispiel(art : string) : typ_aktor
{
return implementierung_aktor[art].beispiel();
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function aktor_drehen(aktor : typ_aktor, inkrement ?: int) : void
{
return implementierung_aktor[aktor.art].drehen(aktor, inkrement);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function aktor_verwenden(aktor : typ_aktor, figur : typ_figur) : void
{
return implementierung_aktor[aktor.art].verwenden(aktor, figur);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function aktor_exportieren(aktor : typ_aktor) : any
{
return implementierung_aktor[aktor.art].exportieren(aktor);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function aktor_importieren(roh : any) : typ_aktor
{
return implementierung_aktor[roh.art].importieren(roh);
}
}

View file

@ -1,329 +0,0 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
module mod_vtm_aufbau
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type typ_aktor =
{
art : string;
angaben ?: any;
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
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 <vidofnir@folksprak.org>
*/
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 <vidofnir@folksprak.org>
*/
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 <vidofnir@folksprak.org>
*/
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 <vidofnir@folksprak.org>
*/
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;
}
}
}
}

View file

@ -3,16 +3,16 @@
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 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 <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
@ -22,7 +22,7 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export type typ_aktor_annehmer = export type typ_annehmer =
{ {
} }
; ;
@ -31,10 +31,10 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function aktor_annehmer_erstellen function annehmer_erstellen
( (
) )
: typ_aktor_annehmer : typ_annehmer
{ {
return { return {
}; };
@ -44,7 +44,36 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
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 <vidofnir@folksprak.org>
*/
function annehmer_beispiel
(
)
: typ_annehmer
{
return annehmer_erstellen();
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function annehmer_drehen
(
annehmer : typ_annehmer,
inkrement ?: int
)
: void
{ {
} }
@ -52,7 +81,12 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
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); figur_annehmen(figur);
} }
@ -61,7 +95,11 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function aktor_annehmer_exportieren(aktor_annehmer : typ_aktor_annehmer) : any function annehmer_exportieren
(
annehmer : typ_annehmer
)
: any
{ {
return { return {
}; };
@ -71,15 +109,35 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function aktor_annehmer_importieren(roh : any) : typ_aktor_annehmer function annehmer_importieren
(
roh : any
)
: typ_annehmer
{ {
return ( return (
aktor_annehmer_erstellen annehmer_erstellen
( (
) )
); );
} }
/**
* @author kcf <vidofnir@folksprak.org>
*/
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)),
}
;
} }

View file

@ -3,16 +3,16 @@
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 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 <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
@ -22,7 +22,7 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export type typ_aktor_befoerderer = export type typ_befoerderer =
{ {
richtung : typ_richtung; richtung : typ_richtung;
} }
@ -32,7 +32,11 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function aktor_befoerderer_erstellen(richtung : typ_richtung = 0) : typ_aktor_befoerderer function befoerderer_erstellen
(
richtung : typ_richtung
)
: typ_befoerderer
{ {
return { return {
"richtung": richtung, "richtung": richtung,
@ -43,37 +47,80 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
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 <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
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 <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
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 <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
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 <vidofnir@folksprak.org>
*/
function befoerderer_verwenden
(
befoerderer : typ_befoerderer,
figur : typ_figur
)
: void
{
figur_bewegen(figur, befoerderer.richtung);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function befoerderer_exportieren
(
befoerderer : typ_befoerderer
)
: any
{ {
return { return {
"richtung": richtung_exportieren(aktor_befoerderer.richtung), "richtung": richtung_exportieren(befoerderer.richtung),
}; };
} }
@ -81,16 +128,36 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function aktor_befoerderer_importieren(roh : any) : typ_aktor_befoerderer function befoerderer_importieren
(
roh : any
)
: typ_befoerderer
{ {
return ( return (
aktor_befoerderer_erstellen befoerderer_erstellen
( (
richtung_importieren(roh["richtung"]) richtung_importieren(roh["richtung"])
) )
); );
} }
/**
* @author kcf <vidofnir@folksprak.org>
*/
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)),
}
;
} }

View file

@ -22,7 +22,7 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export type typ_aktor_erzeuger = export type typ_erzeuger =
{ {
richtung : typ_richtung; richtung : typ_richtung;
} }
@ -32,11 +32,11 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function aktor_erzeuger_erstellen function erzeuger_erstellen
( (
richtung : typ_richtung = 0 richtung : typ_richtung
) )
: typ_aktor_erzeuger : typ_erzeuger
{ {
return { return {
"richtung": richtung, "richtung": richtung,
@ -47,55 +47,80 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
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 <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function aktor_erzeuger_drehen function erzeuger_beispiel
( (
aktor_erzeuger : typ_aktor_erzeuger, )
: typ_erzeuger
{
return erzeuger_erstellen(0);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function erzeuger_richtung_lesen
(
erzeuger : typ_erzeuger
)
: typ_richtung
{
return erzeuger.richtung;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function erzeuger_drehen
(
erzeuger : typ_erzeuger,
inkrement : int = +1 inkrement : int = +1
) )
: void : void
{ {
aktor_erzeuger.richtung = richtung_addieren(aktor_erzeuger.richtung, inkrement); erzeuger.richtung = richtung_addieren(erzeuger.richtung, inkrement);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function aktor_erzeuger_verwenden function erzeuger_verwenden
( (
aktor_erzeuger : typ_aktor_erzeuger, erzeuger : typ_erzeuger,
figur : typ_figur figur : typ_figur
) )
: void : void
{ {
figur_bewegen(figur, aktor_erzeuger.richtung); figur_bewegen(figur, erzeuger.richtung);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function aktor_erzeuger_exportieren function erzeuger_exportieren
( (
aktor_erzeuger : typ_aktor_erzeuger erzeuger : typ_erzeuger
) )
: any : any
{ {
return { return {
"richtung": richtung_exportieren(aktor_erzeuger.richtung), "richtung": richtung_exportieren(erzeuger.richtung),
}; };
} }
@ -103,20 +128,36 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function aktor_erzeuger_importieren function erzeuger_importieren
( (
roh : any roh : any
) )
: typ_aktor_erzeuger : typ_erzeuger
{ {
return ( return (
aktor_erzeuger_erstellen erzeuger_erstellen
( (
richtung_importieren(roh["richtung"]) richtung_importieren(roh["richtung"])
) )
); );
} }
/**
* @author kcf <vidofnir@folksprak.org>
*/
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)),
}
;
} }

View file

@ -3,16 +3,16 @@
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 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 <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
@ -22,7 +22,7 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export type typ_aktor_leser = export type typ_leser =
{ {
"richtung": typ_richtung, "richtung": typ_richtung,
"symbol_links": typ_symbol, "symbol_links": typ_symbol,
@ -34,7 +34,13 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
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 { return {
"richtung": richtung, "richtung": richtung,
@ -47,55 +53,104 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
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 <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
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 <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
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 <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
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 <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
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 <vidofnir@folksprak.org>
*/
function leser_drehen
(
leser : typ_leser,
inkrement : int = +1
)
: void
{
leser.richtung = richtung_addieren(leser.richtung, inkrement);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function leser_verwenden
(
leser : typ_leser,
figur : typ_figur
)
: void
{ {
let symbol_ : schnittstelle_fehlermonade<typ_symbol> = figur_lesen(figur); let symbol_ : schnittstelle_fehlermonade<typ_symbol> = figur_lesen(figur);
let summand : typ_richtung; let summand : typ_richtung;
if (symbol_.ist_schlicht()) if (symbol_.ist_schlicht())
{ {
let symbol : typ_symbol = symbol_.lesen(); let symbol : typ_symbol = symbol_.lesen();
if (symbol === aktor_leser.symbol_links) if (symbol === leser.symbol_links)
{ {
figur_schieben(figur); figur_schieben(figur);
summand = +2; summand = +2;
} }
else if (symbol === aktor_leser.symbol_rechts) else if (symbol === leser.symbol_rechts)
{ {
figur_schieben(figur); figur_schieben(figur);
summand = -2; summand = -2;
@ -109,7 +164,7 @@ module mod_vtm_aufbau
{ {
summand = 0; 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); figur_bewegen(figur, richtung);
} }
@ -117,12 +172,16 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function aktor_leser_exportieren(aktor_leser : typ_aktor_leser) : any function leser_exportieren
(
leser : typ_leser
)
: any
{ {
return { return {
"richtung": richtung_exportieren(aktor_leser.richtung), "richtung": richtung_exportieren(leser.richtung),
"symbol_links": symbol_exportieren(aktor_leser.symbol_links), "symbol_links": symbol_exportieren(leser.symbol_links),
"symbol_rechts": symbol_exportieren(aktor_leser.symbol_rechts), "symbol_rechts": symbol_exportieren(leser.symbol_rechts),
}; };
} }
@ -130,10 +189,14 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function aktor_leser_importieren(roh : any) : typ_aktor_leser function leser_importieren
(
roh : any
)
: typ_leser
{ {
return ( return (
aktor_leser_erstellen leser_erstellen
( (
richtung_importieren(roh["richtung"]), richtung_importieren(roh["richtung"]),
symbol_importieren(roh["symbol_links"]), symbol_importieren(roh["symbol_links"]),
@ -142,6 +205,22 @@ module mod_vtm_aufbau
); );
} }
/**
* @author kcf <vidofnir@folksprak.org>
*/
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)),
}
;
} }

View file

@ -3,16 +3,16 @@
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 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 <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
@ -22,7 +22,7 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export type typ_aktor_schreiber = export type typ_schreiber =
{ {
richtung : typ_richtung; richtung : typ_richtung;
symbol : typ_symbol; symbol : typ_symbol;
@ -33,60 +33,16 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
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 { return {
"richtung": richtung, "richtung": richtung,
"symbol": symbol, "symbol": symbol,
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function aktor_schreiber_richtung_lesen(aktor_schreiber : typ_aktor_schreiber) : typ_richtung
{
return aktor_schreiber.richtung;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function aktor_schreiber_symbol_lesen(aktor_schreiber : typ_aktor_schreiber) : typ_symbol
{
return aktor_schreiber.symbol;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
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 <vidofnir@folksprak.org>
*/
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 <vidofnir@folksprak.org>
*/
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 <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
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 <vidofnir@folksprak.org>
*/
function schreiber_beispiel
(
)
: typ_schreiber
{
return schreiber_erstellen(0, 0);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function schreiber_richtung_lesen
(
schreiber : typ_schreiber
)
: typ_richtung
{
return schreiber.richtung;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function schreiber_symbol_lesen
(
schreiber : typ_schreiber
)
: typ_symbol
{
return schreiber.symbol;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function schreiber_drehen
(
schreiber : typ_schreiber,
inkrement : int = +1
)
: void
{
schreiber.richtung = richtung_addieren(schreiber.richtung, inkrement);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function schreiber_verwenden
(
schreiber : typ_schreiber,
figur : typ_figur
)
: void
{
figur_schreiben(figur, schreiber.symbol);
figur_bewegen(figur, schreiber.richtung);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function schreiber_exportieren
(
schreiber : typ_schreiber
)
: any
{
return {
"richtung": richtung_exportieren(schreiber.richtung),
"symbol": symbol_exportieren(schreiber.symbol),
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function schreiber_importieren
(
roh : any
)
: typ_schreiber
{ {
return ( return (
aktor_schreiber_erstellen schreiber_erstellen
( (
richtung_importieren(roh["richtung"]), richtung_importieren(roh["richtung"]),
symbol_importieren(roh["symbol"]) symbol_importieren(roh["symbol"])
@ -105,6 +162,22 @@ module mod_vtm_aufbau
); );
} }
/**
* @author kcf <vidofnir@folksprak.org>
*/
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)),
}
;
} }

View file

@ -3,16 +3,16 @@
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org> * Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 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 <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
@ -22,7 +22,7 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export type typ_aktor_verwerfer = export type typ_verwerfer =
{ {
} }
; ;
@ -31,7 +31,10 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function aktor_verwerfer_erstellen() : typ_aktor_verwerfer function verwerfer_erstellen
(
)
: typ_verwerfer
{ {
return { return {
}; };
@ -41,7 +44,36 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
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 <vidofnir@folksprak.org>
*/
function verwerfer_beispiel
(
)
: typ_verwerfer
{
return verwerfer_erstellen();
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function verwerfer_drehen
(
verwerfer : typ_verwerfer,
inkrement ?: int
)
: void
{ {
} }
@ -49,7 +81,12 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
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); figur_verwerfen(figur);
} }
@ -58,7 +95,11 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function aktor_verwerfer_exportieren(aktor_verwerfer : typ_aktor_verwerfer) : any function verwerfer_exportieren
(
verwerfer : typ_verwerfer
)
: any
{ {
return { return {
}; };
@ -68,15 +109,35 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function aktor_verwerfer_importieren(roh : any) : typ_aktor_verwerfer function verwerfer_importieren
(
roh : any
)
: typ_verwerfer
{ {
return ( return (
aktor_verwerfer_erstellen verwerfer_erstellen
( (
) )
); );
} }
/**
* @author kcf <vidofnir@folksprak.org>
*/
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)),
}
;
} }

View file

@ -22,85 +22,86 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export class klasse_akzeptoraufgabe export type typ_akzeptoraufgabe =
implements schnittstelle_aufgabe
{ {
id : string;
/** titel : string;
* @author kcf <vidofnir@folksprak.org> text : string;
*/ tests : Array<typ_akzeptortest>;
private id : string; }
;
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
private titel_ : string; export function akzeptoraufgabe_erstellen
(
id : string,
/** titel : string,
* @author kcf <vidofnir@folksprak.org> text : string,
*/ tests : Array<typ_akzeptortest>
private text_ : string; )
: typ_akzeptoraufgabe
/**
* @author kcf <vidofnir@folksprak.org>
*/
private tests_ : Array<schnittstelle_test>;
/**
* @author kcf <vidofnir@folksprak.org>
*/
public constructor(id : string, titel : string, text : string, tests : Array<klasse_akzeptortest>)
{ {
this.id = id; return {
this.titel_ = titel; "id": id,
this.text_ = text; "titel": titel,
this.tests_ = tests; "text": text,
"tests": tests,
};
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
* @implementation
*/ */
public id_lesen() : string export function akzeptoraufgabe_id
(
akzeptoraufgabe : typ_akzeptoraufgabe
)
: string
{ {
return this.id; return akzeptoraufgabe.id;
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
* @implementation
*/ */
public titel() : string export function akzeptoraufgabe_titel
(
akzeptoraufgabe : typ_akzeptoraufgabe
)
: string
{ {
return this.titel_; return akzeptoraufgabe.titel;
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
* @implementation
*/ */
public text() : string export function akzeptoraufgabe_text
(
akzeptoraufgabe : typ_akzeptoraufgabe
)
: string
{ {
return this.text_; return akzeptoraufgabe.text;
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
* @implementation
*/ */
public tests() : Array<schnittstelle_test> export function akzeptoraufgabe_tests
(
akzeptoraufgabe : typ_akzeptoraufgabe
)
: Array<typ_akzeptortest>
{ {
return this.tests_; return akzeptoraufgabe.tests;
}
} }
} }

View file

@ -22,51 +22,56 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export class klasse_akzeptortest export type typ_akzeptortest =
implements schnittstelle_test
{ {
eingabe : Array<typ_symbol>;
/** annehmen : boolean;
* @author kcf <vidofnir@folksprak.org> }
*/ ;
private eingabe_ : Array<typ_symbol>;
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
private annehmen : boolean; export function akzeptortest_erstellen
(
eingabe : Array<typ_symbol>,
/** annehmen : boolean
* @author kcf <vidofnir@folksprak.org> )
*/ : typ_akzeptortest
public constructor(eingabe : Array<typ_symbol>, annehmen : boolean)
{ {
this.eingabe_ = eingabe; return {
this.annehmen = annehmen; "eingabe": eingabe,
"annehmen": annehmen,
};
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
* @implementation
*/ */
public eingabe() : Array<typ_symbol> export function akzeptortest_eingabe
(
akzeptortest : typ_akzeptortest
)
: Array<typ_symbol>
{ {
return this.eingabe_; return akzeptortest.eingabe;
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
* @implementation
*/ */
public pruefen(angenommen : boolean, ausgabe : Array<typ_symbol>) : boolean export function akzeptortest_pruefen
(
akzeptortest : typ_akzeptortest,
angenommen : boolean,
ausgabe : Array<typ_symbol>
)
: boolean
{ {
return (this.annehmen === angenommen); return (akzeptortest.annehmen === angenommen);
}
} }
} }

View file

@ -22,32 +22,191 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export interface schnittstelle_aufgabe export type typ_aufgabe = typ_komplex<Object>;
/**
* @author kcf <vidofnir@folksprak.org>
*/
var _liste : Array<typ_aufgabe> = [];
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function aufgabe_id
(
aufgabe : typ_aufgabe
)
: string
{ {
return (
/** fallunterscheidung<string>
* @author kcf <vidofnir@folksprak.org> (
*/ aufgabe,
id_lesen() : string; {
"akzeptoraufgabe": (angaben) => akzeptoraufgabe_id(angaben),
"transduktoraufgabe": (angaben) => transduktoraufgabe_id(angaben),
}
)
);
}
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
titel() : string; export function aufgabe_titel
(
aufgabe : typ_aufgabe
)
: string
{
return (
fallunterscheidung<string>
(
aufgabe,
{
"akzeptoraufgabe": (angaben) => akzeptoraufgabe_titel(angaben),
"transduktoraufgabe": (angaben) => transduktoraufgabe_titel(angaben),
}
)
);
}
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
text() : string; export function aufgabe_text
(
aufgabe : typ_aufgabe
)
: string
{
return (
fallunterscheidung<string>
(
aufgabe,
{
"akzeptoraufgabe": (angaben) => akzeptoraufgabe_text(angaben),
"transduktoraufgabe": (angaben) => transduktoraufgabe_text(angaben),
}
)
);
}
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
tests() : Array<schnittstelle_test>; export function aufgabe_tests
(
aufgabe : typ_aufgabe
)
: Array<typ_test>
{
return (
fallunterscheidung<Array<typ_test>>
(
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 <vidofnir@folksprak.org>
*/
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 <vidofnir@folksprak.org>
*/
export function aufgabe_registrieren(aufgabe : typ_aufgabe) : void
{
_liste.push(aufgabe);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function aufgabe_holen(index : int) : typ_aufgabe
{
return _liste[index];
} }
} }

View file

@ -1,95 +0,0 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
module mod_vtm_aufbau
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
var _liste : Array<schnittstelle_aufgabe> = [];
/**
* @author kcf <vidofnir@folksprak.org>
*/
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 <vidofnir@folksprak.org>
*/
export function aufgabe_registrieren(aufgabe : schnittstelle_aufgabe) : void
{
_liste.push(aufgabe);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function aufgabe_holen(index : int) : schnittstelle_aufgabe
{
return _liste[index];
}
}

View file

@ -22,21 +22,100 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export interface schnittstelle_test export type typ_test = typ_komplex<Object>;
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function test_eingabe
(
test : typ_test
)
: Array<typ_symbol>
{ {
return (
/** fallunterscheidung<Array<typ_symbol>>
* @author kcf <vidofnir@folksprak.org> (
* @implementation test,
*/ {
eingabe() : Array<typ_symbol>; "akzeptortest": (angaben) => akzeptortest_eingabe(angaben),
"transduktortest": (angaben) => transduktortest_eingabe(angaben),
}
)
);
}
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
pruefen(angenommen : boolean, ausgabe : Array<typ_symbol>) : boolean; export function test_pruefen
(
test : typ_test,
angenommen : boolean,
ausgabe : Array<typ_symbol>
)
: boolean
{
return (
fallunterscheidung<boolean>
(
test,
{
"akzeptortest": (angaben) => akzeptortest_pruefen(angaben, angenommen, ausgabe),
"transduktortest": (angaben) => transduktortest_pruefen(angaben, angenommen, ausgabe),
}
)
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
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;
}
}
} }
} }

View file

@ -22,85 +22,86 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export class klasse_transduktoraufgabe export type typ_transduktoraufgabe =
implements schnittstelle_aufgabe
{ {
id : string;
/** titel : string;
* @author kcf <vidofnir@folksprak.org> text : string;
*/ tests : Array<typ_transduktortest>;
private id : string; }
;
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
private titel_ : string; export function transduktoraufgabe_erstellen
(
id : string,
/** titel : string,
* @author kcf <vidofnir@folksprak.org> text : string,
*/ tests : Array<typ_transduktortest>
private text_ : string; )
: typ_transduktoraufgabe
/**
* @author kcf <vidofnir@folksprak.org>
*/
private tests_ : Array<schnittstelle_test>;
/**
* @author kcf <vidofnir@folksprak.org>
*/
public constructor(id : string, titel : string, text : string, tests : Array<klasse_transduktortest>)
{ {
this.id = id; return {
this.titel_ = titel; "id": id,
this.text_ = text; "titel": titel,
this.tests_ = tests; "text": text,
"tests": tests,
};
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
* @implementation
*/ */
public id_lesen() : string export function transduktoraufgabe_id
(
transduktoraufgabe : typ_transduktoraufgabe
)
: string
{ {
return this.id; return transduktoraufgabe.id;
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
* @implementation
*/ */
public titel() : string export function transduktoraufgabe_titel
(
transduktoraufgabe : typ_transduktoraufgabe
)
: string
{ {
return this.titel_; return transduktoraufgabe.titel;
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
* @implementation
*/ */
public text() : string export function transduktoraufgabe_text
(
transduktoraufgabe : typ_transduktoraufgabe
)
: string
{ {
return this.text_; return transduktoraufgabe.text;
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
* @implementation
*/ */
public tests() : Array<schnittstelle_test> export function transduktoraufgabe_tests
(
transduktoraufgabe : typ_transduktoraufgabe
)
: Array<typ_transduktortest>
{ {
return this.tests_; return transduktoraufgabe.tests;
}
} }
} }

View file

@ -22,58 +22,65 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export class klasse_transduktortest export type typ_transduktortest =
implements schnittstelle_test
{ {
eingabe : Array<typ_symbol>;
/** ausgabe : Array<typ_symbol>;
* @author kcf <vidofnir@folksprak.org> }
*/ ;
private eingabe_ : Array<typ_symbol>;
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
private ausgabe : Array<typ_symbol>; export function transduktortest_erstellen
(
eingabe : Array<typ_symbol>,
/** ausgabe : Array<typ_symbol>
* @author kcf <vidofnir@folksprak.org> )
*/ : typ_transduktortest
public constructor(eingabe : Array<typ_symbol>, ausgabe : Array<typ_symbol>)
{ {
this.eingabe_ = eingabe; return {
this.ausgabe = ausgabe; "eingabe": eingabe,
"ausgabe": ausgabe,
};
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
* @implementation
*/ */
public eingabe() : Array<typ_symbol> export function transduktortest_eingabe
(
transduktortest : typ_transduktortest
)
: Array<typ_symbol>
{ {
return this.eingabe_; return transduktortest.eingabe;
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
* @implementation
*/ */
public pruefen(angenommen : boolean, ausgabe : Array<typ_symbol>) : boolean export function transduktortest_pruefen
(
transduktortest : typ_transduktortest,
angenommen : boolean,
ausgabe : Array<typ_symbol>
)
: boolean
{ {
if (this.ausgabe.length !== ausgabe.length) if (transduktortest.ausgabe.length !== ausgabe.length)
{ {
return false; return false;
} }
else else
{ {
let gleich : boolean = true; let gleich : boolean = true;
for (let index : int = 0; index < this.ausgabe.length; index += 1) for (let index : int = 0; index < transduktortest.ausgabe.length; index += 1)
{ {
if (! symbol_vergleichen(this.ausgabe[index], ausgabe[index])) if (! symbol_vergleichen(transduktortest.ausgabe[index], ausgabe[index]))
{ {
gleich = false; gleich = false;
break; break;
@ -89,5 +96,3 @@ module mod_vtm_aufbau
} }
}

View file

@ -26,7 +26,7 @@ module mod_vtm_aufbau
{ {
welt : typ_welt; welt : typ_welt;
figur : schnittstelle_fehlermonade<typ_figur>; figur : schnittstelle_fehlermonade<typ_figur>;
aufgabe : schnittstelle_aufgabe; aufgabe : typ_aufgabe;
testindex : schnittstelle_fehlermonade<int>; testindex : schnittstelle_fehlermonade<int>;
modus : typ_modus; modus : typ_modus;
lauscher : {[ereignis : string] : Array<(angaben ?: any)=>void>}; lauscher : {[ereignis : string] : Array<(angaben ?: any)=>void>};
@ -39,7 +39,7 @@ module mod_vtm_aufbau
*/ */
export function partie_erstellen export function partie_erstellen
( (
aufgabe : schnittstelle_aufgabe aufgabe : typ_aufgabe
) )
: typ_partie : typ_partie
{ {
@ -127,7 +127,7 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export function partie_aufgabe_lesen(partie : typ_partie) : schnittstelle_aufgabe export function partie_aufgabe_lesen(partie : typ_partie) : typ_aufgabe
{ {
return partie.aufgabe; return partie.aufgabe;
} }
@ -136,7 +136,7 @@ module mod_vtm_aufbau
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
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.aufgabe = aufgabe;
// partie.welt_leeren(); // partie.welt_leeren();
@ -272,8 +272,8 @@ module mod_vtm_aufbau
{ {
if (! partie.figur.ist_schlicht()) if (! partie.figur.ist_schlicht())
{ {
let test : schnittstelle_test = partie.aufgabe.tests()[partie.testindex.lesen()]; let test : typ_test = aufgabe_tests(partie.aufgabe)[partie.testindex.lesen()];
let band : Array<typ_symbol> = mod_vtm_helfer.liste_kopieren<typ_symbol>(test.eingabe()); let band : Array<typ_symbol> = mod_vtm_helfer.liste_kopieren<typ_symbol>(test_eingabe(test));
let stelle : typ_stelle = welt_erzeuger_finden(partie.welt); let stelle : typ_stelle = welt_erzeuger_finden(partie.welt);
partie.figur = ( partie.figur = (
new klasse_schlicht<typ_figur> new klasse_schlicht<typ_figur>
@ -291,7 +291,7 @@ module mod_vtm_aufbau
let figur : typ_figur = partie.figur.lesen(); let figur : typ_figur = partie.figur.lesen();
let stelle : typ_stelle = figur_stelle_lesen(figur); let stelle : typ_stelle = figur_stelle_lesen(figur);
let aktor_ : schnittstelle_fehlermonade<typ_aktor> = welt_feld_holen(partie.welt, stelle); let aktor_ : schnittstelle_fehlermonade<typ_aktor> = 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); aktor_verwenden(aktor, figur);
let zustand : typ_zustand = figur_zustand_lesen(figur); let zustand : typ_zustand = figur_zustand_lesen(figur);
if (zustand === zustand_laufend) if (zustand === zustand_laufend)
@ -304,9 +304,9 @@ module mod_vtm_aufbau
let ausgabe : Array<typ_symbol> = figur_band_lesen(figur); let ausgabe : Array<typ_symbol> = figur_band_lesen(figur);
partie.figur = (new klasse_nichts<typ_figur>()); partie.figur = (new klasse_nichts<typ_figur>());
let testindex : int = partie.testindex.lesen(); let testindex : int = partie.testindex.lesen();
let tests : Array<schnittstelle_test> = partie.aufgabe.tests(); let tests : Array<typ_test> = aufgabe_tests(partie.aufgabe);
let test : schnittstelle_test = tests[testindex]; let test : typ_test = tests[testindex];
if (! test.pruefen(angenommen, ausgabe)) if (! test_pruefen(test, angenommen, ausgabe))
{ {
partie.modus = modus_fehlerhaft; partie.modus = modus_fehlerhaft;
partie_benachrichtigen(partie, "aenderung_modus", {}); partie_benachrichtigen(partie, "aenderung_modus", {});

View file

@ -90,7 +90,7 @@ module mod_vtm_aufbau
[ [
{ {
"pruefer": (aktor) => (aktor.art === "befoerderer"), "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") if (aktor.art === "schreiber")
{ {
return (aktor_schreiber_symbol_lesen(aktor.angaben) === symbol); return (schreiber_symbol_lesen(aktor.angaben) === symbol);
} }
else 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") if (aktor.art === "leser")
{ {
return ( 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 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,17 +154,18 @@ module mod_vtm_aufbau
[ [
{ {
"pruefer": (aktor) => (aktor.art === "verwerfer"), "pruefer": (aktor) => (aktor.art === "verwerfer"),
"ersteller": () => aktor_erstellen("verwerfer"), "ersteller": () => verwerfer_erstellen_aktor(),
}, },
] ]
) )
); );
let index_alt : schnittstelle_fehlermonade<int>; let index_alt : schnittstelle_fehlermonade<int>;
let aktor_alt_ : schnittstelle_fehlermonade<typ_aktor> = welt.felder.holen(stelle); let aktor_alt_ : schnittstelle_fehlermonade<typ_aktor> = welt.felder.holen(stelle);
if (aktor_alt_.ist_schlicht) if (aktor_alt_.ist_schlicht())
{ {
let aktor_alt : typ_aktor = aktor_alt_.lesen(); let aktor_alt : typ_aktor = aktor_alt_.lesen();
let gefunden : boolean = liste.some let gefunden : boolean = (
liste.some
( (
(eintrag, index) => (eintrag, index) =>
{ {
@ -179,7 +180,7 @@ module mod_vtm_aufbau
} }
} }
) )
; );
if (! gefunden) if (! gefunden)
{ {
index_alt = (new klasse_nichts<int>()); index_alt = (new klasse_nichts<int>());
@ -281,15 +282,15 @@ module mod_vtm_aufbau
let aktor : typ_aktor; let aktor : typ_aktor;
if ((u === -groesse) && (v === 0)) if ((u === -groesse) && (v === 0))
{ {
aktor = aktor_erstellen("erzeuger", {"richtung": 0}); aktor = erzeuger_erstellen_aktor(0);
} }
else if ((u === +groesse) && (v === 0)) else if ((u === +groesse) && (v === 0))
{ {
aktor = aktor_erstellen("annehmer", {}); aktor = annehmer_erstellen_aktor();
} }
else else
{ {
aktor = aktor_erstellen("verwerfer", {}); aktor = verwerfer_erstellen_aktor();
} }
welt.felder.setzen(stelle, aktor); welt.felder.setzen(stelle, aktor);
} }

View file

@ -0,0 +1,58 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* @author kcf <vidofnir@folksprak.org>
*/
type typ_komplex<typ_angaben> = {art : string; angaben ?: typ_angaben;};
/**
* @author kcf <vidofnir@folksprak.org>
*/
function fallunterscheidung<typ_ergebnis>
(
komplex : typ_komplex<any>,
faelle : {[art : string] : (angaben ?: any)=>typ_ergebnis},
ersatz : schnittstelle_fehlermonade<(komplex : typ_komplex<any>)=>typ_ergebnis> = (new klasse_nichts<(komplex : typ_komplex<any>)=>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"));
}
}
}

View file

@ -19,7 +19,7 @@
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
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<Array<any>> = mod_vtm_daten.lesen("aufgaben"); let aufgaben_roh_ : schnittstelle_fehlermonade<Array<any>> = mod_vtm_daten.lesen("aufgaben");
if (aufgaben_roh_.ist_schlicht()) if (aufgaben_roh_.ist_schlicht())
@ -32,7 +32,7 @@ function aufgaben_eintragen(behandler : (aufgabe : mod_vtm_aufbau.schnittstelle_
{ {
// Aufgabe registrieren // 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); mod_vtm_aufbau.aufgabe_registrieren(aufgabe);
} }
// Option eintragen // Option eintragen
@ -60,7 +60,7 @@ function aufgaben_eintragen(behandler : (aufgabe : mod_vtm_aufbau.schnittstelle_
{ {
let value : string = dom_auswahl["value"]; let value : string = dom_auswahl["value"];
let index : int = parseInt(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); behandler(aufgabe);
} }
) )
@ -115,27 +115,27 @@ function haupt() : void
let hoehe : float = 80; 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"), "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"), "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"), "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"), "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"), "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"), "bereich": document.querySelector("#hilfe_aktoren_aktor_leser"),
}, },
] ]
@ -143,9 +143,23 @@ function haupt() : void
( (
eintrag => eintrag =>
{ {
let manifestor = (new mod_vtm_manifestation.klasse_svg_aktor(eintrag.aufbau, mod_vtm_aufbau.stelle_null())); let manifestor = (
let xmlknoten : mod_vtm_helfer.schnittstelle_xmlknoten = mod_vtm_manifestation.svg_wurzel(von_x, von_y, bis_x, bis_y, breite, hoehe, [manifestor.darstellen()]); mod_vtm_manifestation.svg_aktor_erstellen_manifestation
eintrag.bereich.querySelector(".hilfe_aktoren_aktor_bild").innerHTML = xmlknoten.darstellen(); (
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 // Spiel
{ {
let aufbau : mod_vtm_aufbau.typ_partie; // let aufbau : mod_vtm_aufbau.typ_partie;
aufgaben_eintragen 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)); 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(); mod_vtm_manifestation.manifestation_einrichten
(new mod_vtm_manifestation.klasse_speicher_partie(aufbau)).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;
/** /**

View file

@ -1,160 +0,0 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
module mod_vtm_helfer
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
function einrueckung(tiefe : int, zeichen : string = "\t") : string
{
return ((tiefe === 0) ? "" : (zeichen + einrueckung(tiefe-1)));
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export interface schnittstelle_xmlknoten
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
darstellen(tiefe ?: int) : string;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export class klasse_xmlknoten_text
implements schnittstelle_xmlknoten
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
private inhalt : string;
/**
* @author kcf <vidofnir@folksprak.org>
*/
public constructor(inhalt : string)
{
this.inhalt = inhalt;
}
/**
* @author kcf <vidofnir@folksprak.org>
* @implementation
*/
public darstellen(tiefe : int = 0) : string
{
return this.inhalt;
}
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export class klasse_xmlknoten_normal
implements schnittstelle_xmlknoten
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
private name : string;
/**
* @author kcf <vidofnir@folksprak.org>
*/
private attribute : {[schluessel : string] : string} = {};
/**
* @author kcf <vidofnir@folksprak.org>
*/
private kinder : Array<schnittstelle_xmlknoten> = [];
/**
* @author kcf <vidofnir@folksprak.org>
*/
public constructor(name : string, attribute : {[schluessel : string] : string} = {}, kinder : Array<schnittstelle_xmlknoten> = [])
{
this.name = name;
this.attribute = attribute;
this.kinder = kinder;
}
/**
* @author kcf <vidofnir@folksprak.org>
* @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;
}
}
}

View file

@ -0,0 +1,53 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
module mod_vtm_helfer
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type typ_xmlknoten = typ_komplex<any>;
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type schnittstelle_xmlknoten =
{
darstellen : (xmlknoten : typ_xmlknoten, tiefe : int)=>string;
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
export var implementierung_xmlknoten : {[art : string] : schnittstelle_xmlknoten} = {};
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function xmlknoten_darstellen(xmlknoten : typ_xmlknoten, tiefe : int = 0) : string
{
return implementierung_xmlknoten[xmlknoten.art].darstellen(xmlknoten, tiefe);
}
}

View file

@ -0,0 +1,132 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
module mod_vtm_helfer
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
function einrueckung(tiefe : int, zeichen : string = "\t") : string
{
return ((tiefe === 0) ? "" : (zeichen + einrueckung(tiefe-1)));
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type typ_xmlknoten_normal =
{
name : string;
attribute : {[schluessel : string] : string};
kinder : Array<typ_xmlknoten>;
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
function xmlknoten_normal_erstellen
(
name : string,
attribute : {[schluessel : string] : string} = {},
kinder : Array<typ_xmlknoten> = []
)
: typ_xmlknoten_normal
{
return {
"name": name,
"attribute": attribute,
"kinder": kinder
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function xmlknoten_normal_erstellen_erweitert
(
name : string,
attribute : {[schluessel : string] : string} = {},
kinder : Array<typ_xmlknoten> = []
)
: typ_xmlknoten
{
return {
"art": "normal",
"angaben": xmlknoten_normal_erstellen(name, attribute, kinder)
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
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 <vidofnir@folksprak.org>
*/
implementierung_xmlknoten["normal"] =
{
"darstellen": (xmlknoten, tiefe) => xmlknoten_normal_darstellen(xmlknoten.angaben, tiefe),
}
;
}

View file

@ -0,0 +1,69 @@
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
module mod_vtm_helfer
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type typ_xmlknoten_text =
{
inhalt : string
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
function xmlknoten_text_erstellen(inhalt : string) : typ_xmlknoten_text
{
return {"inhalt": inhalt};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function xmlknoten_text_erstellen_erweitert(inhalt : string) : typ_xmlknoten
{
return {"art": "text", "angaben": xmlknoten_text_erstellen(inhalt)};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function xmlknoten_text_darstellen(xmlknoten_text : typ_xmlknoten_text, tiefe : int) : string
{
return xmlknoten_text.inhalt;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
implementierung_xmlknoten["text"] =
{
"darstellen": (xmlknoten, tiefe) => xmlknoten_text_darstellen(xmlknoten.angaben, tiefe),
}
;
}

View file

@ -22,45 +22,51 @@ module mod_vtm_manifestation
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export abstract class klasse_manifestation<typ_aufbau, typ_ausgabe> export type typ_manifestation<typ_aufbau> = typ_komplex<any>;
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type schnittstelle_manifestation<typ_aufbau, typ_ausgabe> =
{ {
darstellen : (manifestation : typ_manifestation<typ_aufbau>)=>typ_ausgabe;
/** binden : (manifestation : typ_manifestation<typ_aufbau>)=>void;
* @author kcf <vidofnir@folksprak.org> }
*/ ;
protected aufbau : typ_aufbau;
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
public constructor(aufbau : typ_aufbau) export var implementierung_manifestation : {[art : string] : schnittstelle_manifestation<any, any>} = {};
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function manifestation_darstellen<typ_aufbau, typ_ausgabe>(manifestation : typ_manifestation<typ_aufbau>) : typ_ausgabe
{ {
this.aufbau = aufbau; return implementierung_manifestation[manifestation.art].darstellen(manifestation);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
public abstract darstellen() : typ_ausgabe; export function manifestation_binden<typ_aufbau, typ_ausgabe>(manifestation : typ_manifestation<typ_aufbau>) : void
/**
* @author kcf <vidofnir@folksprak.org>
*/
public abstract binden() : void;
/**
* @author kcf <vidofnir@folksprak.org>
*/
public einrichten() : void
{ {
this.darstellen(); return implementierung_manifestation[manifestation.art].binden(manifestation);
this.binden(); }
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function manifestation_einrichten<typ_aufbau, typ_ausgabe>(manifestation : typ_manifestation<typ_aufbau>) : void
{
manifestation_darstellen<typ_aufbau, typ_ausgabe>(manifestation);
manifestation_binden<typ_aufbau, typ_ausgabe>(manifestation);
} }
} }

View file

@ -28,8 +28,8 @@ module mod_vtm_manifestation
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
var position_basis1 : typ_position = mod_vtm_helfer.vektor_polar(0/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.0 * (2*Math.PI)); var position_basis2 : typ_position = mod_vtm_helfer.vektor_polar((2/6) * (2*Math.PI));
/** /**

View file

@ -22,24 +22,56 @@ module mod_vtm_manifestation
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export class klasse_speicher_partie export type typ_speicher_partie =
extends klasse_manifestation<mod_vtm_aufbau.typ_partie, void>
{ {
aufbau : mod_vtm_aufbau.typ_partie;
}
;
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
public constructor(aufbau : mod_vtm_aufbau.typ_partie) export function speicher_partie_erstellen
(
aufbau : mod_vtm_aufbau.typ_partie
)
: typ_speicher_partie
{ {
super(aufbau); return {
"aufbau": aufbau
};
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
* @override
*/ */
public einrichten() : void export function speicher_partie_erstellen_erweitert
(
aufbau : mod_vtm_aufbau.typ_partie
)
: typ_manifestation<mod_vtm_aufbau.typ_partie>
{
return {
"art": "speicher_partie",
"angaben": speicher_partie_erstellen(aufbau)
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function speicher_partie_darstellen(speicher_partie : typ_speicher_partie) : void
{
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function speicher_partie_binden(speicher_partie : typ_speicher_partie) : void
{ {
mod_vtm_aufbau.partie_lauschen mod_vtm_aufbau.partie_lauschen
( (
@ -48,7 +80,7 @@ module mod_vtm_manifestation
(angaben) => (angaben) =>
{ {
// console.info("aenderung_aufgabe", angaben); // console.info("aenderung_aufgabe", angaben);
let id : string = mod_vtm_aufbau.partie_aufgabe_lesen(this.aufbau).id_lesen(); let id : string = mod_vtm_aufbau.aufgabe_id(mod_vtm_aufbau.partie_aufgabe_lesen(this.aufbau))
let key : string = ("vtm_" + id); let key : string = ("vtm_" + id);
if (key in localStorage) if (key in localStorage)
{ {
@ -70,7 +102,7 @@ module mod_vtm_manifestation
"aenderung_welt", "aenderung_welt",
(angaben) => (angaben) =>
{ {
let id : string = mod_vtm_aufbau.partie_aufgabe_lesen(this.aufbau).id_lesen(); let id : string = mod_vtm_aufbau.aufgabe_id(mod_vtm_aufbau.partie_aufgabe_lesen(this.aufbau))
let key : string = ("vtm_" + id); let key : string = ("vtm_" + id);
let item : string = JSON.stringify(mod_vtm_aufbau.welt_exportieren(mod_vtm_aufbau.partie_welt_lesen(this.aufbau))); let item : string = JSON.stringify(mod_vtm_aufbau.welt_exportieren(mod_vtm_aufbau.partie_welt_lesen(this.aufbau)));
localStorage.setItem(key, item); localStorage.setItem(key, item);
@ -97,32 +129,18 @@ module mod_vtm_manifestation
} }
) )
; ;
this.darstellen();
this.binden();
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
* @implementation
*/ */
public darstellen() : void implementierung_manifestation["speicher_partie"] =
{ {
console.warn("empty"); "darstellen": (manifestation) => speicher_partie_darstellen(manifestation.angaben),
} "binden": (manifestation) => speicher_partie_binden(manifestation.angaben),
/**
* @author kcf <vidofnir@folksprak.org>
* @implementation
*/
public binden() : void
{
console.warn("empty");
}
} }
;
} }

View file

@ -22,39 +22,60 @@ module mod_vtm_manifestation
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export class klasse_svg_aktor export type typ_svg_aktor =
extends klasse_manifestation<mod_vtm_aufbau.typ_aktor, mod_vtm_helfer.schnittstelle_xmlknoten>
{ {
aufbau : mod_vtm_aufbau.typ_aktor;
/** stelle : mod_vtm_aufbau.typ_stelle;
* @author kcf <vidofnir@folksprak.org> }
*/ ;
private stelle : mod_vtm_aufbau.typ_stelle;
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
public constructor(aufbau : mod_vtm_aufbau.typ_aktor, stelle : mod_vtm_aufbau.typ_stelle) function svg_aktor_erstellen
(
aufbau : mod_vtm_aufbau.typ_aktor,
stelle : mod_vtm_aufbau.typ_stelle
)
: typ_svg_aktor
{ {
super(aufbau); return {
this.stelle = stelle; "aufbau": aufbau,
"stelle": stelle
};
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
* @implementation
*/ */
public darstellen() : mod_vtm_helfer.schnittstelle_xmlknoten export function svg_aktor_erstellen_manifestation
(
aufbau : mod_vtm_aufbau.typ_aktor,
stelle : mod_vtm_aufbau.typ_stelle
)
: typ_manifestation<mod_vtm_aufbau.typ_aktor>
{ {
let aktor : mod_vtm_aufbau.typ_aktor = this.aufbau; return {
let knoten_rahmen = function () : mod_vtm_helfer.schnittstelle_xmlknoten "art": "svg_aktor",
"angaben": svg_aktor_erstellen(aufbau, stelle),
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
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
{ {
return ( return (
svg_pfad svg_pfad
( (
mod_vtm_helfer.sequenz(6).map(i => mod_vtm_helfer.vektor_polar(((i+0.5)/6.0) * (2*Math.PI), 0.5)), mod_vtm_helfer.sequenz(6).map(i => mod_vtm_helfer.vektor_polar(((i+0.5)/6) * (2*Math.PI), 0.5)),
true, true,
{ {
"class": "rahmen" "class": "rahmen"
@ -63,15 +84,17 @@ module mod_vtm_manifestation
); );
} }
; ;
let kinder_feld : Array<mod_vtm_helfer.schnittstelle_xmlknoten> = []; let kinder_feld : Array<mod_vtm_helfer.typ_xmlknoten> = [];
switch (aktor.art) fallunterscheidung<void>
(
aktor,
{ {
case "erzeuger": "erzeuger": (angaben) =>
{ {
kinder_feld.push(knoten_rahmen()); kinder_feld.push(knoten_rahmen());
let richtung : mod_vtm_aufbau.typ_richtung = mod_vtm_aufbau.aktor_erzeuger_richtung_lesen(aktor.angaben); let richtung : mod_vtm_aufbau.typ_richtung = mod_vtm_aufbau.erzeuger_richtung_lesen(angaben);
let knoten_pfeil : mod_vtm_helfer.schnittstelle_xmlknoten = ( let knoten_pfeil : mod_vtm_helfer.typ_xmlknoten = (
new mod_vtm_helfer.klasse_xmlknoten_normal mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert
( (
"path", "path",
{ {
@ -84,7 +107,7 @@ module mod_vtm_manifestation
), ),
"transform": ( "transform": (
[ [
"rotate(" + ((richtung/6.0) * 360).toFixed(svg_float_praezission) + ")", "rotate(" + ((richtung/6) * 360).toFixed(svg_float_praezission) + ")",
"translate(-0.2, 0)", "translate(-0.2, 0)",
"scale(0.12)", "scale(0.12)",
].join(" ") ].join(" ")
@ -93,14 +116,14 @@ module mod_vtm_manifestation
) )
); );
kinder_feld.push(knoten_pfeil); kinder_feld.push(knoten_pfeil);
break;
} }
case "befoerderer": ,
"befoerderer": (angaben) =>
{ {
kinder_feld.push(knoten_rahmen()); kinder_feld.push(knoten_rahmen());
let richtung : mod_vtm_aufbau.typ_richtung = mod_vtm_aufbau.aktor_befoerderer_richtung_lesen(aktor.angaben); let richtung : mod_vtm_aufbau.typ_richtung = mod_vtm_aufbau.befoerderer_richtung_lesen(angaben);
let knoten_pfeil : mod_vtm_helfer.schnittstelle_xmlknoten = ( let knoten_pfeil : mod_vtm_helfer.typ_xmlknoten = (
new mod_vtm_helfer.klasse_xmlknoten_normal mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert
( (
"path", "path",
{ {
@ -113,7 +136,7 @@ module mod_vtm_manifestation
), ),
"transform": ( "transform": (
[ [
"rotate(" + ((richtung/6.0) * 360).toFixed(svg_float_praezission) + ")", "rotate(" + ((richtung/6) * 360).toFixed(svg_float_praezission) + ")",
"translate(-0.2, 0)", "translate(-0.2, 0)",
"scale(0.12)", "scale(0.12)",
].join(" ") ].join(" ")
@ -122,15 +145,15 @@ module mod_vtm_manifestation
) )
); );
kinder_feld.push(knoten_pfeil); kinder_feld.push(knoten_pfeil);
break;
} }
case "schreiber": ,
"schreiber": (angaben) =>
{ {
kinder_feld.push(knoten_rahmen()); kinder_feld.push(knoten_rahmen());
let richtung : mod_vtm_aufbau.typ_richtung = mod_vtm_aufbau.aktor_schreiber_richtung_lesen(aktor.angaben); let richtung : mod_vtm_aufbau.typ_richtung = mod_vtm_aufbau.schreiber_richtung_lesen(angaben);
let symbol : mod_vtm_aufbau.typ_symbol = mod_vtm_aufbau.aktor_schreiber_symbol_lesen(aktor.angaben); let symbol : mod_vtm_aufbau.typ_symbol = mod_vtm_aufbau.schreiber_symbol_lesen(angaben);
let knoten_pfeil : mod_vtm_helfer.schnittstelle_xmlknoten = ( let knoten_pfeil : mod_vtm_helfer.typ_xmlknoten = (
new mod_vtm_helfer.klasse_xmlknoten_normal mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert
( (
"path", "path",
{ {
@ -143,7 +166,7 @@ module mod_vtm_manifestation
), ),
"transform": ( "transform": (
[ [
"rotate(" + ((richtung/6.0) * 360).toFixed(svg_float_praezission) + ")", "rotate(" + ((richtung/6) * 360).toFixed(svg_float_praezission) + ")",
"translate(-0.2, 0)", "translate(-0.2, 0)",
"scale(0.12)", "scale(0.12)",
].join(" ") ].join(" ")
@ -152,14 +175,14 @@ module mod_vtm_manifestation
) )
); );
kinder_feld.push(knoten_pfeil); kinder_feld.push(knoten_pfeil);
break;
} }
case "leser": ,
"leser": (angaben) =>
{ {
kinder_feld.push(knoten_rahmen()); kinder_feld.push(knoten_rahmen());
let richtung : mod_vtm_aufbau.typ_richtung = mod_vtm_aufbau.aktor_leser_richtung_lesen(aktor.angaben); 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.aktor_leser_symbol_links_lesen(aktor.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.aktor_leser_symbol_rechts_lesen(aktor.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<mod_vtm_aufbau.typ_symbol>;}> = let ausgaenge : Array<{summand : mod_vtm_aufbau.typ_richtung, symbol : schnittstelle_fehlermonade<mod_vtm_aufbau.typ_symbol>;}> =
[ [
{ {
@ -180,9 +203,9 @@ module mod_vtm_manifestation
( (
eintrag => eintrag =>
{ {
let winkel : float = ((mod_vtm_aufbau.richtung_addieren(richtung, eintrag.summand) / 6.0) * 360); let winkel : float = ((mod_vtm_aufbau.richtung_addieren(richtung, eintrag.summand) / 6) * 360);
let knoten_pfeil : mod_vtm_helfer.schnittstelle_xmlknoten = ( let knoten_pfeil : mod_vtm_helfer.typ_xmlknoten = (
new mod_vtm_helfer.klasse_xmlknoten_normal mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert
( (
"path", "path",
{ {
@ -212,13 +235,13 @@ module mod_vtm_manifestation
} }
) )
; ;
break;
} }
case "verwerfer": ,
"verwerfer": (angaben) =>
{ {
kinder_feld.push(knoten_rahmen()); kinder_feld.push(knoten_rahmen());
let knoten_kreis : mod_vtm_helfer.schnittstelle_xmlknoten = ( let knoten_kreis : mod_vtm_helfer.typ_xmlknoten = (
new mod_vtm_helfer.klasse_xmlknoten_normal mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert
( (
"circle", "circle",
{ {
@ -235,13 +258,13 @@ module mod_vtm_manifestation
) )
); );
kinder_feld.push(knoten_kreis); kinder_feld.push(knoten_kreis);
break;
} }
case "annehmer": ,
"annehmer": (angaben) =>
{ {
kinder_feld.push(knoten_rahmen()); kinder_feld.push(knoten_rahmen());
let knoten_kreis : mod_vtm_helfer.schnittstelle_xmlknoten = ( let knoten_kreis : mod_vtm_helfer.typ_xmlknoten = (
new mod_vtm_helfer.klasse_xmlknoten_normal mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert
( (
"circle", "circle",
{ {
@ -258,24 +281,20 @@ module mod_vtm_manifestation
) )
); );
kinder_feld.push(knoten_kreis); 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 = ( let position : typ_position = position_von_stelle(svg_aktor.stelle);
new mod_vtm_helfer.klasse_xmlknoten_normal let knoten_feld : mod_vtm_helfer.typ_xmlknoten = (
mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert
( (
"g", "g",
{ {
"class": "feld", "class": "feld",
"rel": mod_vtm_aufbau.stelle_hash(this.stelle), "rel": mod_vtm_aufbau.stelle_hash(svg_aktor.stelle),
"transform": ("translate(" + position.x.toFixed(svg_float_praezission) + ", " + position.y.toFixed(svg_float_praezission) + ")"), "transform": ("translate" + "(" + position.x.toFixed(svg_float_praezission) + ", " + position.y.toFixed(svg_float_praezission) + ")"),
}, },
kinder_feld kinder_feld
) )
@ -286,13 +305,13 @@ module mod_vtm_manifestation
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
* @implementation
*/ */
public binden() : void implementierung_manifestation["svg_aktor"] =
{ {
"darstellen": (manifestation) => svg_aktor_darstellen(manifestation.angaben),
"binden": (manifestation) => {},
} }
;
}
} }

View file

@ -22,31 +22,59 @@ module mod_vtm_manifestation
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export class klasse_svg_figur export type typ_svg_figur =
extends klasse_manifestation<mod_vtm_aufbau.typ_figur, mod_vtm_helfer.schnittstelle_xmlknoten>
{ {
aufbau : mod_vtm_aufbau.typ_figur;
}
;
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
public constructor(aufbau : mod_vtm_aufbau.typ_figur) function svg_figur_erstellen
(
aufbau : mod_vtm_aufbau.typ_figur
)
: typ_svg_figur
{ {
super(aufbau); return {
"aufbau": aufbau,
};
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
* @implementation
*/ */
public darstellen() : mod_vtm_helfer.schnittstelle_xmlknoten export function svg_figur_erstellen_manifestation
(
aufbau : mod_vtm_aufbau.typ_figur
)
: typ_manifestation<mod_vtm_aufbau.typ_figur>
{ {
let figur : mod_vtm_aufbau.typ_figur = this.aufbau; return {
let kinder_figur : Array<mod_vtm_helfer.schnittstelle_xmlknoten> = []; "art": "svg_figur",
"angaben": svg_figur_erstellen(aufbau),
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
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<mod_vtm_helfer.typ_xmlknoten> = [];
// Stein // Stein
{ {
let knoten_stein : mod_vtm_helfer.schnittstelle_xmlknoten = ( let knoten_stein : mod_vtm_helfer.typ_xmlknoten = (
new mod_vtm_helfer.klasse_xmlknoten_normal mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert
( (
"circle", "circle",
{ {
@ -62,7 +90,7 @@ module mod_vtm_manifestation
// Band // Band
{ {
let band : Array<mod_vtm_aufbau.typ_symbol> = mod_vtm_aufbau.figur_band_lesen(figur); let band : Array<mod_vtm_aufbau.typ_symbol> = mod_vtm_aufbau.figur_band_lesen(figur);
let kinder_band : Array<mod_vtm_helfer.schnittstelle_xmlknoten> = []; let kinder_band : Array<mod_vtm_helfer.typ_xmlknoten> = [];
band.forEach band.forEach
( (
(symbol, index) => (symbol, index) =>
@ -70,8 +98,8 @@ module mod_vtm_manifestation
let r : float = 0.06125; let r : float = 0.06125;
let x : float = (+0.1+(2*r*1.25)*index); let x : float = (+0.1+(2*r*1.25)*index);
let y : float = (-0.1); let y : float = (-0.1);
let knoten_eintrag : mod_vtm_helfer.schnittstelle_xmlknoten = ( let knoten_eintrag : mod_vtm_helfer.typ_xmlknoten = (
new mod_vtm_helfer.klasse_xmlknoten_normal mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert
( (
"circle", "circle",
{ {
@ -98,7 +126,7 @@ module mod_vtm_manifestation
) )
; ;
let knoten_band = ( let knoten_band = (
new mod_vtm_helfer.klasse_xmlknoten_normal mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert
( (
"g", "g",
{ {
@ -111,7 +139,7 @@ module mod_vtm_manifestation
} }
let position : typ_position = position_von_stelle(mod_vtm_aufbau.figur_stelle_lesen(figur)); let position : typ_position = position_von_stelle(mod_vtm_aufbau.figur_stelle_lesen(figur));
let knoten_figur = ( let knoten_figur = (
new mod_vtm_helfer.klasse_xmlknoten_normal mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert
( (
"g", "g",
{ {
@ -127,13 +155,21 @@ module mod_vtm_manifestation
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
* @implementation
*/ */
public binden() : void function svg_figur_binden(svg_figur : typ_svg_figur) : void
{ {
} }
/**
* @author kcf <vidofnir@folksprak.org>
*/
implementierung_manifestation["svg_figur"] =
{
"darstellen": (manifestation) => svg_figur_darstellen(manifestation.angaben),
"binden": (manifestation) => svg_figur_binden(manifestation.angaben),
} }
;
} }

View file

@ -22,44 +22,60 @@ module mod_vtm_manifestation
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export class klasse_svg_partie export type typ_svg_partie =
extends klasse_manifestation<mod_vtm_aufbau.typ_partie, mod_vtm_helfer.schnittstelle_xmlknoten>
{ {
aufbau : mod_vtm_aufbau.typ_partie;
}
;
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
public constructor(aufbau : mod_vtm_aufbau.typ_partie) function svg_partie_erstellen(aufbau : mod_vtm_aufbau.typ_partie) : typ_svg_partie
{ {
super(aufbau); return {
"aufbau": aufbau
};
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
* @implementation
*/ */
public darstellen() : mod_vtm_helfer.schnittstelle_xmlknoten export function svg_partie_erstellen_manifestation(aufbau : mod_vtm_aufbau.typ_partie) : typ_manifestation<mod_vtm_aufbau.typ_partie>
{ {
let kinder_partie : Array<mod_vtm_helfer.schnittstelle_xmlknoten> = []; return {
"art": "svg_partie",
"angaben": svg_partie_erstellen(aufbau)
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function svg_partie_darstellen(svg_partie : typ_svg_partie) : mod_vtm_helfer.typ_xmlknoten
{
let kinder_partie : Array<mod_vtm_helfer.typ_xmlknoten> = [];
// Welt // Welt
{ {
let kinder_welt : Array<mod_vtm_helfer.schnittstelle_xmlknoten> = []; let kinder_welt : Array<mod_vtm_helfer.typ_xmlknoten> = [];
// Felder // Felder
{ {
let kinder_felder : Array<mod_vtm_helfer.schnittstelle_xmlknoten> = []; let kinder_felder : Array<mod_vtm_helfer.typ_xmlknoten> = [];
mod_vtm_aufbau.welt_felder_lesen(mod_vtm_aufbau.partie_welt_lesen(this.aufbau)).forEach mod_vtm_aufbau.welt_felder_lesen(mod_vtm_aufbau.partie_welt_lesen(svg_partie.aufbau)).forEach
( (
({"stelle": stelle, "aktor": aktor}) => ({"stelle": stelle, "aktor": aktor}) =>
{ {
let manifestation_feld : klasse_manifestation<mod_vtm_aufbau.typ_aktor, mod_vtm_helfer.schnittstelle_xmlknoten> = new klasse_svg_aktor(aktor, stelle); let manifestation_feld : typ_manifestation<mod_vtm_aufbau.typ_aktor> = svg_aktor_erstellen_manifestation(aktor, stelle);
let knoten_feld : mod_vtm_helfer.schnittstelle_xmlknoten = manifestation_feld.darstellen(); let knoten_feld : mod_vtm_helfer.typ_xmlknoten = manifestation_darstellen(manifestation_feld);
kinder_felder.push(knoten_feld); kinder_felder.push(knoten_feld);
} }
) )
; ;
let knoten_felder : mod_vtm_helfer.schnittstelle_xmlknoten = ( let knoten_felder : mod_vtm_helfer.typ_xmlknoten = (
new mod_vtm_helfer.klasse_xmlknoten_normal mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert
( (
"g", "g",
{ {
@ -71,8 +87,8 @@ module mod_vtm_manifestation
); );
kinder_welt.push(knoten_felder); kinder_welt.push(knoten_felder);
} }
let knoten_welt : mod_vtm_helfer.schnittstelle_xmlknoten = ( let knoten_welt : mod_vtm_helfer.typ_xmlknoten = (
new mod_vtm_helfer.klasse_xmlknoten_normal mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert
( (
"g", "g",
{ {
@ -85,12 +101,12 @@ module mod_vtm_manifestation
} }
// Figur // Figur
{ {
let figur_ : schnittstelle_fehlermonade<mod_vtm_aufbau.typ_figur> = mod_vtm_aufbau.partie_figur_lesen(this.aufbau); let figur_ : schnittstelle_fehlermonade<mod_vtm_aufbau.typ_figur> = mod_vtm_aufbau.partie_figur_lesen(svg_partie.aufbau);
if (figur_.ist_schlicht()) if (figur_.ist_schlicht())
{ {
let figur : mod_vtm_aufbau.typ_figur = figur_.lesen(); let figur : mod_vtm_aufbau.typ_figur = figur_.lesen();
let manifestation_figur : klasse_manifestation<mod_vtm_aufbau.typ_figur, mod_vtm_helfer.schnittstelle_xmlknoten> = (new klasse_svg_figur(figur)); let manifestation_figur : typ_manifestation<mod_vtm_aufbau.typ_figur> = svg_figur_erstellen_manifestation(figur);
let knoten_figur : mod_vtm_helfer.schnittstelle_xmlknoten = manifestation_figur.darstellen(); let knoten_figur : mod_vtm_helfer.typ_xmlknoten = manifestation_darstellen(manifestation_figur);
kinder_partie.push(knoten_figur); kinder_partie.push(knoten_figur);
} }
else else
@ -98,8 +114,8 @@ module mod_vtm_manifestation
// nichts tun // nichts tun
} }
} }
let knoten_partie : mod_vtm_helfer.schnittstelle_xmlknoten = ( let knoten_partie : mod_vtm_helfer.typ_xmlknoten = (
new mod_vtm_helfer.klasse_xmlknoten_normal mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert
( (
"g", "g",
{ {
@ -114,13 +130,21 @@ module mod_vtm_manifestation
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
* @implementation
*/ */
public binden() : void function svg_partie_binden(svg_partie : typ_svg_partie) : void
{ {
} }
/**
* @author kcf <vidofnir@folksprak.org>
*/
implementierung_manifestation["svg_partie"] =
{
"darstellen": (manifestation) => svg_partie_darstellen(manifestation.angaben),
"binden": (manifestation) => svg_partie_binden(manifestation.angaben),
} }
;
} }

View file

@ -40,7 +40,7 @@ module mod_vtm_manifestation
schliessen : boolean = true, schliessen : boolean = true,
attribute : {[schlussel : string] : string} = {}, attribute : {[schlussel : string] : string} = {},
) )
: mod_vtm_helfer.schnittstelle_xmlknoten : mod_vtm_helfer.typ_xmlknoten
{ {
let d : string = ""; let d : string = "";
vertices.forEach vertices.forEach
@ -57,7 +57,7 @@ module mod_vtm_manifestation
if (schliessen) if (schliessen)
d += "Z"; d += "Z";
attribute["d"] = d; 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, bis_y : float,
hoehe : int = 500, hoehe : int = 500,
breite : int = 500, breite : int = 500,
kinder : Array<mod_vtm_helfer.schnittstelle_xmlknoten> = [] kinder : Array<mod_vtm_helfer.typ_xmlknoten> = []
) )
: mod_vtm_helfer.schnittstelle_xmlknoten : mod_vtm_helfer.typ_xmlknoten
{ {
return ( return (
new mod_vtm_helfer.klasse_xmlknoten_normal mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert
( (
"svg", "svg",
{ {

View file

@ -32,149 +32,108 @@ module mod_vtm_manifestation
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
export class klasse_web_partie export type typ_web_partie =
extends klasse_manifestation<mod_vtm_aufbau.typ_partie, void>
{ {
aufbau : mod_vtm_aufbau.typ_partie;
/** bereich : Element;
* @author kcf <vidofnir@folksprak.org> intervall : schnittstelle_fehlermonade<any>;
*/
private bereich : Element;
/**
* @author kcf <vidofnir@folksprak.org>
*/
private intervall : schnittstelle_fehlermonade<any>;
/**
* @author kcf <vidofnir@folksprak.org>
*/
public constructor(aufbau : mod_vtm_aufbau.typ_partie, bereich : Element)
{
super(aufbau);
this.bereich = bereich;
this.intervall = (new klasse_nichts<any>());
/*
mod_vtm_aufbau.partie_lauschen
(
this.aufbau,
"aenderung_welt",
(angaben) =>
{
this.erneuern_welt();
} }
)
; ;
*/
}
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
* @override
*/ */
public einrichten() : void function web_partie_erstellen
{
mod_vtm_aufbau.partie_lauschen
( (
this.aufbau, aufbau : mod_vtm_aufbau.typ_partie,
"aenderung_aufgabe", bereich : Element
(angaben) =>
{
this.erneuern_aufgabe();
}
) )
; : typ_web_partie
mod_vtm_aufbau.partie_lauschen
(
this.aufbau,
"aenderung_welt",
(angaben) =>
{ {
this.erneuern_welt(); return {
} "aufbau": aufbau,
) "bereich": bereich,
; "intervall": (new klasse_nichts<any>()),
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 <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
private erneuern_aufgabe() : void export function web_partie_erstellen_erweitert
(
aufbau : mod_vtm_aufbau.typ_partie,
bereich : Element
)
: typ_manifestation<mod_vtm_aufbau.typ_partie>
{ {
document.querySelector("#aufgabe_text").innerHTML = text_nachbearbeiten(mod_vtm_aufbau.partie_aufgabe_lesen(this.aufbau).text()); return {
"art": "web_partie",
"angaben": web_partie_erstellen(aufbau, bereich)
};
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
private erneuern_welt() : void function web_partie_erneuern_aufgabe(web_partie : typ_web_partie) : void
{ {
let knoten_svg : mod_vtm_helfer.schnittstelle_xmlknoten = mod_vtm_manifestation.svg_wurzel document.querySelector("#aufgabe_text").innerHTML = (
text_nachbearbeiten
(
mod_vtm_aufbau.aufgabe_text
(
mod_vtm_aufbau.partie_aufgabe_lesen(web_partie.aufbau)
)
)
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
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,
+4, +4, +4, +4,
800, 800, 800, 800,
[new klasse_svg_partie(this.aufbau).darstellen()] [manifestation_darstellen(svg_partie_erstellen_manifestation(web_partie.aufbau))]
) )
; ;
this.bereich.innerHTML = knoten_svg.darstellen(); web_partie.bereich.innerHTML = mod_vtm_helfer.xmlknoten_darstellen(knoten_svg);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
private erneuern_figur() : void function web_partie_erneuern_figur(web_partie : typ_web_partie) : void
{ {
/* let knoten_svg : mod_vtm_helfer.typ_xmlknoten = mod_vtm_manifestation.svg_wurzel
*/
let knoten_svg : mod_vtm_helfer.schnittstelle_xmlknoten = mod_vtm_manifestation.svg_wurzel
( (
-4, -4, -4, -4,
+4, +4, +4, +4,
800, 800, 800, 800,
[new klasse_svg_partie(this.aufbau).darstellen()] [manifestation_darstellen(svg_partie_erstellen_manifestation(web_partie.aufbau))]
) )
; ;
this.bereich.innerHTML = knoten_svg.darstellen(); web_partie.bereich.innerHTML = mod_vtm_helfer.xmlknoten_darstellen(knoten_svg);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
private erneuern_modus() : void function web_partie_erneuern_modus(web_partie : typ_web_partie) : void
{ {
let status : string; let status : string;
switch (mod_vtm_aufbau.partie_modus_lesen(this.aufbau)) switch (mod_vtm_aufbau.partie_modus_lesen(web_partie.aufbau))
{ {
case mod_vtm_aufbau.modus_initial: case mod_vtm_aufbau.modus_initial:
{ {
@ -210,9 +169,9 @@ module mod_vtm_manifestation
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
public erneuern_knoepfe() : void function web_partie_erneuern_knoepfe(web_partie : typ_web_partie) : void
{ {
let modus : mod_vtm_aufbau.typ_modus = mod_vtm_aufbau.partie_modus_lesen(this.aufbau); let modus : mod_vtm_aufbau.typ_modus = mod_vtm_aufbau.partie_modus_lesen(web_partie.aufbau);
let klasse : string; let klasse : string;
switch (modus) switch (modus)
{ {
@ -224,7 +183,7 @@ module mod_vtm_manifestation
case mod_vtm_aufbau.modus_ungewiss: case mod_vtm_aufbau.modus_ungewiss:
{ {
klasse = ( klasse = (
this.intervall.ist_schlicht() web_partie.intervall.ist_schlicht()
? "ungewiss_laufend" ? "ungewiss_laufend"
: "ungewiss_stehend" : "ungewiss_stehend"
); );
@ -243,91 +202,89 @@ module mod_vtm_manifestation
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
* @implementation
*/ */
public darstellen() : void function web_partie_darstellen(web_partie : typ_web_partie) : void
{ {
this.erneuern_aufgabe(); web_partie_erneuern_aufgabe(web_partie);
this.erneuern_welt(); web_partie_erneuern_welt(web_partie);
this.erneuern_figur(); web_partie_erneuern_figur(web_partie);
this.erneuern_modus(); web_partie_erneuern_modus(web_partie);
this.erneuern_knoepfe(); web_partie_erneuern_knoepfe(web_partie);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
private anhalten() : void function web_partie_anhalten(web_partie : typ_web_partie) : void
{ {
if (this.intervall.ist_schlicht()) if (web_partie.intervall.ist_schlicht())
{ {
clearInterval(this.intervall.lesen()); clearInterval(web_partie.intervall.lesen());
this.intervall = (new klasse_nichts<any>()); web_partie.intervall = (new klasse_nichts<any>());
} }
else else
{ {
let meldung : string = "kein Intervall gesetzt"; let meldung : string = "kein Intervall gesetzt";
console.warn(meldung); console.warn(meldung);
} }
this.erneuern_knoepfe(); web_partie_erneuern_knoepfe(web_partie);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
private fortfahren() : void function web_partie_fortfahren(web_partie : typ_web_partie) : void
{ {
mod_vtm_aufbau.partie_fortfahren(this.aufbau); mod_vtm_aufbau.partie_fortfahren(web_partie.aufbau);
let modus : mod_vtm_aufbau.typ_modus = mod_vtm_aufbau.partie_modus_lesen(this.aufbau); let modus : mod_vtm_aufbau.typ_modus = mod_vtm_aufbau.partie_modus_lesen(web_partie.aufbau);
if (modus <= 1) if (modus <= 1)
{ {
// nichts tun // nichts tun
} }
else else
{ {
this.anhalten(); web_partie_anhalten(web_partie);
} }
this.erneuern_knoepfe(); web_partie_erneuern_knoepfe(web_partie);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
private testen() : void function web_partie_testen(web_partie : typ_web_partie) : void
{ {
let handle : any = setInterval(() => this.fortfahren(), 500); let handle : any = setInterval(() => web_partie_fortfahren(web_partie), 500);
this.intervall = (new klasse_schlicht<any>(handle)); web_partie.intervall = (new klasse_schlicht<any>(handle));
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
private bearbeiten() : void function web_partie_bearbeiten(web_partie : typ_web_partie) : void
{ {
this.anhalten(); web_partie_anhalten(web_partie);
mod_vtm_aufbau.partie_zuruecksetzen(this.aufbau); mod_vtm_aufbau.partie_zuruecksetzen(web_partie.aufbau);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */
private leeren() : void function web_partie_leeren(web_partie : typ_web_partie) : void
{ {
mod_vtm_aufbau.partie_welt_leeren(this.aufbau); mod_vtm_aufbau.partie_welt_leeren(web_partie.aufbau);
mod_vtm_aufbau.partie_zuruecksetzen(this.aufbau); mod_vtm_aufbau.partie_zuruecksetzen(web_partie.aufbau);
} }
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
* @implementation
*/ */
public binden() : void function web_partie_binden(web_partie : typ_web_partie) : void
{ {
let stelle_ermitteln = (target : EventTarget) => let stelle_ermitteln = (target : EventTarget) =>
{ {
@ -345,8 +302,49 @@ module mod_vtm_manifestation
return stelle; return stelle;
} }
; ;
mod_vtm_aufbau.partie_lauschen
(
web_partie.aufbau,
"aenderung_aufgabe",
(angaben) =>
{
web_partie_erneuern_aufgabe(web_partie);
}
)
;
mod_vtm_aufbau.partie_lauschen
(
web_partie.aufbau,
"aenderung_welt",
(angaben) =>
{
web_partie_erneuern_welt(web_partie);
}
)
;
mod_vtm_aufbau.partie_lauschen
(
web_partie.aufbau,
"aenderung_figur",
(angaben) =>
{
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 // Links-Klick
this.bereich.addEventListener web_partie.bereich.addEventListener
( (
"click", "click",
event => event =>
@ -355,7 +353,7 @@ module mod_vtm_manifestation
let stelle_ : schnittstelle_fehlermonade<mod_vtm_aufbau.typ_stelle> = stelle_ermitteln(event.target); let stelle_ : schnittstelle_fehlermonade<mod_vtm_aufbau.typ_stelle> = stelle_ermitteln(event.target);
if (stelle_.ist_schlicht()) if (stelle_.ist_schlicht())
{ {
mod_vtm_aufbau.partie_welt_feld_wechseln(this.aufbau, stelle_.lesen(), false); mod_vtm_aufbau.partie_welt_feld_wechseln(web_partie.aufbau, stelle_.lesen(), false);
} }
else else
{ {
@ -365,7 +363,7 @@ module mod_vtm_manifestation
) )
; ;
// Rechts-Klick // Rechts-Klick
this.bereich.addEventListener web_partie.bereich.addEventListener
( (
"contextmenu", "contextmenu",
event => event =>
@ -374,7 +372,7 @@ module mod_vtm_manifestation
let stelle_ : schnittstelle_fehlermonade<mod_vtm_aufbau.typ_stelle> = stelle_ermitteln(event.target); let stelle_ : schnittstelle_fehlermonade<mod_vtm_aufbau.typ_stelle> = stelle_ermitteln(event.target);
if (stelle_.ist_schlicht()) if (stelle_.ist_schlicht())
{ {
mod_vtm_aufbau.partie_welt_feld_wechseln(this.aufbau, stelle_.lesen(), true); mod_vtm_aufbau.partie_welt_feld_wechseln(web_partie.aufbau, stelle_.lesen(), true);
} }
else else
{ {
@ -384,7 +382,7 @@ module mod_vtm_manifestation
) )
; ;
// Mausrad // Mausrad
this.bereich.addEventListener web_partie.bereich.addEventListener
( (
"wheel", "wheel",
event => event =>
@ -394,7 +392,7 @@ module mod_vtm_manifestation
if (stelle_.ist_schlicht()) if (stelle_.ist_schlicht())
{ {
let inkrement : int = ((event["deltaY"] < 0) ? -1 : +1); let inkrement : int = ((event["deltaY"] < 0) ? -1 : +1);
mod_vtm_aufbau.partie_welt_feld_drehen(this.aufbau, stelle_.lesen(), inkrement); mod_vtm_aufbau.partie_welt_feld_drehen(web_partie.aufbau, stelle_.lesen(), inkrement);
} }
else else
{ {
@ -409,8 +407,8 @@ module mod_vtm_manifestation
"click", "click",
event => event =>
{ {
this.anhalten(); web_partie_anhalten(web_partie);
this.fortfahren(); web_partie_fortfahren(web_partie);
} }
) )
; ;
@ -420,7 +418,7 @@ module mod_vtm_manifestation
"click", "click",
event => event =>
{ {
this.testen(); web_partie_testen(web_partie);
} }
) )
; ;
@ -430,7 +428,7 @@ module mod_vtm_manifestation
"click", "click",
event => event =>
{ {
this.anhalten(); web_partie_anhalten(web_partie);
} }
) )
; ;
@ -440,7 +438,7 @@ module mod_vtm_manifestation
"click", "click",
event => event =>
{ {
this.bearbeiten(); web_partie_bearbeiten(web_partie);
} }
) )
; ;
@ -450,13 +448,22 @@ module mod_vtm_manifestation
"click", "click",
event => event =>
{ {
this.leeren(); web_partie_leeren(web_partie);
} }
) )
; ;
} }
/**
* @author kcf <vidofnir@folksprak.org>
*/
implementierung_manifestation["web_partie"] =
{
"darstellen": (manifestation) => web_partie_darstellen(manifestation.angaben),
"binden": (manifestation) => web_partie_binden(manifestation.angaben),
} }
;
} }