vtm/quelldatein/manifestation/svg/partie.ts

166 lines
5.1 KiB
TypeScript
Raw Normal View History

2017-11-09 18:42:09 +01:00
/*
* Verrückte Turing-Maschinen A turing complete game
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
2018-03-26 14:22:20 +02:00
module mod_vtm
2017-11-09 18:42:09 +01:00
{
2018-03-26 14:22:20 +02:00
export module mod_manifestation
2017-11-09 18:42:09 +01:00
{
2018-03-26 14:22:20 +02:00
export module mod_svg
2017-11-09 18:42:09 +01:00
{
2018-03-26 14:22:20 +02:00
export module mod_partie
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type typ_partie =
{
aufbau : mod_vtm.mod_aufbau.mod_partie.typ_partie;
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
function erstellen(aufbau : mod_vtm.mod_aufbau.mod_partie.typ_partie) : typ_partie
2018-03-26 00:41:10 +02:00
{
2018-03-26 14:22:20 +02:00
return {
"aufbau": aufbau
};
2018-03-26 00:41:10 +02:00
}
2018-03-26 14:22:20 +02:00
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function erstellen_manifestation(aufbau : mod_vtm.mod_aufbau.mod_partie.typ_partie) : typ_manifestation<mod_vtm.mod_aufbau.mod_partie.typ_partie>
2017-11-09 18:42:09 +01:00
{
2018-03-26 14:22:20 +02:00
return {
"art": "svg_partie",
"angaben": erstellen(aufbau)
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
2018-03-27 17:24:31 +02:00
function darstellen(partie : typ_partie) : mod_vtm.mod_helfer.mod_xml.typ_knoten
2018-03-26 14:22:20 +02:00
{
2018-03-27 17:24:31 +02:00
let kinder_partie : Array<mod_vtm.mod_helfer.mod_xml.typ_knoten> = [];
2018-03-26 14:22:20 +02:00
// Welt
{
2018-03-27 17:24:31 +02:00
let kinder_welt : Array<mod_vtm.mod_helfer.mod_xml.typ_knoten> = [];
2018-03-26 14:22:20 +02:00
// Felder
{
2018-03-27 17:24:31 +02:00
let kinder_felder : Array<mod_vtm.mod_helfer.mod_xml.typ_knoten> = [];
2018-03-26 14:22:20 +02:00
mod_vtm.mod_aufbau.mod_welt.felder_lesen(mod_vtm.mod_aufbau.mod_partie.welt_lesen(partie.aufbau)).forEach
(
({"stelle": stelle, "aktor": aktor}) =>
{
let manifestation_feld : typ_manifestation<mod_vtm.mod_aufbau.mod_aktor.typ_aktor> = mod_aktor.erstellen_manifestation(aktor, stelle);
2018-03-27 17:24:31 +02:00
let knoten_feld : mod_vtm.mod_helfer.mod_xml.typ_knoten = mod_manifestation.darstellen(manifestation_feld);
2018-03-26 14:22:20 +02:00
kinder_felder.push(knoten_feld);
}
)
;
2018-03-27 17:24:31 +02:00
let knoten_felder : mod_vtm.mod_helfer.mod_xml.typ_knoten = (
mod_vtm.mod_helfer.mod_xml.mod_normal.erstellen_erweitert
2018-03-26 14:22:20 +02:00
(
"g",
{
"class": "felder",
},
kinder_felder
)
);
kinder_welt.push(knoten_felder);
}
2018-03-27 17:24:31 +02:00
let knoten_welt : mod_vtm.mod_helfer.mod_xml.typ_knoten = (
mod_vtm.mod_helfer.mod_xml.mod_normal.erstellen_erweitert
2018-03-26 14:22:20 +02:00
(
"g",
{
"class": "welt",
},
kinder_welt
)
);
kinder_partie.push(knoten_welt);
}
// Figur
{
2018-03-27 17:24:31 +02:00
let figur_ : lib_fehlermonade.typ_fehlermonade<mod_vtm.mod_aufbau.mod_figur.typ_figur> = mod_vtm.mod_aufbau.mod_partie.figur_lesen(partie.aufbau);
if (lib_fehlermonade.voll(figur_))
2018-03-26 14:22:20 +02:00
{
2018-03-27 17:24:31 +02:00
let figur : mod_vtm.mod_aufbau.mod_figur.typ_figur = lib_fehlermonade.lesen(figur_);
2018-03-26 14:22:20 +02:00
let manifestation_figur : typ_manifestation<mod_vtm.mod_aufbau.mod_figur.typ_figur> = mod_figur.erstellen_manifestation(figur);
2018-03-27 17:24:31 +02:00
let knoten_figur : mod_vtm.mod_helfer.mod_xml.typ_knoten = mod_manifestation.darstellen(manifestation_figur);
2018-03-26 14:22:20 +02:00
kinder_partie.push(knoten_figur);
}
else
{
// nichts tun
}
}
2018-03-27 17:24:31 +02:00
let knoten_partie : mod_vtm.mod_helfer.mod_xml.typ_knoten = (
mod_vtm.mod_helfer.mod_xml.mod_normal.erstellen_erweitert
2018-03-26 14:22:20 +02:00
(
"g",
{
"class": "partie",
},
kinder_partie
)
);
return knoten_partie;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function binden(partie : typ_partie) : void
{
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
implementierung_manifestation["svg_partie"] =
{
"darstellen": (manifestation) => darstellen(manifestation.angaben),
"binden": (manifestation) => binden(manifestation.angaben),
}
;
}
2017-11-09 18:42:09 +01:00
}
2018-03-26 14:22:20 +02:00
2017-11-09 18:42:09 +01:00
}
}