vtm/quelldatein/manifestation/svg/partie.ts
Christian Fraß 74a9792bbf fast fertig
2018-03-26 00:41:10 +02:00

151 lines
4 KiB
TypeScript

/*
* Verrückte Turing-Maschinen — A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
module mod_vtm_manifestation
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type typ_svg_partie =
{
aufbau : mod_vtm_aufbau.typ_partie;
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
function svg_partie_erstellen(aufbau : mod_vtm_aufbau.typ_partie) : typ_svg_partie
{
return {
"aufbau": aufbau
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function svg_partie_erstellen_manifestation(aufbau : mod_vtm_aufbau.typ_partie) : typ_manifestation<mod_vtm_aufbau.typ_partie>
{
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
{
let kinder_welt : Array<mod_vtm_helfer.typ_xmlknoten> = [];
// Felder
{
let kinder_felder : Array<mod_vtm_helfer.typ_xmlknoten> = [];
mod_vtm_aufbau.welt_felder_lesen(mod_vtm_aufbau.partie_welt_lesen(svg_partie.aufbau)).forEach
(
({"stelle": stelle, "aktor": aktor}) =>
{
let manifestation_feld : typ_manifestation<mod_vtm_aufbau.typ_aktor> = svg_aktor_erstellen_manifestation(aktor, stelle);
let knoten_feld : mod_vtm_helfer.typ_xmlknoten = manifestation_darstellen(manifestation_feld);
kinder_felder.push(knoten_feld);
}
)
;
let knoten_felder : mod_vtm_helfer.typ_xmlknoten = (
mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert
(
"g",
{
"class": "felder",
},
kinder_felder
)
);
kinder_welt.push(knoten_felder);
}
let knoten_welt : mod_vtm_helfer.typ_xmlknoten = (
mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert
(
"g",
{
"class": "welt",
},
kinder_welt
)
);
kinder_partie.push(knoten_welt);
}
// Figur
{
let figur_ : schnittstelle_fehlermonade<mod_vtm_aufbau.typ_figur> = mod_vtm_aufbau.partie_figur_lesen(svg_partie.aufbau);
if (figur_.ist_schlicht())
{
let figur : mod_vtm_aufbau.typ_figur = figur_.lesen();
let manifestation_figur : typ_manifestation<mod_vtm_aufbau.typ_figur> = svg_figur_erstellen_manifestation(figur);
let knoten_figur : mod_vtm_helfer.typ_xmlknoten = manifestation_darstellen(manifestation_figur);
kinder_partie.push(knoten_figur);
}
else
{
// nichts tun
}
}
let knoten_partie : mod_vtm_helfer.typ_xmlknoten = (
mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert
(
"g",
{
"class": "partie",
},
kinder_partie
)
);
return knoten_partie;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
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),
}
;
}