[mod] major update

This commit is contained in:
fenris 2025-09-23 12:13:49 +02:00
parent a47a8e30e3
commit 745cd50236
68 changed files with 989 additions and 915 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
build/ build/
/.geany

View file

@ -1,24 +1,26 @@
# Verrückte Turing-Maschinen # Verrückte Turing-Maschinen
Dieses Spiel ist inspiriert von [http://www.kongregate.com/games/PleasingFungus/manufactoria"](Manufacturia), [http://www.crazy-machines.com/](Crazy Machines), [http://worldofgoo.com/](World of Goo) … und auch von unvergessenen Stunden Hardware-Praktikum im Informatik-Studium :P — ein Turing-vollständiges Spiel
### Beschreibung
Dieses Spiel ist inspiriert von [Manufacturia](http://www.kongregate.com/games/PleasingFungus/manufactoria), [Crazy Machines](http://www.crazy-machines.com/), [World of Goo](http://worldofgoo.com/) … und auch von unvergessenen Stunden Hardware-Praktikum im Informatik-Studium :P
## Erstellen ## Erstellen
### Voraussetzungen ### Voraussetzungen
- [https://www.gnu.org/software/make/manual/make.html](GNU-Make) - [GNU-Make](https://www.gnu.org/software/make/manual/make.html)
- [http://www.typescriptlang.org/](Typescript)-Compiler - [TypeScript](http://www.typescriptlang.org/)-Compiler (Debian-Paket-Name: `node-typescript`, npm-Paket-Name: `typescript`)
- [http://sass-lang.com/](Sass)-Compiler - [Sass](http://sass-lang.com/)-Compiler (Debian-Paket-Name: `sassc`, npm-Paket-Name: `sass`)
Typescript und Sass sind beispielweise per [https://www.npmjs.com/](npm) beziehbar mit `npm install -g typescript && npm install -g sass`.
### Kompilieren ### Anweisungen
Im Haupt-Verzeichnis ausführen: Im Haupt-Verzeichnis ausführen:
make tools/build
Dadurch wird das Verzeichnis `build` angelegt, welches die Ergebnis-Dateien enthält. Dadurch wird das Verzeichnis `build` angelegt, welches die Ergebnis-Dateien enthält.
@ -30,5 +32,5 @@ Zum Starten/Testen einen Web-Server im Verzeichnis `build` starten (zum Beispiel
## Anmerkungen ## Anmerkungen
Das Programm folgt konsequent den Paradigmen der prozeduralen und funktionalen Programmierung und orientiert sich am Architektur-Muster [https://de.wikipedia.org/wiki/Model_View_Controller](MVC). Das Programm folgt konsequent den Paradigmen der prozeduralen und funktionalen Programmierung und orientiert sich am Architektur-Muster [MVC](https://de.wikipedia.org/wiki/Model_View_Controller).

View file

@ -16,10 +16,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_data export namespace mod_data
{ {
/** /**

View file

@ -5,6 +5,7 @@ jsonp_handle(
"common.title": "Verrückte Turing-Maschinen", "common.title": "Verrückte Turing-Maschinen",
"common.help": "Hilfe", "common.help": "Hilfe",
"common.game": "Spiel", "common.game": "Spiel",
"common.media": "Musik",
"model.token.terms.singular": "Figur", "model.token.terms.singular": "Figur",
"model.token.terms.plural": "Figuren", "model.token.terms.plural": "Figuren",
"model.modes.initial": "Maschine bearbeiten", "model.modes.initial": "Maschine bearbeiten",

View file

@ -5,6 +5,7 @@ jsonp_handle(
"common.title": "Crazy Turing Machines", "common.title": "Crazy Turing Machines",
"common.help": "Help", "common.help": "Help",
"common.game": "Game", "common.game": "Game",
"common.media": "Media",
"model.token.terms.singular": "token", "model.token.terms.singular": "token",
"model.token.terms.plural": "tokens", "model.token.terms.plural": "tokens",
"model.modes.initial": "edit machine", "model.modes.initial": "edit machine",

View file

@ -5,6 +5,7 @@ jsonp_handle(
"common.title": "Frenezaj Turing-masxinoj", "common.title": "Frenezaj Turing-masxinoj",
"common.help": "Helpo", "common.help": "Helpo",
"common.game": "Ludo", "common.game": "Ludo",
"common.media": "Musiko",
"model.token.terms.singular": "figuro", "model.token.terms.singular": "figuro",
"model.token.terms.plural": "figuroj", "model.token.terms.plural": "figuroj",
"model.modes.initial": "redakti masxinon", "model.modes.initial": "redakti masxinon",

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module lib_call namespace lib_call
{ {
/** /**

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module lib_errormonade namespace lib_errormonade
{ {
/** /**

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module lib_hashmap namespace lib_hashmap
{ {
/** /**

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module lib_list namespace lib_list
{ {
/** /**

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module lib_math namespace lib_math
{ {
/** /**

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module lib_string namespace lib_string
{ {
/** /**

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module lib_svg namespace lib_svg
{ {
/** /**
@ -126,6 +126,54 @@ module lib_svg
} }
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function group
(
attributes : {[key : string] : string} = {},
children : Array<lib_xml.type_node> = []
)
: lib_xml.type_node
{
return (
lib_xml.create_normal
(
"g",
attributes,
children
)
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function circle
(
center_x : float,
center_y : float,
radius : float,
classes : Array<string> = []
)
: lib_xml.type_node
{
return (
lib_xml.create_normal
(
"circle",
{
"cx": center_x.toFixed(float_precision),
"cy": center_y.toFixed(float_precision),
"r": radius.toFixed(float_precision),
"class": classes.join(" "),
}
)
);
}
/** /**
* @author kcf <vidofnir@folksprak.org> * @author kcf <vidofnir@folksprak.org>
*/ */

View file

@ -17,7 +17,7 @@
*/ */
module lib_trait namespace lib_trait
{ {
/** /**

View file

@ -17,7 +17,7 @@
*/ */
module lib_translate namespace lib_translate
{ {
/** /**
@ -42,12 +42,12 @@ module lib_translate
( (
language => language =>
{ {
let strs_raw_ : lib_errormonade.type_errormonade<any> = mod_vtm.mod_data.read("strings-" + language); const strs_raw_ : lib_errormonade.type_errormonade<any> = mod_vtm.mod_data.read("strings-" + language);
if (lib_errormonade.filled(strs_raw_)) if (lib_errormonade.filled(strs_raw_))
{ {
let strs_raw : {[key : string] : string} = (<{[key : string] : string}>(lib_errormonade.read(strs_raw_))); const strs_raw : {[key : string] : string} = (<{[key : string] : string}>(lib_errormonade.read(strs_raw_)));
_data[language] = {}; _data[language] = {};
for (let key in strs_raw) for (const key in strs_raw)
{ {
_data[language][key] = (<string>(strs_raw[key])); _data[language][key] = (<string>(strs_raw[key]));
} }
@ -55,7 +55,7 @@ module lib_translate
} }
else else
{ {
let message : string = ("Zeichenketten für Sprache '" + language + "' konnten nicht geladen werden"); const message : string = ("Zeichenketten für Sprache '" + language + "' konnten nicht geladen werden");
console.warn(message); console.warn(message);
} }
} }
@ -78,14 +78,14 @@ module lib_translate
} }
else else
{ {
let message : string = ("keine Zeichenketten für Schlüssel '" + key + "' in Sprache '" + language + "'"); const message : string = ("keine Zeichenketten für Schlüssel '" + key + "' in Sprache '" + language + "'");
console.warn(message); console.warn(message);
return (lib_errormonade.create_nothing<string>()); return (lib_errormonade.create_nothing<string>());
} }
} }
else else
{ {
let message : string = ("keine Zeichenketten für Sprache '" + language + "'"); const message : string = ("keine Zeichenketten für Sprache '" + language + "'");
console.warn(message); console.warn(message);
return (lib_errormonade.create_nothing<string>()); return (lib_errormonade.create_nothing<string>());
} }
@ -98,13 +98,13 @@ module lib_translate
export function get(key : string, vars : {[name : string] : string} = {}) : string export function get(key : string, vars : {[name : string] : string} = {}) : string
{ {
let result : lib_errormonade.type_errormonade<string> = (lib_errormonade.create_nothing<string>()); let result : lib_errormonade.type_errormonade<string> = (lib_errormonade.create_nothing<string>());
let found : boolean = ( const found : boolean = (
_languagestack _languagestack
.some .some
( (
language => language =>
{ {
let result_ : lib_errormonade.type_errormonade<string> = read(language, key); const result_ : lib_errormonade.type_errormonade<string> = read(language, key);
if (lib_errormonade.filled(result_)) if (lib_errormonade.filled(result_))
{ {
result = result_; result = result_;
@ -133,33 +133,41 @@ module lib_translate
*/ */
export function deploy(context : DocumentFragment) : void export function deploy(context : DocumentFragment) : void
{ {
let pattern : RegExp = (new RegExp("^!translate:([a-z0-9\.]*)$")); const pattern : RegExp = (new RegExp("^!translate:([a-z0-9\.]*)$"));
document.querySelectorAll("*")[""+"forEach"] const adjust = (
( element =>
element => {
{ if (element.childElementCount > 0)
if (element.childElementCount === 0) {
{ // nichts tun
let content : string = element.textContent; }
let fund : any = pattern.exec(content); else
if (fund != null) {
{ const content : string = element.textContent;
let key : string = fund[1]; const fund : any = pattern.exec(content);
let content_ : string = get(key); if (fund === null)
element.textContent = content_; {
} // nichts tun
else }
{ else
// nothing tun {
} const key : string = fund[1];
} const content_ : string = get(key);
else element.textContent = content_;
{ }
// nothing tun }
} }
} );
) const old : boolean = true;
; const nodelist : NodeListOf<Element> = document.querySelectorAll("*");
if (old)
{
for (let index : int = 0; index < nodelist.length; index += 1) adjust(nodelist[index])
}
else
{
nodelist.forEach(element => adjust(element));
}
} }
} }

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module lib_vector namespace lib_vector
{ {
/** /**

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module lib_xml namespace lib_xml
{ {
/** /**

View file

@ -19,15 +19,18 @@
<html> <html>
<head> <head>
<meta charset="utf-8"/> <meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<script type="text/javascript" src="vtm.js"></script> <script type="text/javascript" src="vtm.js"></script>
<script type="text/javascript" src="vtm.dat.js"></script> <script type="text/javascript" src="vtm.dat.js"></script>
<script type="text/javascript">mod_vtm.entry_web();</script> <script type="text/javascript">mod_vtm.entry_web();</script>
<link rel="stylesheet" type="text/css" href="vtm.css"/> <link rel="stylesheet" type="text/css" href="vtm.css"/>
<title>!translate:common.title</title>
</head> </head>
<body> <body>
<header>!translate:common.title</header> <h1>!translate:common.title</h1>
<label for="radio_help"><a>!translate:common.help</a></label><input type="radio" name="tab" id="radio_help" checked="checked"/> <label class="tab" for="radio_help"><a>!translate:common.help</a></label><input type="radio" name="tab" id="radio_help"/>
<label for="radio_game"><a>!translate:common.game</a></label><input type="radio" name="tab" id="radio_game"/> <label class="tab" for="radio_game"><a>!translate:common.game</a></label><input type="radio" name="tab" id="radio_game" checked="checked"/>
<label class="tab" for="radio_media"><a>!translate:common.media</a></label><input type="radio" name="tab" id="radio_media"/>
<!-- <!--
<hr/> <hr/>
--> -->
@ -54,70 +57,72 @@
<div id="help"> <div id="help">
<p id="help_introduction"></p> <p id="help_introduction"></p>
<section class="section"> <section class="section">
<header id="help_controls_title">!translate:help.controls.title</header> <h2 id="help_controls_title">!translate:help.controls.title</h2>
<ul> <ul>
<li id="help_controls_entry1">!translate:help.controls.entry1</li> <li id="help_controls_entry1">!translate:help.controls.entry1</li>
<li id="help_controls_entry2">!translate:help.controls.entry2</li> <li id="help_controls_entry2">!translate:help.controls.entry2</li>
</ul> </ul>
</section> </section>
<section class="section"> <section class="section">
<header id="help_token_title">!translate:model.token.terms.singular</header> <h2 id="help_token_title">!translate:model.token.terms.singular</h2>
<p id="help_token_satz1">!translate:help.token.satz1</p> <p id="help_token_satz1">!translate:help.token.satz1</p>
<p id="help_token_satz2">!translate:help.token.satz2</p> <p id="help_token_satz2">!translate:help.token.satz2</p>
</section> </section>
<section class="section" id="help_actuators"> <section class="section" id="help_actuators">
<header id="help_actuators_title">!translate:model.actuators.terms.plural</header> <h2 id="help_actuators_title">!translate:model.actuators.terms.plural</h2>
<p id="help_actuators_introduction">!translate:help.actuators.introduction</p> <p id="help_actuators_introduction">!translate:help.actuators.introduction</p>
<ul> <ul>
<li class="help_actuators_actuator" id="help_actuators_actuator_generator"> <li class="help_actuators_actuator" id="help_actuators_actuator_generator">
<header class="help_actuators_actuator_name">!translate:model.actuators.kinds.generator.name</header> <h3 class="help_actuators_actuator_name">!translate:model.actuators.kinds.generator.name</h3>
<div class="help_actuators_actuator_image"></div> <div class="help_actuators_actuator_image"></div>
<div class="help_actuators_actuator_text">!translate:help.actuators.generator</div> <div class="help_actuators_actuator_text">!translate:help.actuators.generator</div>
</li> </li>
<li class="help_actuators_actuator" id="help_actuators_actuator_acceptor"> <li class="help_actuators_actuator" id="help_actuators_actuator_acceptor">
<header class="help_actuators_actuator_name">!translate:model.actuators.kinds.acceptor.name</header> <h3 class="help_actuators_actuator_name">!translate:model.actuators.kinds.acceptor.name</h3>
<div class="help_actuators_actuator_image"></div> <div class="help_actuators_actuator_image"></div>
<div class="help_actuators_actuator_text">!translate:help.actuators.acceptor</div> <div class="help_actuators_actuator_text">!translate:help.actuators.acceptor</div>
</li> </li>
<li class="help_actuators_actuator" id="help_actuators_actuator_rejector"> <li class="help_actuators_actuator" id="help_actuators_actuator_rejector">
<header class="help_actuators_actuator_name">!translate:model.actuators.kinds.rejector.name</header> <h3 class="help_actuators_actuator_name">!translate:model.actuators.kinds.rejector.name</h3>
<div class="help_actuators_actuator_image"></div> <div class="help_actuators_actuator_image"></div>
<div class="help_actuators_actuator_text">!translate:help.actuators.rejector</div> <div class="help_actuators_actuator_text">!translate:help.actuators.rejector</div>
</li> </li>
<li class="help_actuators_actuator" id="help_actuators_actuator_conveyer"> <li class="help_actuators_actuator" id="help_actuators_actuator_conveyer">
<header class="help_actuators_actuator_name">!translate:model.actuators.kinds.conveyer.name</header> <h3 class="help_actuators_actuator_name">!translate:model.actuators.kinds.conveyer.name</h3>
<div class="help_actuators_actuator_image"></div> <div class="help_actuators_actuator_image"></div>
<div class="help_actuators_actuator_text">!translate:help.actuators.conveyer</div> <div class="help_actuators_actuator_text">!translate:help.actuators.conveyer</div>
</li> </li>
<li class="help_actuators_actuator" id="help_actuators_actuator_writer"> <li class="help_actuators_actuator" id="help_actuators_actuator_writer">
<header class="help_actuators_actuator_name">!translate:model.actuators.kinds.writer.name</header> <h3 class="help_actuators_actuator_name">!translate:model.actuators.kinds.writer.name</h3>
<div class="help_actuators_actuator_image"></div> <div class="help_actuators_actuator_image"></div>
<div class="help_actuators_actuator_text">!translate:help.actuators.writer</div> <div class="help_actuators_actuator_text">!translate:help.actuators.writer</div>
</li> </li>
<li class="help_actuators_actuator" id="help_actuators_actuator_reader"> <li class="help_actuators_actuator" id="help_actuators_actuator_reader">
<header class="help_actuators_actuator_name">!translate:model.actuators.kinds.reader.name</header> <h3 class="help_actuators_actuator_name">!translate:model.actuators.kinds.reader.name</h3>
<div class="help_actuators_actuator_image"></div> <div class="help_actuators_actuator_image"></div>
<div class="help_actuators_actuator_text">!translate:help.actuators.reader</div> <div class="help_actuators_actuator_text">!translate:help.actuators.reader</div>
</li> </li>
</ul> </ul>
</section> </section>
<section class="section"> <section class="section">
<header id="help_tasks_title">!translate:model.tasks.terms.plural</header> <h2 id="help_tasks_title">!translate:model.tasks.terms.plural</h2>
<p id="help_tasks_introduction">!translate:help.tasks.introduction</p> <p id="help_tasks_introduction">!translate:help.tasks.introduction</p>
<ul> <ul>
<li id="help_tasks_acceptor"> <li id="help_tasks_acceptor">
<header id="help_tasks_acceptor_name">!translate:model.tasks.kinds.acceptor.name</header> <h3 id="help_tasks_acceptor_name">!translate:model.tasks.kinds.acceptor.name</h3>
<p id="help_tasks_acceptor_description">!translate:help.tasks.acceptor.description</p> <p id="help_tasks_acceptor_description">!translate:help.tasks.acceptor.description</p>
<p id="help_tasks_acceptor_example">!translate:help.tasks.acceptor.example</p> <p id="help_tasks_acceptor_example">!translate:help.tasks.acceptor.example</p>
</li> </li>
<li id="help_tasks_transducer"> <li id="help_tasks_transducer">
<header id="help_tasks_acceptor_name">!translate:model.tasks.kinds.transducer.name</header> <h3 id="help_tasks_acceptor_name">!translate:model.tasks.kinds.transducer.name</h3>
<p id="help_tasks_transducer_description">!translate:help.tasks.transducer.description</p> <p id="help_tasks_transducer_description">!translate:help.tasks.transducer.description</p>
<p id="help_tasks_transducer_example">!translate:help.tasks.transducer.example</p> <p id="help_tasks_transducer_example">!translate:help.tasks.transducer.example</p>
</li> </li>
</ul> </ul>
</section> </section>
</div> </div>
<div id="media">
<audio id="music" controls="controls"></audio>
</div>
</body> </body>
</html> </html>

View file

@ -94,14 +94,14 @@ input,select,textarea,button
} }
} }
body > header label.tab
{ {
font-size: 200%;
margin: 8px; margin: 8px;
} }
#radio_help, #radio_help,
#radio_game #radio_game,
#radio_media
{ {
display: none; display: none;
} }
@ -110,14 +110,28 @@ body > header
{ {
& ~ #help {} & ~ #help {}
& ~ #game {display: none !important;} & ~ #game {display: none !important;}
& ~ #media {display: none !important;}
} }
#radio_game:checked #radio_game:checked
{ {
& ~ #help {display: none !important;} & ~ #help {display: none !important;}
& ~ #game {} & ~ #game {}
& ~ #media {display: none !important;}
} }
#radio_media:checked
{
& ~ #help {display: none !important;}
& ~ #game {display: none !important;}
& ~ #media {}
}
/*
#help {display: none !important;}
#game {}
*/
#game #game
{ {
display: flex; display: flex;
@ -128,7 +142,7 @@ body > header
.section .section
{ {
margin: 8px; margin: 8px;
padding: 8px; padding: 16px;
background-color: hsl($hue, 0%, 12.5%); background-color: hsl($hue, 0%, 12.5%);
color: hsl($hue, 0%, 87.5%); color: hsl($hue, 0%, 87.5%);
@ -159,9 +173,9 @@ body > header
flex-shrink: 1; flex-shrink: 1;
} }
#help section > header h1,h2,h3,h4
{ {
font-size: 150%; margin-top: 0;
} }
#buttons #buttons
@ -248,3 +262,10 @@ body > header
} }
} }
#music
{
/*
display: none;
*/
}

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
/** /**
@ -24,7 +24,7 @@ module mod_vtm
*/ */
function tasks_insert(handler : (task : mod_model.mod_task.type_task)=>void) : void function tasks_insert(handler : (task : mod_model.mod_task.type_task)=>void) : void
{ {
let tasks_raw_ : lib_errormonade.type_errormonade<Array<any>> = mod_vtm.mod_data.read("tasks"); const tasks_raw_ : lib_errormonade.type_errormonade<Array<any>> = mod_vtm.mod_data.read("tasks");
if (lib_errormonade.filled(tasks_raw_)) if (lib_errormonade.filled(tasks_raw_))
{ {
let tasks_raw : Array<any> = lib_errormonade.read(tasks_raw_); let tasks_raw : Array<any> = lib_errormonade.read(tasks_raw_);
@ -83,9 +83,10 @@ module mod_vtm
{ {
// Übersetzungen // Übersetzungen
{ {
let languages : Array<string> = lib_list.copy<string>(navigator.languages); const languages : Array<string> = lib_list.copy<string>(navigator.languages);
let language_native : string = "de"; const language_native : string = "de";
if (! languages[""+"includes"](language_native)) // if (! languages.includes(language_native))
if (! languages.some((language) => (language === language_native)))
languages.push(language_native); languages.push(language_native);
lib_translate.setup(languages); lib_translate.setup(languages);
lib_translate.deploy(document); lib_translate.deploy(document);
@ -110,12 +111,12 @@ module mod_vtm
{ {
// Arten // Arten
{ {
let from_x : float = -0.5; const from_x : float = -0.5;
let from_y : float = -0.5; const from_y : float = -0.5;
let to_x : float = +0.5; const to_x : float = +0.5;
let to_y : float = +0.5; const to_y : float = +0.5;
let width : float = 80; const width : float = 80;
let height : float = 80; const height : float = 80;
[ [
{ {
"model": mod_model.mod_actuator.example("generator"), "model": mod_model.mod_actuator.example("generator"),
@ -146,14 +147,14 @@ module mod_vtm
( (
entry => entry =>
{ {
let manifestation = ( const manifestation = (
mod_manifestation.mod_svg.mod_actuator.create_extended mod_manifestation.mod_svg.mod_actuator.create_extended
( (
entry.model, entry.model,
mod_model.mod_spot.null_() mod_model.mod_spot.null_()
) )
); );
let xmlnode : lib_xml.type_node = ( const xmlnode : lib_xml.type_node = (
lib_svg.root lib_svg.root
( (
from_x, from_y, from_x, from_y,
@ -213,7 +214,43 @@ module mod_vtm
document.addEventListener document.addEventListener
( (
"DOMContentLoaded", "DOMContentLoaded",
event => {main();} event =>
{
// music
{
let dom_audio : HTMLAudioElement = document.querySelector<HTMLAudioElement>("#music");
const playlist : Array<string> =
[
"time",
"marble_machine",
"elan",
"lux_aeterna",
"sweet_dreams",
];
let index : int = -1;
const next = function ()
{
index = ((index + 1) % playlist.length);
const path : string = ("music/" + playlist[index] + ".ogg");
let dom_source : HTMLSourceElement = document.createElement("source");
dom_source.setAttribute("type", "audio/ogg");
dom_source.setAttribute("src", path);
for (let i : int = 0; i < dom_audio.children.length; i += 1) dom_audio.removeChild(dom_audio.children[i]);
dom_audio.appendChild(dom_source);
dom_audio.load();
dom_audio.play();
}
;
dom_audio.volume = 0.25;
// dom_audio.setAttribute("autoplay", "autoplay");
// dom_audio.setAttribute("loop", "loop");
// dom_audio.setAttribute("controls", "controls");
dom_audio.addEventListener("ended", () => {next();});
next();
}
main();
}
) )
; ;
} }

View file

@ -16,10 +16,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_manifestation export namespace mod_manifestation
{ {
/** /**

View file

@ -16,13 +16,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_manifestation export namespace mod_manifestation
{ {
export module mod_position export namespace mod_position
{ {
/** /**

View file

@ -16,16 +16,16 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_manifestation export namespace mod_manifestation
{ {
export module mod_store export namespace mod_store
{ {
export module mod_game export namespace mod_game
{ {
/** /**

View file

@ -16,182 +16,166 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm.mod_manifestation.mod_svg.mod_actuator
{ {
export module mod_manifestation /**
* @author kcf <vidofnir@folksprak.org>
*/
export const shape_arrow_1 : string = (
lib_svg.path_description
(
(
[
lib_vector.cartesian( 4, 0),
lib_vector.cartesian( 0, +1),
lib_vector.cartesian(-0, 0),
lib_vector.cartesian( 0, -1),
]
),
true
)
);
/**
* @author kcf <vidofnir@folksprak.org>
*/
export const shape_arrow_2 : string = (
lib_svg.path_description
(
[
lib_vector.cartesian(+3, 0),
lib_vector.cartesian( 0, +2),
lib_vector.cartesian(+1, 0),
lib_vector.cartesian( 0, -2),
],
true
)
);
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type signature_actuator =
{ {
view : (actuator : mod_vtm.mod_model.mod_actuator.type_actuator)=>Array<lib_xml.type_node>;
export module mod_svg
{
export module mod_actuator
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export const shape_arrow_1 : string = (
lib_svg.path_description
(
(
[
lib_vector.cartesian( 4, 0),
lib_vector.cartesian( 0, +1),
lib_vector.cartesian(-0, 0),
lib_vector.cartesian( 0, -1),
]
),
true
)
);
/**
* @author kcf <vidofnir@folksprak.org>
*/
export const shape_arrow_2 : string = (
lib_svg.path_description
(
[
lib_vector.cartesian(+3, 0),
lib_vector.cartesian( 0, +2),
lib_vector.cartesian(+1, 0),
lib_vector.cartesian( 0, -2),
],
true
)
);
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type signature_actuator =
{
view : (actuator : mod_vtm.mod_model.mod_actuator.type_actuator)=>Array<lib_xml.type_node>;
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
export var trait_actuator : lib_trait.type_trait<signature_actuator> = lib_trait.create<signature_actuator>();
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type type_actuator =
{
model : mod_vtm.mod_model.mod_actuator.type_actuator;
spot : mod_vtm.mod_model.mod_spot.type_spot;
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
function create
(
model : mod_vtm.mod_model.mod_actuator.type_actuator,
spot : mod_vtm.mod_model.mod_spot.type_spot
)
: type_actuator
{
return {
"model": model,
"spot": spot
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function create_extended
(
model : mod_vtm.mod_model.mod_actuator.type_actuator,
spot : mod_vtm.mod_model.mod_spot.type_spot
)
: type_manifestation<mod_vtm.mod_model.mod_actuator.type_actuator>
{
return {
"kind": "svg_actuator",
"data": create(model, spot),
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function view(actuator_ : type_actuator) : lib_xml.type_node
{
let actuator : mod_vtm.mod_model.mod_actuator.type_actuator = actuator_.model;
let node_frame = function () : lib_xml.type_node
{
return (
lib_svg.path
(
lib_list.sequence(6).map(i => lib_vector.polar(((i+0.5)/6) * (2*Math.PI), 0.5)),
true,
{
"class": "frame"
}
)
);
}
;
let position : mod_position.type_position = mod_position.from_spot(actuator_.spot);
let node_tile : lib_xml.type_node = (
lib_xml.create_normal
(
"g",
{
"class": "tile",
"rel": mod_vtm.mod_model.mod_spot.hash(actuator_.spot),
"transform": lib_svg.translation(position.x, position.y),
},
(
[node_frame()]
.concat(lib_trait.deploy<signature_actuator>(trait_actuator, actuator.kind)["view"](actuator))
)
)
);
return node_tile;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function bind(actuator : type_actuator) : void
{
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
lib_trait.attend<signature_manifestation<mod_vtm.mod_model.mod_actuator.type_actuator, lib_xml.type_node>>
(
trait_manifestation,
"svg_actuator",
{
"view": (manifestation) => view(manifestation.data),
"bind": (manifestation) => bind(manifestation.data),
}
)
;
}
}
} }
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
export var trait_actuator : lib_trait.type_trait<signature_actuator> = lib_trait.create<signature_actuator>();
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type type_actuator =
{
model : mod_vtm.mod_model.mod_actuator.type_actuator;
spot : mod_vtm.mod_model.mod_spot.type_spot;
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
function create
(
model : mod_vtm.mod_model.mod_actuator.type_actuator,
spot : mod_vtm.mod_model.mod_spot.type_spot
)
: type_actuator
{
return {
"model": model,
"spot": spot
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function create_extended
(
model : mod_vtm.mod_model.mod_actuator.type_actuator,
spot : mod_vtm.mod_model.mod_spot.type_spot
)
: type_manifestation<mod_vtm.mod_model.mod_actuator.type_actuator>
{
return {
"kind": "svg_actuator",
"data": create(model, spot),
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function view(actuator_ : type_actuator) : lib_xml.type_node
{
let actuator : mod_vtm.mod_model.mod_actuator.type_actuator = actuator_.model;
let node_frame = function () : lib_xml.type_node
{
return (
lib_svg.path
(
lib_list.sequence(6).map(i => lib_vector.polar(((i+0.5)/6) * (2*Math.PI), 0.5)),
true,
{
"class": "frame"
}
)
);
}
;
let position : mod_position.type_position = mod_position.from_spot(actuator_.spot);
let node_tile : lib_xml.type_node = (
lib_svg.group
(
{
"class": "tile",
"rel": mod_vtm.mod_model.mod_spot.hash(actuator_.spot),
"transform": lib_svg.translation(position.x, position.y),
},
(
[node_frame()]
.concat(lib_trait.deploy<signature_actuator>(trait_actuator, actuator.kind)["view"](actuator))
)
)
);
return node_tile;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function bind(actuator : type_actuator) : void
{
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
lib_trait.attend<signature_manifestation<mod_vtm.mod_model.mod_actuator.type_actuator, lib_xml.type_node>>
(
trait_manifestation,
"svg_actuator",
{
"view": (manifestation) => view(manifestation.data),
"bind": (manifestation) => bind(manifestation.data),
}
)
;
} }

View file

@ -16,59 +16,39 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm.mod_manifestation.mod_svg.mod_actuator
{ {
export module mod_manifestation /**
{ * @author kcf <vidofnir@folksprak.org>
*/
export module mod_svg lib_trait.attend
{ (
trait_actuator,
export module mod_actuator "acceptor",
{ {
"view": (actuator) =>
/** {
* @author kcf <vidofnir@folksprak.org> let children : Array<lib_xml.type_node> = [];
*/ const node_circle : lib_xml.type_node = (
lib_trait.attend lib_svg.circle
( (
trait_actuator, 0.0,
"acceptor", 0.0,
{ 0.25,
"view": (actuator) => [
{ "circle",
let children : Array<lib_xml.type_node> = []; "positive",
let node_circle : lib_xml.type_node = ( ]
lib_xml.create_normal
(
"circle",
{
"cx": (0.0).toFixed(lib_svg.float_precision),
"cy": (0.0).toFixed(lib_svg.float_precision),
"r": (0.25).toFixed(lib_svg.float_precision),
"class": (
[
"circle",
"positive",
].join(" ")
),
}
)
);
children.push(node_circle);
return children;
}
,
}
) )
; );
children.push(node_circle);
} return children;
}
} ,
}
} )
;
} }

View file

@ -16,16 +16,16 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_manifestation export namespace mod_manifestation
{ {
export module mod_svg export namespace mod_svg
{ {
export module mod_actuator export namespace mod_actuator
{ {
/** /**

View file

@ -16,16 +16,16 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_manifestation export namespace mod_manifestation
{ {
export module mod_svg export namespace mod_svg
{ {
export module mod_actuator export namespace mod_actuator
{ {
/** /**

View file

@ -16,16 +16,16 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_manifestation export namespace mod_manifestation
{ {
export module mod_svg export namespace mod_svg
{ {
export module mod_actuator export namespace mod_actuator
{ {
/** /**

View file

@ -16,16 +16,16 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_manifestation export namespace mod_manifestation
{ {
export module mod_svg export namespace mod_svg
{ {
export module mod_actuator export namespace mod_actuator
{ {
/** /**

View file

@ -16,16 +16,16 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_manifestation export namespace mod_manifestation
{ {
export module mod_svg export namespace mod_svg
{ {
export module mod_actuator export namespace mod_actuator
{ {
/** /**

View file

@ -16,16 +16,16 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_manifestation export namespace mod_manifestation
{ {
export module mod_svg export namespace mod_svg
{ {
export module mod_game export namespace mod_game
{ {
/** /**

View file

@ -16,16 +16,16 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_manifestation export namespace mod_manifestation
{ {
export module mod_svg export namespace mod_svg
{ {
export module mod_token export namespace mod_token
{ {
/** /**

View file

@ -17,14 +17,8 @@
*/ */
$phi: 0.6180339887498949; $phi: 0.6180339887498949;
$sigma: $phi; // $sigma: $phi;
$sigma: 0.25;
/*
$hue_symbol_0: 000.0000000000000;
$hue_symbol_1: 222.4922359499621;
$hue_symbol_2: 084.9844718999243;
$hue_symbol_3: 307.4767078498864;
*/
$offset: 0.0; $offset: 0.0;
$hue_symbol_0: (((($sigma*0)+$offset)%1)*360); $hue_symbol_0: (((($sigma*0)+$offset)%1)*360);
@ -32,7 +26,8 @@ $hue_symbol_1: (((($sigma*1)+$offset)%1)*360);
$hue_symbol_2: (((($sigma*2)+$offset)%1)*360); $hue_symbol_2: (((($sigma*2)+$offset)%1)*360);
$hue_symbol_3: (((($sigma*3)+$offset)%1)*360); $hue_symbol_3: (((($sigma*3)+$offset)%1)*360);
$saturation_symbol: 50%;
$saturation_symbol: 75%;
$lightness_symbol: 50%; $lightness_symbol: 50%;
.frame .frame

View file

@ -16,483 +16,468 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm.mod_manifestation.mod_web.mod_game
{ {
export module mod_manifestation /**
* @author kcf <vidofnir@folksprak.org>
*/
function text_postprocess(text : string) : string
{ {
let vars : {[name : string] : string} = {};
export module mod_web for (let i : int = 0; i <= 3; i += 1)
{ vars["s" + i.toFixed(0)] = ("<span class=\"symbol_" + i.toFixed(0) + "\">&nbsp;&nbsp;</span>");
return lib_string.stance(text, vars);
export module mod_game
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
function text_postprocess(text : string) : string
{
let vars : {[name : string] : string} = {};
for (let i : int = 0; i <= 3; i += 1)
vars["s" + i.toFixed(0)] = ("<span class=\"symbol_" + i.toFixed(0) + "\">&nbsp;&nbsp;</span>");
return lib_string.stance(text, vars);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type type_game =
{
model : mod_model.mod_game.type_game;
area : Element;
intervall : lib_errormonade.type_errormonade<any>;
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
function create
(
model : mod_model.mod_game.type_game,
area : Element
)
: type_game
{
return {
"model": model,
"area": area,
"intervall": (lib_errormonade.create_nothing<any>()),
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function create_extended
(
model : mod_model.mod_game.type_game,
area : Element
)
: type_manifestation<mod_model.mod_game.type_game>
{
return (
lib_call.wrap
(
"web_game",
create(model, area)
)
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function update_task(game : type_game) : void
{
document.querySelector("#task_text").innerHTML = (
text_postprocess
(
mod_vtm.mod_model.mod_task.text
(
mod_vtm.mod_model.mod_game.task_read(game.model)
)
)
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function update_world(game : type_game) : void
{
let node_svg : lib_xml.type_node = lib_svg.root
(
-4, -4,
+4, +4,
800, 800,
[mod_manifestation.view(mod_svg.mod_game.create_extended(game.model))]
)
;
game.area.innerHTML = lib_xml.view(node_svg);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function update_token(game : type_game) : void
{
let node_svg : lib_xml.type_node = lib_svg.root
(
-4, -4,
+4, +4,
800, 800,
[mod_manifestation.view(mod_svg.mod_game.create_extended(game.model))]
)
;
game.area.innerHTML = lib_xml.view(node_svg);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function update_mode(game : type_game) : void
{
let status : string;
switch (mod_vtm.mod_model.mod_game.mode_read(game.model))
{
case mod_vtm.mod_model.mod_mode.initial:
{
status = lib_translate.get("model.modes.initial");
break;
}
case mod_vtm.mod_model.mod_mode.uncertain:
{
status = lib_translate.get("model.modes.uncertain");
break;
}
case mod_vtm.mod_model.mod_mode.wrong:
{
status = lib_translate.get("model.modes.wrong");
break;
}
case mod_vtm.mod_model.mod_mode.correct:
{
status = lib_translate.get("model.modes.correct");
break;
}
default:
{
let message : string = "unbehandelter Modus";
throw (new Error(message));
break;
}
}
document.querySelector("#task_status").textContent = status;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function update_buttons(game : type_game) : void
{
let mode : mod_vtm.mod_model.mod_mode.type_mode = mod_vtm.mod_model.mod_game.mode_read(game.model);
let class_ : string;
switch (mode)
{
case mod_vtm.mod_model.mod_mode.initial:
{
class_ = "initial";
break;
}
case mod_vtm.mod_model.mod_mode.uncertain:
{
class_ = (
lib_errormonade.filled<any>(game.intervall)
? "uncertain_running"
: "uncertain_standing"
);
break;
}
case mod_vtm.mod_model.mod_mode.wrong:
case mod_vtm.mod_model.mod_mode.correct:
{
class_ = "done";
break;
}
default:
{
throw (new Error("unbehandelt!"));
break;
}
}
document.querySelector("#buttons").setAttribute("class", class_);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function view(game : type_game) : void
{
update_task(game);
update_world(game);
update_token(game);
update_mode(game);
update_buttons(game);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function stop(game : type_game) : void
{
if (lib_errormonade.filled(game.intervall))
{
clearInterval(lib_errormonade.read(game.intervall));
game.intervall = (lib_errormonade.create_nothing<any>());
}
else
{
let message : string = "kein Intervall gesetzt";
console.warn(message);
}
update_buttons(game);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function resume(game : type_game) : void
{
mod_vtm.mod_model.mod_game.resume(game.model);
let mode : mod_vtm.mod_model.mod_mode.type_mode = mod_vtm.mod_model.mod_game.mode_read(game.model);
if (mode <= 1)
{
// nothing tun
}
else
{
stop(game);
}
update_buttons(game);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function testen(game : type_game) : void
{
let handle : any = setInterval(() => resume(game), 500);
game.intervall = (lib_errormonade.create_just<any>(handle));
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function edit(game : type_game) : void
{
stop(game);
mod_vtm.mod_model.mod_game.reset(game.model);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function clear(game : type_game) : void
{
mod_vtm.mod_model.mod_game.world_clear(game.model);
mod_vtm.mod_model.mod_game.reset(game.model);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function bind(game : type_game) : void
{
let spot_determine = (target : EventTarget) =>
{
let spot : lib_errormonade.type_errormonade<mod_vtm.mod_model.mod_spot.type_spot>;
let dom_tile : Element = target["closest"](".tile");
if (dom_tile == null)
{
spot = (lib_errormonade.create_nothing<mod_vtm.mod_model.mod_spot.type_spot>());
}
else
{
let rel : string = dom_tile.getAttribute("rel")
spot = (lib_errormonade.create_just<mod_vtm.mod_model.mod_spot.type_spot>(mod_vtm.mod_model.mod_spot.from_hash(rel)));
}
return spot;
}
;
mod_vtm.mod_model.mod_game.listen
(
game.model,
"change_task",
(data) =>
{
update_task(game);
}
)
;
mod_vtm.mod_model.mod_game.listen
(
game.model,
"change_world",
(data) =>
{
update_world(game);
}
)
;
mod_vtm.mod_model.mod_game.listen
(
game.model,
"change_token",
(data) =>
{
update_token(game);
}
)
;
mod_vtm.mod_model.mod_game.listen
(
game.model,
"change_mode",
(data) =>
{
update_mode(game);
update_buttons(game);
}
)
;
// Links-Klick
game.area.addEventListener
(
"click",
event =>
{
event.preventDefault();
let spot_ : lib_errormonade.type_errormonade<mod_vtm.mod_model.mod_spot.type_spot> = spot_determine(event.target);
if (lib_errormonade.filled(spot_))
{
mod_vtm.mod_model.mod_game.world_tile_change(game.model, lib_errormonade.read(spot_), false);
}
else
{
console.info("-- kein Feld");
}
}
)
;
// Rechts-Klick
game.area.addEventListener
(
"contextmenu",
event =>
{
event.preventDefault();
let spot_ : lib_errormonade.type_errormonade<mod_vtm.mod_model.mod_spot.type_spot> = spot_determine(event.target);
if (lib_errormonade.filled(spot_))
{
mod_vtm.mod_model.mod_game.world_tile_change(game.model, lib_errormonade.read(spot_), true);
}
else
{
console.info("-- kein Feld");
}
}
)
;
// Mausrad
game.area.addEventListener
(
"wheel",
event =>
{
event.preventDefault();
let spot_ : lib_errormonade.type_errormonade<mod_vtm.mod_model.mod_spot.type_spot> = spot_determine(event.target);
if (lib_errormonade.filled(spot_))
{
let increment : int = ((event["deltaY"] < 0) ? -1 : +1);
mod_vtm.mod_model.mod_game.world_tile_rotate(game.model, lib_errormonade.read(spot_), increment);
}
else
{
console.info("-- kein Feld");
}
}
)
;
// Schritt
document.querySelector("#button_step").addEventListener
(
"click",
event =>
{
stop(game);
resume(game);
}
)
;
// Testen
document.querySelector("#button_test").addEventListener
(
"click",
event =>
{
testen(game);
}
)
;
// stop
document.querySelector("#button_stop").addEventListener
(
"click",
event =>
{
stop(game);
}
)
;
// edit
document.querySelector("#button_edit").addEventListener
(
"click",
event =>
{
edit(game);
}
)
;
// Leeren
document.querySelector("#button_clear").addEventListener
(
"click",
event =>
{
clear(game);
}
)
;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
lib_trait.attend<signature_manifestation<mod_vtm.mod_model.mod_game.type_game, void>>
(
trait_manifestation,
"web_game",
{
"view": (manifestation) => view(manifestation.data),
"bind": (manifestation) => bind(manifestation.data),
}
)
;
}
}
} }
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type type_game =
{
model : mod_model.mod_game.type_game;
area : Element;
intervall : lib_errormonade.type_errormonade<any>;
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
function create
(
model : mod_model.mod_game.type_game,
area : Element
)
: type_game
{
return {
"model": model,
"area": area,
"intervall": (lib_errormonade.create_nothing<any>()),
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function create_extended
(
model : mod_model.mod_game.type_game,
area : Element
)
: type_manifestation<mod_model.mod_game.type_game>
{
return (
lib_call.wrap
(
"web_game",
create(model, area)
)
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function update_task(game : type_game) : void
{
document.querySelector("#task_text").innerHTML = (
text_postprocess
(
mod_vtm.mod_model.mod_task.text
(
mod_vtm.mod_model.mod_game.task_read(game.model)
)
)
);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function update_world(game : type_game) : void
{
let node_svg : lib_xml.type_node = lib_svg.root
(
-4, -4,
+4, +4,
800, 800,
[mod_manifestation.view(mod_svg.mod_game.create_extended(game.model))]
)
;
game.area.innerHTML = lib_xml.view(node_svg);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function update_token(game : type_game) : void
{
let node_svg : lib_xml.type_node = lib_svg.root
(
-4, -4,
+4, +4,
800, 800,
[mod_manifestation.view(mod_svg.mod_game.create_extended(game.model))]
)
;
game.area.innerHTML = lib_xml.view(node_svg);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function update_mode(game : type_game) : void
{
let status : string;
switch (mod_vtm.mod_model.mod_game.mode_read(game.model))
{
case mod_vtm.mod_model.mod_mode.initial:
{
status = lib_translate.get("model.modes.initial");
break;
}
case mod_vtm.mod_model.mod_mode.uncertain:
{
status = lib_translate.get("model.modes.uncertain");
break;
}
case mod_vtm.mod_model.mod_mode.wrong:
{
status = lib_translate.get("model.modes.wrong");
break;
}
case mod_vtm.mod_model.mod_mode.correct:
{
status = lib_translate.get("model.modes.correct");
break;
}
default:
{
let message : string = "unbehandelter Modus";
throw (new Error(message));
break;
}
}
document.querySelector("#task_status").textContent = status;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function update_buttons(game : type_game) : void
{
let mode : mod_vtm.mod_model.mod_mode.type_mode = mod_vtm.mod_model.mod_game.mode_read(game.model);
let class_ : string;
switch (mode)
{
case mod_vtm.mod_model.mod_mode.initial:
{
class_ = "initial";
break;
}
case mod_vtm.mod_model.mod_mode.uncertain:
{
class_ = (
lib_errormonade.filled<any>(game.intervall)
? "uncertain_running"
: "uncertain_standing"
);
break;
}
case mod_vtm.mod_model.mod_mode.wrong:
case mod_vtm.mod_model.mod_mode.correct:
{
class_ = "done";
break;
}
default:
{
throw (new Error("unbehandelt!"));
break;
}
}
document.querySelector("#buttons").setAttribute("class", class_);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function view(game : type_game) : void
{
update_task(game);
update_world(game);
update_token(game);
update_mode(game);
update_buttons(game);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function stop(game : type_game) : void
{
if (lib_errormonade.filled(game.intervall))
{
clearInterval(lib_errormonade.read(game.intervall));
game.intervall = (lib_errormonade.create_nothing<any>());
}
else
{
let message : string = "kein Intervall gesetzt";
console.warn(message);
}
update_buttons(game);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function resume(game : type_game) : void
{
mod_vtm.mod_model.mod_game.resume(game.model);
let mode : mod_vtm.mod_model.mod_mode.type_mode = mod_vtm.mod_model.mod_game.mode_read(game.model);
if (mode <= 1)
{
// nothing tun
}
else
{
stop(game);
}
update_buttons(game);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function testen(game : type_game) : void
{
let handle : any = setInterval(() => resume(game), 500);
game.intervall = (lib_errormonade.create_just<any>(handle));
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function edit(game : type_game) : void
{
stop(game);
mod_vtm.mod_model.mod_game.reset(game.model);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function clear(game : type_game) : void
{
mod_vtm.mod_model.mod_game.world_clear(game.model);
mod_vtm.mod_model.mod_game.reset(game.model);
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function bind(game : type_game) : void
{
let spot_determine = (target : EventTarget) =>
{
let spot : lib_errormonade.type_errormonade<mod_vtm.mod_model.mod_spot.type_spot>;
let dom_tile : Element = target["closest"](".tile");
if (dom_tile == null)
{
spot = (lib_errormonade.create_nothing<mod_vtm.mod_model.mod_spot.type_spot>());
}
else
{
let rel : string = dom_tile.getAttribute("rel")
spot = (lib_errormonade.create_just<mod_vtm.mod_model.mod_spot.type_spot>(mod_vtm.mod_model.mod_spot.from_hash(rel)));
}
return spot;
}
;
mod_vtm.mod_model.mod_game.listen
(
game.model,
"change_task",
(data) =>
{
update_task(game);
}
)
;
mod_vtm.mod_model.mod_game.listen
(
game.model,
"change_world",
(data) =>
{
update_world(game);
}
)
;
mod_vtm.mod_model.mod_game.listen
(
game.model,
"change_token",
(data) =>
{
update_token(game);
}
)
;
mod_vtm.mod_model.mod_game.listen
(
game.model,
"change_mode",
(data) =>
{
update_mode(game);
update_buttons(game);
}
)
;
// Links-Klick
game.area.addEventListener
(
"click",
event =>
{
event.preventDefault();
let spot_ : lib_errormonade.type_errormonade<mod_vtm.mod_model.mod_spot.type_spot> = spot_determine(event.target);
if (lib_errormonade.filled(spot_))
{
mod_vtm.mod_model.mod_game.world_tile_change(game.model, lib_errormonade.read(spot_), false);
}
else
{
console.info("-- kein Feld");
}
}
)
;
// Rechts-Klick
game.area.addEventListener
(
"contextmenu",
event =>
{
event.preventDefault();
let spot_ : lib_errormonade.type_errormonade<mod_vtm.mod_model.mod_spot.type_spot> = spot_determine(event.target);
if (lib_errormonade.filled(spot_))
{
mod_vtm.mod_model.mod_game.world_tile_change(game.model, lib_errormonade.read(spot_), true);
}
else
{
console.info("-- kein Feld");
}
}
)
;
// Mausrad
game.area.addEventListener
(
"wheel",
event =>
{
event.preventDefault();
let spot_ : lib_errormonade.type_errormonade<mod_vtm.mod_model.mod_spot.type_spot> = spot_determine(event.target);
if (lib_errormonade.filled(spot_))
{
let increment : int = ((event["deltaY"] < 0) ? -1 : +1);
mod_vtm.mod_model.mod_game.world_tile_rotate(game.model, lib_errormonade.read(spot_), increment);
}
else
{
console.info("-- kein Feld");
}
}
)
;
// Schritt
document.querySelector("#button_step").addEventListener
(
"click",
event =>
{
stop(game);
resume(game);
}
)
;
// Testen
document.querySelector("#button_test").addEventListener
(
"click",
event =>
{
testen(game);
}
)
;
// stop
document.querySelector("#button_stop").addEventListener
(
"click",
event =>
{
stop(game);
}
)
;
// edit
document.querySelector("#button_edit").addEventListener
(
"click",
event =>
{
edit(game);
}
)
;
// Leeren
document.querySelector("#button_clear").addEventListener
(
"click",
event =>
{
clear(game);
}
)
;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
lib_trait.attend<signature_manifestation<mod_vtm.mod_model.mod_game.type_game, void>>
(
trait_manifestation,
"web_game",
{
"view": (manifestation) => view(manifestation.data),
"bind": (manifestation) => bind(manifestation.data),
}
)
;
} }

View file

@ -16,13 +16,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_model export namespace mod_model
{ {
export module mod_actuator export namespace mod_actuator
{ {
/** /**

View file

@ -16,16 +16,16 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_model export namespace mod_model
{ {
export module mod_actuator export namespace mod_actuator
{ {
export module mod_acceptor export namespace mod_acceptor
{ {
/** /**

View file

@ -16,16 +16,16 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_model export namespace mod_model
{ {
export module mod_actuator export namespace mod_actuator
{ {
export module mod_conveyer export namespace mod_conveyer
{ {
/** /**

View file

@ -16,16 +16,16 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_model export namespace mod_model
{ {
export module mod_actuator export namespace mod_actuator
{ {
export module mod_generator export namespace mod_generator
{ {
/** /**

View file

@ -16,16 +16,16 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_model export namespace mod_model
{ {
export module mod_actuator export namespace mod_actuator
{ {
export module mod_reader export namespace mod_reader
{ {
/** /**

View file

@ -16,16 +16,16 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_model export namespace mod_model
{ {
export module mod_actuator export namespace mod_actuator
{ {
export module mod_rejector export namespace mod_rejector
{ {
/** /**

View file

@ -16,16 +16,16 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_model export namespace mod_model
{ {
export module mod_actuator export namespace mod_actuator
{ {
export module mod_writer export namespace mod_writer
{ {
/** /**

View file

@ -16,13 +16,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_model export namespace mod_model
{ {
export module mod_direction export namespace mod_direction
{ {
/** /**

View file

@ -16,13 +16,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_model export namespace mod_model
{ {
export module mod_game export namespace mod_game
{ {
/** /**

View file

@ -16,13 +16,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_model export namespace mod_model
{ {
export module mod_mode export namespace mod_mode
{ {
/** /**

View file

@ -16,13 +16,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_model export namespace mod_model
{ {
export module mod_spot export namespace mod_spot
{ {
/** /**

View file

@ -16,13 +16,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_model export namespace mod_model
{ {
export module mod_state export namespace mod_state
{ {
/** /**

View file

@ -16,13 +16,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_model export namespace mod_model
{ {
export module mod_symbol export namespace mod_symbol
{ {
/** /**

View file

@ -16,13 +16,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_model export namespace mod_model
{ {
export module mod_acceptortask export namespace mod_acceptortask
{ {
/** /**

View file

@ -16,13 +16,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_model export namespace mod_model
{ {
export module mod_acceptortest export namespace mod_acceptortest
{ {
/** /**

View file

@ -16,13 +16,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_model export namespace mod_model
{ {
export module mod_task export namespace mod_task
{ {
/** /**

View file

@ -16,13 +16,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_model export namespace mod_model
{ {
export module mod_test export namespace mod_test
{ {
/** /**

View file

@ -16,13 +16,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_model export namespace mod_model
{ {
export module mod_transducertask export namespace mod_transducertask
{ {
/** /**

View file

@ -16,13 +16,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_model export namespace mod_model
{ {
export module mod_transducertest export namespace mod_transducertest
{ {
/** /**

View file

@ -16,13 +16,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_model export namespace mod_model
{ {
export module mod_token export namespace mod_token
{ {
/** /**

View file

@ -16,13 +16,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
module mod_vtm namespace mod_vtm
{ {
export module mod_model export namespace mod_model
{ {
export module mod_world export namespace mod_world
{ {
/** /**

BIN
source/music/elan.ogg Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
source/music/time.ogg Normal file

Binary file not shown.

View file

@ -2,4 +2,5 @@
- Tests anzeigen? - Tests anzeigen?
- zufällige Tests? - zufällige Tests?
- Drehung beibehalten? - Drehung beibehalten?
- bessere Musik-Steuerung

4
tools/build Executable file
View file

@ -0,0 +1,4 @@
#!/usr/bin/env sh
make --file=tools/makefile all

View file

@ -1,4 +0,0 @@
#!/usr/bin/env sh
make all

View file

@ -2,9 +2,8 @@
rsync \ rsync \
--verbose \ --verbose \
--archive \
--compress \
--recursive \ --recursive \
--delete \
--rsh=ssh \ --rsh=ssh \
build/* \ build/* \
mehl:~/websites/folksprak.org/htdocs/vtm/ mehl:~/websites/folksprak.org/htdocs/vtm/

View file

@ -1,10 +1,10 @@
cmd_md := mkdir -p cmd_md := mkdir -p
cmd_rm := rm -rf cmd_rm := rm -rf
cmd_echo := echo # -e cmd_echo := echo # -e
cmd_cp := cp -ruv cmd_cp := cp -r -u -v
cmd_cat := cat cmd_cat := cat
cmd_tsc := tsc --allowUnreachableCode cmd_tsc := tsc --target ES5 --allowUnreachableCode
cmd_sass := sass cmd_sass := sassc
dir_source := source dir_source := source
dir_build := build dir_build := build
@ -13,7 +13,8 @@ all: \
${dir_build}/vtm.html \ ${dir_build}/vtm.html \
${dir_build}/vtm.css \ ${dir_build}/vtm.css \
${dir_build}/vtm.dat.js \ ${dir_build}/vtm.dat.js \
${dir_build}/vtm.js ${dir_build}/vtm.js \
music
.PHONY: all .PHONY: all
clear: clear:
@ -96,3 +97,7 @@ ${dir_build}/vtm.js: \
@ ${cmd_md} ${dir_build} @ ${cmd_md} ${dir_build}
@ ${cmd_tsc} $^ --outFile $@ @ ${cmd_tsc} $^ --outFile $@
music:
@ ${cmd_md} ${dir_build}/music
@ ${cmd_cp} ${dir_source}/music/* ${dir_build}/music/
.PHONY: music

View file

@ -1 +1 @@
0.5.0 0.5.1