diff --git a/dokumente/bildschirmfoto.png b/dokumente/bildschirmfoto.png new file mode 100644 index 0000000..eee5af5 Binary files /dev/null and b/dokumente/bildschirmfoto.png differ diff --git a/makefile b/makefile index 2d90e5a..4c72dee 100644 --- a/makefile +++ b/makefile @@ -45,6 +45,7 @@ erzeugnis/vtm.js: \ quelldatein/aufbau/akzeptoraufgabe.ts \ quelldatein/aufbau/transduktoraufgabe.ts \ quelldatein/aufbau/aufgabe_.ts \ + quelldatein/aufbau/modus.ts \ quelldatein/aufbau/partie.ts \ quelldatein/manifestation/manifestation.ts \ quelldatein/manifestation/position.ts \ @@ -86,6 +87,7 @@ erzeugnis/vtm.js: \ quelldatein/aufbau/akzeptoraufgabe.ts \ quelldatein/aufbau/transduktoraufgabe.ts \ quelldatein/aufbau/aufgabe_.ts \ + quelldatein/aufbau/modus.ts \ quelldatein/aufbau/partie.ts \ quelldatein/manifestation/manifestation.ts \ quelldatein/manifestation/position.ts \ diff --git a/quelldatein/aufbau/aktor.ts b/quelldatein/aufbau/aktor.ts index 2ffde16..2e4172c 100644 --- a/quelldatein/aufbau/aktor.ts +++ b/quelldatein/aufbau/aktor.ts @@ -28,7 +28,7 @@ module mod_vtm_aufbau /** * @author kcf */ - drehen() : void; + drehen(inkrement ?: int) : void; /** diff --git a/quelldatein/aufbau/annehmer.ts b/quelldatein/aufbau/annehmer.ts index 94947de..d97046a 100644 --- a/quelldatein/aufbau/annehmer.ts +++ b/quelldatein/aufbau/annehmer.ts @@ -38,7 +38,7 @@ module mod_vtm_aufbau * @author kcf * @implementation */ - public drehen() : void + public drehen(inkrement ?: int) : void { } diff --git a/quelldatein/aufbau/befoerderer.ts b/quelldatein/aufbau/befoerderer.ts index 5781185..37882b1 100644 --- a/quelldatein/aufbau/befoerderer.ts +++ b/quelldatein/aufbau/befoerderer.ts @@ -54,9 +54,9 @@ module mod_vtm_aufbau * @author kcf * @implementation */ - public drehen() : void + public drehen(inkrement : int = +1) : void { - this.richtung = richtung_addieren(this.richtung, +1); + this.richtung = richtung_addieren(this.richtung, inkrement); } diff --git a/quelldatein/aufbau/erzeuger.ts b/quelldatein/aufbau/erzeuger.ts index da4f095..b849415 100644 --- a/quelldatein/aufbau/erzeuger.ts +++ b/quelldatein/aufbau/erzeuger.ts @@ -54,9 +54,9 @@ module mod_vtm_aufbau * @author kcf * @implementation */ - public drehen() : void + public drehen(inkrement : int = +1) : void { - this.richtung = richtung_addieren(this.richtung, +1); + this.richtung = richtung_addieren(this.richtung, inkrement); } diff --git a/quelldatein/aufbau/leser.ts b/quelldatein/aufbau/leser.ts index 00c0d84..39af600 100644 --- a/quelldatein/aufbau/leser.ts +++ b/quelldatein/aufbau/leser.ts @@ -86,9 +86,9 @@ module mod_vtm_aufbau * @author kcf * @implementation */ - public drehen() : void + public drehen(inkrement : int = +1) : void { - this.richtung = richtung_addieren(this.richtung, +1); + this.richtung = richtung_addieren(this.richtung, inkrement); } diff --git a/quelldatein/aufbau/modus.ts b/quelldatein/aufbau/modus.ts new file mode 100644 index 0000000..2d3612d --- /dev/null +++ b/quelldatein/aufbau/modus.ts @@ -0,0 +1,37 @@ +/* + * Verrückte Turing-Maschinen — A turing complete game + * Copyright (C) 2016 Christian Fraß + * + * 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_aufbau + { + + /** + * @author kcf + */ + export type typ_modus = int; + + + /** + * @author kcf + */ + export const modus_initial = 0; + export const modus_ungewiss = 1; + export const modus_fehlerhaft = 2; + export const modus_korrekt = 3; + + } + diff --git a/quelldatein/aufbau/partie.ts b/quelldatein/aufbau/partie.ts index d18c39c..49c0da1 100644 --- a/quelldatein/aufbau/partie.ts +++ b/quelldatein/aufbau/partie.ts @@ -19,21 +19,6 @@ module mod_vtm_aufbau { - /** - * @author kcf - */ - export type typ_modus = int; - - - /** - * @author kcf - */ - export const modus_initial = 0; - export const modus_ungewiss = 1; - export const modus_fehlerhaft = 2; - export const modus_korrekt = 3; - - /** * @author kcf */ @@ -70,6 +55,12 @@ module mod_vtm_aufbau private modus : typ_modus; + /** + * @author kcf + */ + private lauscher : {[ereignis : string] : Array<(angaben ?: any)=>void>}; + + /** * @author kcf */ @@ -84,6 +75,62 @@ module mod_vtm_aufbau this.figur = (new klasse_nichts()); this.testindex = (new klasse_nichts()); this.modus = modus_initial; + this.lauscher = { + "aenderung_aufgabe": [], + "aenderung_welt": [], + "aenderung_figur": [], + "aenderung_modus": [], + }; + } + + + /** + * @author kcf + */ + public lauschen(ereignis : string, prozedur : (angaben ?: any)=>void) : void + { + if (ereignis in this.lauscher) + { + this.lauscher[ereignis].push(prozedur); + } + else + { + let meldung : string = "kein Ereignis mit diesem Name"; + throw (new Error(meldung)); + } + } + + + /** + * @author kcf + */ + private benachrichtigen(ereignis : string, angaben : any = {}) : void + { + if (ereignis in this.lauscher) + { + this.lauscher[ereignis].forEach + ( + prozedur => + { + prozedur(angaben); + } + ) + ; + } + else + { + let meldung : string = "kein Ereignis mit diesem Name"; + throw (new Error(meldung)); + } + } + + + /** + * @author kcf + */ + public aufgabe_lesen() : schnittstelle_aufgabe + { + return this.aufgabe; } @@ -122,6 +169,42 @@ module mod_vtm_aufbau this.figur = (new klasse_nichts()); this.testindex = (new klasse_nichts()); this.modus = modus_initial; + this.benachrichtigen("aenderung_figur", {}); + this.benachrichtigen("aenderung_modus", {}); + } + + + /** + * @author kcf + */ + public welt_feld_wechseln(stelle : typ_stelle, umgekehrt : boolean = false) : void + { + if (! (this.modus === mod_vtm_aufbau.modus_initial)) + { + let meldung : string = "gesperrt"; + } + else + { + this.welt.feld_wechseln(stelle, umgekehrt); + this.benachrichtigen("aenderung_welt", {}); + } + } + + + /** + * @author kcf + */ + public welt_feld_drehen(stelle : typ_stelle, inkrement : int = +1) : void + { + if (! (this.modus === mod_vtm_aufbau.modus_initial)) + { + let meldung : string = "gesperrt"; + } + else + { + this.welt.feld_drehen(stelle, inkrement); + this.benachrichtigen("aenderung_welt", {}); + } } @@ -136,6 +219,7 @@ module mod_vtm_aufbau { this.modus = modus_ungewiss; this.testindex = (new klasse_schlicht(0)); + this.benachrichtigen("aenderung_modus", {}); break; } case modus_ungewiss: @@ -146,7 +230,17 @@ module mod_vtm_aufbau let testindex : int = this.testindex.lesen(); let test : schnittstelle_test = tests[testindex]; let stelle : typ_stelle = this.welt.erzeuger_finden(); - this.figur = (new klasse_schlicht(new klasse_figur(test.eingabe(), stelle))); + this.figur = ( + new klasse_schlicht + ( + new klasse_figur + ( + mod_vtm_helfer.liste_kopieren(test.eingabe()), + stelle + ) + ) + ); + this.benachrichtigen("aenderung_figur", {}); } else { @@ -171,6 +265,7 @@ module mod_vtm_aufbau if (! test.pruefen(angenommen, ausgabe)) { this.modus = modus_fehlerhaft; + this.benachrichtigen("aenderung_modus", {}); } else { @@ -180,6 +275,7 @@ module mod_vtm_aufbau // auf Modus "korrekt" wechseln this.testindex = (new klasse_nichts()); this.modus = modus_korrekt; + this.benachrichtigen("aenderung_modus", {}); } else { @@ -193,6 +289,7 @@ module mod_vtm_aufbau let meldung : string = "unbehandelter Zustand"; throw (new Error(meldung)); } + this.benachrichtigen("aenderung_figur", {}); } break; } diff --git a/quelldatein/aufbau/schreiber.ts b/quelldatein/aufbau/schreiber.ts index 545ee8a..7205992 100644 --- a/quelldatein/aufbau/schreiber.ts +++ b/quelldatein/aufbau/schreiber.ts @@ -70,9 +70,9 @@ module mod_vtm_aufbau * @author kcf * @implementation */ - public drehen() : void + public drehen(inkrement : int = +1) : void { - this.richtung = richtung_addieren(this.richtung, +1); + this.richtung = richtung_addieren(this.richtung, inkrement); } diff --git a/quelldatein/aufbau/transduktortest.ts b/quelldatein/aufbau/transduktortest.ts index 4ea46ac..28c8ba3 100644 --- a/quelldatein/aufbau/transduktortest.ts +++ b/quelldatein/aufbau/transduktortest.ts @@ -64,8 +64,6 @@ module mod_vtm_aufbau */ public pruefen(angenommen : boolean, ausgabe : Array) : boolean { -console.info(this.ausgabe); -console.info(ausgabe); if (this.ausgabe.length !== ausgabe.length) { return false; @@ -77,7 +75,6 @@ console.info(ausgabe); { if (! symbol_vergleichen(this.ausgabe[index], ausgabe[index])) { -console.info("ungleichheit bei Index " + index.toFixed(0)); gleich = false; break; } diff --git a/quelldatein/aufbau/verwerfer.ts b/quelldatein/aufbau/verwerfer.ts index ae2cdde..9b1afde 100644 --- a/quelldatein/aufbau/verwerfer.ts +++ b/quelldatein/aufbau/verwerfer.ts @@ -38,7 +38,7 @@ module mod_vtm_aufbau * @author kcf * @implementation */ - public drehen() : void + public drehen(inkrement ?: int) : void { } diff --git a/quelldatein/aufbau/welt.ts b/quelldatein/aufbau/welt.ts index 8ac22c0..f3b3aab 100644 --- a/quelldatein/aufbau/welt.ts +++ b/quelldatein/aufbau/welt.ts @@ -79,7 +79,7 @@ module mod_vtm_aufbau /** * @author kcf */ - public feld_wechseln(stelle : typ_stelle) : void + public feld_wechseln(stelle : typ_stelle, umgekehrt : boolean = false) : void { let erweitert : boolean = true; let liste : Array<{pruefer : (aktor : schnittstelle_aktor)=>boolean; ersteller : ()=>schnittstelle_aktor;}> = ( @@ -198,7 +198,7 @@ module mod_vtm_aufbau // console.warn(meldung); index = 0; } - let aktor_neu : schnittstelle_aktor = liste[mod_vtm_helfer.mod(index+1, liste.length)].ersteller(); + let aktor_neu : schnittstelle_aktor = liste[mod_vtm_helfer.mod(index + (umgekehrt ? -1 : +1), liste.length)].ersteller(); this.feld_setzen(stelle, aktor_neu); } @@ -206,12 +206,12 @@ module mod_vtm_aufbau /** * @author kcf */ - public feld_drehen(stelle : typ_stelle) : void + public feld_drehen(stelle : typ_stelle, inkrement : int = +1) : void { let aktor_ : schnittstelle_fehlermonade = this.felder.holen(stelle); if (aktor_.ist_schlicht) { - aktor_.lesen().drehen(); + aktor_.lesen().drehen(inkrement); } else { diff --git a/quelldatein/daten/aufgaben.dat.js b/quelldatein/daten/aufgaben.dat.js index a3092c4..5187a9a 100644 --- a/quelldatein/daten/aufgaben.dat.js +++ b/quelldatein/daten/aufgaben.dat.js @@ -110,24 +110,37 @@ jsonp_behandlung( { "art": "transduktor", "parameter": { - "titel": "Filter", - "text": "aus der Eingabe alle ${s0} beibehalten und alle ${s1} entfernen", + "titel": "An den Anfang", + "text": "die Eingabe, aber mit dem letzten Symbol am Anfang", + "tests": [ + { + "eingabe": [0,0,1,1,1,0,1,0,1,1,1,0,1], + "ausgabe": [1,0,0,1,1,1,0,1,0,1,1,1,0] + } + ] + } + }, + { + "art": "transduktor", + "parameter": { + "titel": "Wählerisch", + "text": "aus der Eingabe alle ${s0} entfernen und alle ${s1} beibehalten", "tests": [ { "eingabe": [0,0,0,1,0], - "ausgabe": [0,0,0,0] + "ausgabe": [1] }, { "eingabe": [1,0,1,0,1], - "ausgabe": [0,0,0] + "ausgabe": [1,1,1] }, { "eingabe": [1,1,1,1,0], - "ausgabe": [0] + "ausgabe": [1,1,1,1] }, { "eingabe": [0,1,1,0,0,1,0,1,1,1,0,1,0,0,1,1,1,1,1,1,0,1,0,1], - "ausgabe": [0,0,0,0,0,0,0,0,0] + "ausgabe": [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1] } ] } @@ -148,6 +161,60 @@ jsonp_behandlung( } ] } + }, + { + "art": "akzeptor", + "parameter": { + "titel": "ungerade Zahlen", + "text": "Mit ${s0} als 0 und ${s1} als 1, nur ungerade Zahlen", + "tests": [ + { + "eingabe": [], + "annehmen": false + }, + { + "eingabe": [], + "annehmen": false + }, + { + "eingabe": [], + "annehmen": false + }, + { + "eingabe": [], + "annehmen": false + } + ] + } + }, + { + "art": "akzeptor", + "parameter": { + "titel": "a^n b^n", + "text": "Jaja, die berühmt berüchtige Sprache, die sich mit einem endlichen Automaten nicht erkennen lässt … Das ist deine Chance zu zeigen, dass dieses Ding hier mehr ist als so ein kümmerlicher DEA … und das ganz ohne Kellerspeicher! Also: Eine beliebige Anzahl an ${s0}, dann die gleiche Anzahl an ${s1}!", + "tests": [ + { + "eingabe": [], + "annehmen": true + }, + { + "eingabe": [0], + "annehmen": false + }, + { + "eingabe": [0,0,1,1], + "annehmen": true + }, + { + "eingabe": [0,0,0,1,1], + "annehmen": false + }, + { + "eingabe": [0,0,0,0,0,0,0,1,1,1,1,1,1,1], + "annehmen": true + } + ] + } } ] } diff --git a/quelldatein/haupt.ts b/quelldatein/haupt.ts index c80e731..4d5dc61 100644 --- a/quelldatein/haupt.ts +++ b/quelldatein/haupt.ts @@ -37,7 +37,13 @@ function aufgaben_eintragen(behandler : (aufgabe : mod_vtm_aufbau.schnittstelle_ } // Option eintragen { - let titel : string = aufgabe_roh["parameter"]["titel"]; + let praefix : string = ( + { + "akzeptor": "AKZ", + "transduktor": "TRA", + }[aufgabe_roh["art"]] + ); + let titel : string = ("[" + praefix + "]" + " " + aufgabe_roh["parameter"]["titel"]); let value : string = index.toFixed(0); let dom_option : Element = document.createElement("option"); dom_option.setAttribute("value", value); @@ -75,7 +81,6 @@ function haupt() : void let aufbau : mod_vtm_aufbau.klasse_partie; let aufgabe_laden = function (aufgabe : mod_vtm_aufbau.schnittstelle_aufgabe) : void { - document.querySelector("#aufgabe_text").textContent = aufgabe.text(); aufbau = (new mod_vtm_aufbau.klasse_partie(aufgabe)); let manifestation : mod_vtm_manifestation.klasse_manifestation = ( new mod_vtm_manifestation.klasse_web_partie(aufbau, document.querySelector("#bereich_mitte")) diff --git a/quelldatein/helfer/verschiedenes.ts b/quelldatein/helfer/verschiedenes.ts index b617960..49f4cc1 100644 --- a/quelldatein/helfer/verschiedenes.ts +++ b/quelldatein/helfer/verschiedenes.ts @@ -27,5 +27,24 @@ module mod_vtm_helfer return ((laenge <= 0) ? [] : sequenz(laenge-1).concat([laenge-1])); } + + /** + * @author kcf + */ + export function liste_kopieren(liste : Array, element_kopieren : (element : type_element)=>type_element = (x => x)) : Array + { + let liste_ : Array = []; + liste.forEach + ( + element => + { + let element_ : type_element = element_kopieren(element); + liste_.push(element); + } + ) + ; + return liste_; + } + } diff --git a/quelldatein/manifestation/svg/aktor.ts b/quelldatein/manifestation/svg/aktor.ts index cdea020..bec12c5 100644 --- a/quelldatein/manifestation/svg/aktor.ts +++ b/quelldatein/manifestation/svg/aktor.ts @@ -198,8 +198,8 @@ module mod_vtm_manifestation [ "rotate(" + winkel.toFixed(svg_float_praezission) + ")", - "translate(0, 0)", - "scale(0.1)", + "translate(0.1, 0)", + "scale(0.075)", ].join(" ") ), } diff --git a/quelldatein/manifestation/web/partie.css b/quelldatein/manifestation/web/partie.css index 01faa51..6ad5845 100644 --- a/quelldatein/manifestation/web/partie.css +++ b/quelldatein/manifestation/web/partie.css @@ -28,21 +28,25 @@ .symbol_0 { fill: hsl(000.0000000000000, 50%, 50%); + background-color: hsl(000.0000000000000, 50%, 50%); } .symbol_1 { fill: hsl(222.4922359499621, 50%, 50%); + background-color: hsl(222.4922359499621, 50%, 50%); } .symbol_2 { fill: hsl(084.9844718999243, 50%, 50%); + background-color: hsl(084.9844718999243, 50%, 50%); } .symbol_3 { fill: hsl(307.4767078498864, 50%, 50%); + background-color: hsl(307.4767078498864, 50%, 50%); } .kreis diff --git a/quelldatein/manifestation/web/partie.ts b/quelldatein/manifestation/web/partie.ts index 30198ec..6fb2f5e 100644 --- a/quelldatein/manifestation/web/partie.ts +++ b/quelldatein/manifestation/web/partie.ts @@ -19,6 +19,16 @@ module mod_vtm_manifestation { + /** + * @author kcf + */ + function text_nachbearbeiten(text : string) : string + { + let regexp : RegExp = (new RegExp("\\$\{s(\\d*)\}", "g")); + return text.replace(regexp, " "); + } + + /** * @author kcf */ @@ -46,61 +56,152 @@ module mod_vtm_manifestation super(aufbau); this.bereich = bereich; this.intervall = (new klasse_nichts()); + this.aufbau.lauschen + ( + "aenderung_welt", + (angaben) => + { + this.erneuern_welt(); + } + ) + ; } /** * @author kcf - * @implementation + * @override */ - public darstellen() : void + public einrichten() : void + { + this.aufbau.lauschen + ( + "aenderung_aufgabe", + (angaben) => + { + this.erneuern_aufgabe(); + } + ) + ; + this.aufbau.lauschen + ( + "aenderung_welt", + (angaben) => + { + this.erneuern_welt(); + } + ) + ; + this.aufbau.lauschen + ( + "aenderung_figur", + (angaben) => + { + this.erneuern_figur(); + } + ) + ; + this.aufbau.lauschen + ( + "aenderung_modus", + (angaben) => + { + this.erneuern_modus(); + } + ) + ; + this.darstellen(); + this.binden(); + } + + + /** + * @author kcf + */ + private erneuern_aufgabe() : void + { + document.querySelector("#aufgabe_text").innerHTML = text_nachbearbeiten(this.aufbau.aufgabe_lesen().text()); + } + + + /** + * @author kcf + */ + private erneuern_welt() : void + { + let knoten_svg : mod_vtm_helfer.schnittstelle_xmlknoten = mod_vtm_manifestation.svg_wurzel + ( + -4, -4, + +4, +4, + 800, 800, + [new klasse_svg_partie(this.aufbau).darstellen()] + ) + ; + this.bereich.innerHTML = knoten_svg.darstellen(); + } + + + /** + * @author kcf + */ + private erneuern_figur() : void + { + let knoten_svg : mod_vtm_helfer.schnittstelle_xmlknoten = mod_vtm_manifestation.svg_wurzel + ( + -4, -4, + +4, +4, + 800, 800, + [new klasse_svg_partie(this.aufbau).darstellen()] + ) + ; + this.bereich.innerHTML = knoten_svg.darstellen(); + } + + + /** + * @author kcf + */ + private erneuern_modus() : void + { + let status : string; + switch (this.aufbau.modus_lesen()) + { + case mod_vtm_aufbau.modus_initial: + { + status = "Maschine aufbauen"; + break; + } + case mod_vtm_aufbau.modus_ungewiss: + { + status = "wird geprüft …"; + break; + } + case mod_vtm_aufbau.modus_fehlerhaft: + { + status = "fehlerhaft :/"; + break; + } + case mod_vtm_aufbau.modus_korrekt: + { + status = "scheinbar korrekt :)"; + break; + } + default: + { + let meldung : string = "unbehandelter Modus"; + throw (new Error(meldung)); + break; + } + } + document.querySelector("#aufgabe_status").textContent = status; + } + + + /** + * @author kcf + */ + public erneuern_knoepfe() : void { - // Zeichnung aktualisieren - { - let knoten_svg : mod_vtm_helfer.schnittstelle_xmlknoten = mod_vtm_manifestation.svg_wurzel - ( - -4, -4, - +4, +4, - 800, 800, - [new klasse_svg_partie(this.aufbau).darstellen()] - ) - ; - this.bereich.innerHTML = knoten_svg.darstellen(); - } - // Status - { - let status : string; - switch (this.aufbau.modus_lesen()) - { - case mod_vtm_aufbau.modus_initial: - { - status = "Rechts 'Testen' drücken zum Prüfen der Maschine"; - break; - } - case mod_vtm_aufbau.modus_ungewiss: - { - status = "wird geprüft …"; - break; - } - case mod_vtm_aufbau.modus_fehlerhaft: - { - status = "fehlerhaft :/"; - break; - } - case mod_vtm_aufbau.modus_korrekt: - { - status = "scheinbar korrekt :)"; - break; - } - default: - { - let meldung : string = "unbehandelter Modus"; - throw (new Error(meldung)); - break; - } - } - document.querySelector("#aufgabe_status").textContent = status; - } // Knöpfe anzeigen/ausblenden { document.querySelector("#knoepfe").setAttribute @@ -121,12 +222,42 @@ module mod_vtm_manifestation } + /** + * @author kcf + * @implementation + */ + public darstellen() : void + { + this.erneuern_aufgabe(); + this.erneuern_welt(); + this.erneuern_figur(); + this.erneuern_modus(); + this.erneuern_knoepfe(); + } + + /** * @author kcf * @implementation */ public binden() : void { + let stelle_ermitteln = (target : EventTarget) => + { + let stelle : schnittstelle_fehlermonade; + let dom_feld : Element = target["closest"](".feld"); + if (dom_feld == null) + { + stelle = (new klasse_nichts()); + } + else + { + let rel : string = dom_feld.getAttribute("rel") + stelle = (new klasse_schlicht(mod_vtm_aufbau.stelle_von_hash(rel))); + } + return stelle; + } + ; // Links-Klick this.bereich.addEventListener ( @@ -134,24 +265,14 @@ module mod_vtm_manifestation event => { event.preventDefault(); - if (this.aufbau.modus_lesen() === mod_vtm_aufbau.modus_initial) + let stelle_ : schnittstelle_fehlermonade = stelle_ermitteln(event.target); + if (stelle_.ist_schlicht()) { - let dom_feld : Element = event.target["closest"](".feld"); - if (dom_feld == null) - { - console.info("-- kein Feld"); - } - else - { - let rel : string = dom_feld.getAttribute("rel") - let stelle : mod_vtm_aufbau.typ_stelle = mod_vtm_aufbau.stelle_von_hash(rel); - this.aufbau.welt_lesen().feld_wechseln(stelle); - this.darstellen(); - } + this.aufbau.welt_feld_wechseln(stelle_.lesen(), true); } else { - console.info("-- nicht zur Bearbeitung freigegeben"); + console.info("-- kein Feld"); } } ) @@ -163,24 +284,34 @@ module mod_vtm_manifestation event => { event.preventDefault(); - if (this.aufbau.modus_lesen() === mod_vtm_aufbau.modus_initial) + let stelle_ : schnittstelle_fehlermonade = stelle_ermitteln(event.target); + if (stelle_.ist_schlicht()) { - let dom_feld : Element = event.target["closest"](".feld"); - if (dom_feld == null) - { - console.info("-- kein Feld"); - } - else - { - let rel : string = dom_feld.getAttribute("rel") - let stelle : mod_vtm_aufbau.typ_stelle = mod_vtm_aufbau.stelle_von_hash(rel); - this.aufbau.welt_lesen().feld_drehen(stelle); - this.darstellen(); - } + this.aufbau.welt_feld_wechseln(stelle_.lesen(), false); } else { - console.info("-- nicht zur Bearbeitung freigegeben"); + console.info("-- kein Feld"); + } + } + ) + ; + // Mausrad + this.bereich.addEventListener + ( + "wheel", + event => + { + event.preventDefault(); + let stelle_ : schnittstelle_fehlermonade = stelle_ermitteln(event.target); + if (stelle_.ist_schlicht()) + { + let inkrement : int = ((event["deltaY"] < 0) ? -1 : +1); + this.aufbau.welt_feld_drehen(stelle_.lesen(), inkrement); + } + else + { + console.info("-- kein Feld"); } } ) @@ -210,7 +341,6 @@ module mod_vtm_manifestation { clearInterval(this.intervall.lesen()); this.intervall = (new klasse_nichts()); - this.darstellen(); } else { @@ -218,7 +348,7 @@ module mod_vtm_manifestation console.warn(meldung); } } - this.darstellen(); + this.erneuern_knoepfe(); } , 500 @@ -238,13 +368,13 @@ module mod_vtm_manifestation { clearInterval(this.intervall.lesen()); this.intervall = (new klasse_nichts()); - this.darstellen(); } else { let meldung : string = "kein Intervall gesetzt"; console.warn(meldung); } + this.erneuern_knoepfe(); } ) ; @@ -264,7 +394,7 @@ module mod_vtm_manifestation // nichts tun } this.aufbau.zuruecksetzen(); - this.darstellen(); + this.erneuern_knoepfe(); } ) ; diff --git a/quelldatein/manifestation/web/vtm.html b/quelldatein/manifestation/web/vtm.html index c7fab4d..c21c6f4 100644 --- a/quelldatein/manifestation/web/vtm.html +++ b/quelldatein/manifestation/web/vtm.html @@ -17,11 +17,11 @@

-
+
@@ -30,12 +30,12 @@
-

Dieses Spiel ist inspiriert von Manufacturia und Crazy Machines.

+

Dieses Spiel ist inspiriert von Manufacturia, Crazy Machines, World of Goo … und auch von unvergessenen Stunden Hardware-Praktikum im Informatik-Studium :P

Steuerung
    -
  • Links-Klick: Feldtyp wechseln
  • -
  • Rechts-Klick: Feld drehen
  • +
  • Links-Klick/Rechts-Klick: Feldtyp wechseln
  • +
  • Mausrad-Drehen: Feld drehen