/* * Verrückte Turing-Maschinen — A turing complete game * Copyright (C) 2016-2018 kcf * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ module mod_vtm { export module mod_manifestation { export module mod_svg { export module mod_game { /** * @author kcf */ export type type_game = { model : mod_vtm.mod_model.mod_game.type_game; } ; /** * @author kcf */ function create(model : mod_vtm.mod_model.mod_game.type_game) : type_game { return { "model": model }; } /** * @author kcf */ export function create_extended(model : mod_vtm.mod_model.mod_game.type_game) : type_manifestation { return { "kind": "svg_game", "data": create(model) }; } /** * @author kcf */ function view(game : type_game) : lib_xml.type_node { let children_game : Array = []; // Welt { let children_world : Array = []; // Felder { let children_tiles : Array = []; mod_vtm.mod_model.mod_world.tiles_read(mod_vtm.mod_model.mod_game.world_read(game.model)).forEach ( ({"spot": spot, "actuator": actuator}) => { let manifestation_tile : type_manifestation = mod_actuator.create_extended(actuator, spot); let node_tile : lib_xml.type_node = mod_manifestation.view(manifestation_tile); children_tiles.push(node_tile); } ) ; let node_tiles : lib_xml.type_node = ( lib_xml.create_normal ( "g", { "class": "tiles", }, children_tiles ) ); children_world.push(node_tiles); } let node_world : lib_xml.type_node = ( lib_xml.create_normal ( "g", { "class": "world", }, children_world ) ); children_game.push(node_world); } // Figur { let token_ : lib_errormonade.type_errormonade = mod_vtm.mod_model.mod_game.token_read(game.model); if (lib_errormonade.filled(token_)) { let token : mod_vtm.mod_model.mod_token.type_token = lib_errormonade.read(token_); let manifestation_token : type_manifestation = mod_token.create_extended(token); let node_token : lib_xml.type_node = mod_manifestation.view(manifestation_token); children_game.push(node_token); } else { // nothing tun } } let node_game : lib_xml.type_node = ( lib_xml.create_normal ( "g", { "class": "game", }, children_game ) ); return node_game; } /** * @author kcf */ function bind(game : type_game) : void { } /** * @author kcf */ lib_trait.attend> ( trait_manifestation, "svg_game", { "view": (manifestation) => view(manifestation.data), "bind": (manifestation) => bind(manifestation.data), } ) ; } } } }