sicherung
This commit is contained in:
parent
e3db24dcab
commit
9d603364b1
27
makefile
27
makefile
|
|
@ -1,32 +1,51 @@
|
||||||
erzeugnis/vtm.js: \
|
erzeugnis/vtm.js: \
|
||||||
quelldatein/basis/typen.ts \
|
quelldatein/basis/typen.ts \
|
||||||
quelldatein/basis/fehlermonade.ts \
|
quelldatein/basis/fehlermonade.ts \
|
||||||
|
quelldatein/helfer/mathematik.ts \
|
||||||
|
quelldatein/helfer/vektor.ts \
|
||||||
quelldatein/helfer/hashmap.ts \
|
quelldatein/helfer/hashmap.ts \
|
||||||
|
quelldatein/helfer/xmlknoten.ts \
|
||||||
quelldatein/aufbau/richtung.ts \
|
quelldatein/aufbau/richtung.ts \
|
||||||
quelldatein/aufbau/symbol.ts \
|
quelldatein/aufbau/symbol.ts \
|
||||||
quelldatein/aufbau/position.ts \
|
quelldatein/aufbau/stelle.ts \
|
||||||
|
quelldatein/aufbau/zustand.ts \
|
||||||
quelldatein/aufbau/figur.ts \
|
quelldatein/aufbau/figur.ts \
|
||||||
quelldatein/aufbau/aktor.ts \
|
quelldatein/aufbau/aktor.ts \
|
||||||
quelldatein/aufbau/befoerderer.ts \
|
quelldatein/aufbau/befoerderer.ts \
|
||||||
quelldatein/aufbau/schreiber.ts \
|
quelldatein/aufbau/schreiber.ts \
|
||||||
|
quelldatein/aufbau/leser.ts \
|
||||||
quelldatein/aufbau/verwerfer.ts \
|
quelldatein/aufbau/verwerfer.ts \
|
||||||
|
quelldatein/aufbau/annehmer.ts \
|
||||||
quelldatein/aufbau/welt.ts \
|
quelldatein/aufbau/welt.ts \
|
||||||
|
quelldatein/darstellung_steuerung/position.ts \
|
||||||
|
quelldatein/darstellung_steuerung/svg.ts \
|
||||||
|
quelldatein/darstellung_steuerung/welt.ts \
|
||||||
quelldatein/test.ts
|
quelldatein/test.ts
|
||||||
mkdir -p erzeugnis
|
@ echo "-- kompilieren …"
|
||||||
tsc \
|
@ mkdir -p erzeugnis
|
||||||
|
@ tsc \
|
||||||
--allowUnreachableCode \
|
--allowUnreachableCode \
|
||||||
quelldatein/basis/typen.ts \
|
quelldatein/basis/typen.ts \
|
||||||
quelldatein/basis/fehlermonade.ts \
|
quelldatein/basis/fehlermonade.ts \
|
||||||
|
quelldatein/helfer/mathematik.ts \
|
||||||
|
quelldatein/helfer/vektor.ts \
|
||||||
quelldatein/helfer/hashmap.ts \
|
quelldatein/helfer/hashmap.ts \
|
||||||
|
quelldatein/helfer/xmlknoten.ts \
|
||||||
quelldatein/aufbau/richtung.ts \
|
quelldatein/aufbau/richtung.ts \
|
||||||
quelldatein/aufbau/symbol.ts \
|
quelldatein/aufbau/symbol.ts \
|
||||||
quelldatein/aufbau/position.ts \
|
quelldatein/aufbau/stelle.ts \
|
||||||
|
quelldatein/aufbau/zustand.ts \
|
||||||
quelldatein/aufbau/figur.ts \
|
quelldatein/aufbau/figur.ts \
|
||||||
quelldatein/aufbau/aktor.ts \
|
quelldatein/aufbau/aktor.ts \
|
||||||
quelldatein/aufbau/befoerderer.ts \
|
quelldatein/aufbau/befoerderer.ts \
|
||||||
quelldatein/aufbau/schreiber.ts \
|
quelldatein/aufbau/schreiber.ts \
|
||||||
|
quelldatein/aufbau/leser.ts \
|
||||||
quelldatein/aufbau/verwerfer.ts \
|
quelldatein/aufbau/verwerfer.ts \
|
||||||
|
quelldatein/aufbau/annehmer.ts \
|
||||||
quelldatein/aufbau/welt.ts \
|
quelldatein/aufbau/welt.ts \
|
||||||
|
quelldatein/darstellung_steuerung/position.ts \
|
||||||
|
quelldatein/darstellung_steuerung/svg.ts \
|
||||||
|
quelldatein/darstellung_steuerung/welt.ts \
|
||||||
quelldatein/test.ts \
|
quelldatein/test.ts \
|
||||||
--outFile erzeugnis/vtm.js
|
--outFile erzeugnis/vtm.js
|
||||||
|
|
||||||
|
|
|
||||||
33
quelldatein/aufbau/annehmer.ts
Normal file
33
quelldatein/aufbau/annehmer.ts
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
|
||||||
|
module mod_vtm_aufbau
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
export class klasse_annehmer
|
||||||
|
implements schnittstelle_aktor
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
public constructor()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
* @implementation
|
||||||
|
*/
|
||||||
|
public verwenden(figur : klasse_figur) : void
|
||||||
|
{
|
||||||
|
figur.annehmen();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -24,6 +24,15 @@ module mod_vtm_aufbau
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
public richtung_lesen() : typ_richtung
|
||||||
|
{
|
||||||
|
return this.richtung;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kcf <vidofnir@folksprak.org>
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
* @implementation
|
* @implementation
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,12 @@ module mod_vtm_aufbau
|
||||||
export class klasse_figur
|
export class klasse_figur
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
private zustand : typ_zustand;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kcf <vidofnir@folksprak.org>
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
*/
|
*/
|
||||||
|
|
@ -17,25 +23,35 @@ module mod_vtm_aufbau
|
||||||
/**
|
/**
|
||||||
* @author kcf <vidofnir@folksprak.org>
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
*/
|
*/
|
||||||
private position : typ_position;
|
private stelle : typ_stelle;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kcf <vidofnir@folksprak.org>
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
*/
|
*/
|
||||||
public constructor(band : Array<typ_symbol> = [], position : typ_position = {"u": 0, "v": 0})
|
public constructor(band : Array<typ_symbol> = [], stelle : typ_stelle = stelle_null())
|
||||||
{
|
{
|
||||||
|
this.zustand = zustand_normal;
|
||||||
this.band = band;
|
this.band = band;
|
||||||
this.position = position;
|
this.stelle = stelle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kcf <vidofnir@folksprak.org>
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
*/
|
*/
|
||||||
public position_lesen() : typ_position
|
public zustand_lesen() : typ_zustand
|
||||||
{
|
{
|
||||||
return this.position;
|
return this.zustand;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
public stelle_lesen() : typ_stelle
|
||||||
|
{
|
||||||
|
return this.stelle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -44,47 +60,8 @@ module mod_vtm_aufbau
|
||||||
*/
|
*/
|
||||||
public bewegen(richtung : typ_richtung) : void
|
public bewegen(richtung : typ_richtung) : void
|
||||||
{
|
{
|
||||||
let summand : typ_position;
|
let summand : typ_stelle = stelle_von_richtung(richtung);
|
||||||
switch (richtung)
|
this.stelle = stelle_addieren(this.stelle, summand);
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
summand = {"u": +1, "v": 0};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
summand = {"u": +1, "v": 0};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 2:
|
|
||||||
{
|
|
||||||
summand = {"u": +1, "v": 0};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 3:
|
|
||||||
{
|
|
||||||
summand = {"u": +1, "v": 0};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 4:
|
|
||||||
{
|
|
||||||
summand = {"u": +1, "v": 0};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 5:
|
|
||||||
{
|
|
||||||
summand = {"u": +1, "v": 0};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
let meldung : string = ("ungültige Richtung '" + String(richtung) + "'");
|
|
||||||
throw (new Error(meldung));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.position = {"u": (this.position.u + summand.u), "v": (this.position.v + summand.v)};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -112,6 +89,50 @@ module mod_vtm_aufbau
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
public band_schieben() : void
|
||||||
|
{
|
||||||
|
if (this.band.length <= 0)
|
||||||
|
{
|
||||||
|
let meldung : string = "Band ist leer";
|
||||||
|
throw (new Error(meldung));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.band.shift();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
public annehmen() : void
|
||||||
|
{
|
||||||
|
this.zustand = zustand_fertig;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
public verwerfen() : void
|
||||||
|
{
|
||||||
|
this.zustand = zustand_tot;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
public zu_string() : string
|
||||||
|
{
|
||||||
|
return ("{" + zustand_zu_string(this.zustand) + " / " + stelle_zu_string(this.stelle) + " : " + "[" + this.band.map(symbol => symbol_zu_string(symbol)) + "]" + "}");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
80
quelldatein/aufbau/leser.ts
Normal file
80
quelldatein/aufbau/leser.ts
Normal file
|
|
@ -0,0 +1,80 @@
|
||||||
|
|
||||||
|
module mod_vtm_aufbau
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
export class klasse_leser
|
||||||
|
implements schnittstelle_aktor
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
private richtung : typ_richtung;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
public constructor(richtung : typ_richtung = 0)
|
||||||
|
{
|
||||||
|
this.richtung = richtung;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
public richtung_lesen() : typ_richtung
|
||||||
|
{
|
||||||
|
return this.richtung;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
* @implementation
|
||||||
|
*/
|
||||||
|
public verwenden(figur : klasse_figur) : void
|
||||||
|
{
|
||||||
|
let symbol_ : schnittstelle_fehlermonade<typ_symbol> = figur.band_lesen();
|
||||||
|
let summand : typ_richtung;
|
||||||
|
if (symbol_.ist_schlicht())
|
||||||
|
{
|
||||||
|
let symbol : typ_symbol = symbol_.lesen();
|
||||||
|
figur.band_schieben();
|
||||||
|
switch (symbol)
|
||||||
|
{
|
||||||
|
case symbol_rot:
|
||||||
|
{
|
||||||
|
summand = +1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case symbol_gruen:
|
||||||
|
{
|
||||||
|
summand = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
let meldung : string = ("ungültiges Symbol '" + String(symbol) + "'");
|
||||||
|
throw (new Error(meldung));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
summand = 0;
|
||||||
|
}
|
||||||
|
let richtung : typ_richtung = richtung_addieren(this.richtung, summand);
|
||||||
|
figur.bewegen(richtung);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
|
|
||||||
module mod_vtm_aufbau
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author kcf <vidofnir@folksprak.org>
|
|
||||||
*/
|
|
||||||
export type typ_position = {u : int; v : int;};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author kcf <vidofnir@folksprak.org>
|
|
||||||
*/
|
|
||||||
export function position_hash(position : typ_position) : string
|
|
||||||
{
|
|
||||||
return (position.u.toFixed(0) + "_" + position.v.toFixed(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -7,5 +7,14 @@ module mod_vtm_aufbau
|
||||||
*/
|
*/
|
||||||
export type typ_richtung = int;
|
export type typ_richtung = int;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
export function richtung_addieren(richtung1 : typ_richtung, richtung2 : typ_richtung) : typ_richtung
|
||||||
|
{
|
||||||
|
return mod_vtm_helfer.mod(richtung1 + richtung2, 6);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,6 @@ module mod_vtm_aufbau
|
||||||
implements schnittstelle_aktor
|
implements schnittstelle_aktor
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* @author kcf <vidofnir@folksprak.org>
|
|
||||||
*/
|
|
||||||
private symbol : typ_symbol;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kcf <vidofnir@folksprak.org>
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
*/
|
*/
|
||||||
|
|
@ -24,10 +18,34 @@ module mod_vtm_aufbau
|
||||||
/**
|
/**
|
||||||
* @author kcf <vidofnir@folksprak.org>
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
*/
|
*/
|
||||||
public constructor(symbol : int = 0, richtung : int = 0)
|
private symbol : typ_symbol;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
public constructor(richtung : typ_richtung = 0, symbol : typ_symbol = 0)
|
||||||
{
|
{
|
||||||
this.symbol = symbol;
|
|
||||||
this.richtung = richtung;
|
this.richtung = richtung;
|
||||||
|
this.symbol = symbol;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
public richtung_lesen() : typ_richtung
|
||||||
|
{
|
||||||
|
return this.richtung;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
public symbol_lesen() : typ_symbol
|
||||||
|
{
|
||||||
|
return this.symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
65
quelldatein/aufbau/stelle.ts
Normal file
65
quelldatein/aufbau/stelle.ts
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
|
||||||
|
module mod_vtm_aufbau
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
export type typ_stelle = {u : int; v : int;};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
export function stelle_hash(stelle : typ_stelle) : string
|
||||||
|
{
|
||||||
|
return (stelle.u.toFixed(0) + "_" + stelle.v.toFixed(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
export function stelle_zu_string(stelle : typ_stelle) : string
|
||||||
|
{
|
||||||
|
return ("<" + stelle.u.toFixed(0) + "," + stelle.v.toFixed(0) + ">");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
export function stelle_null() : typ_stelle
|
||||||
|
{
|
||||||
|
return {"u": 0, "v": 0};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
export function stelle_von_richtung(richtung : typ_richtung) : typ_stelle
|
||||||
|
{
|
||||||
|
switch (richtung)
|
||||||
|
{
|
||||||
|
case 0: {return {"u": +1, "v": 0}; break;}
|
||||||
|
case 1: {return {"u": +1, "v": +1}; break;}
|
||||||
|
case 2: {return {"u": 0, "v": +1}; break;}
|
||||||
|
case 3: {return {"u": -1, "v": 0}; break;}
|
||||||
|
case 4: {return {"u": -1, "v": -1}; break;}
|
||||||
|
case 5: {return {"u": 0, "v": -1}; break;}
|
||||||
|
default: {throw (new Error("ungültige Richtung '" + String(richtung) + "'")); break;}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
export function stelle_addieren(stelle1 : typ_stelle, stelle2 : typ_stelle) : typ_stelle
|
||||||
|
{
|
||||||
|
return {"u": (stelle1.u + stelle2.u), "v": (stelle1.v + stelle2.v)};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -7,5 +7,21 @@ module mod_vtm_aufbau
|
||||||
*/
|
*/
|
||||||
export type typ_symbol = int;
|
export type typ_symbol = int;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
export var symbol_rot = 0;
|
||||||
|
export var symbol_gruen = 1;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
export function symbol_zu_string(symbol : typ_symbol) : string
|
||||||
|
{
|
||||||
|
return symbol.toFixed(0);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,7 @@ module mod_vtm_aufbau
|
||||||
*/
|
*/
|
||||||
public verwenden(figur : klasse_figur) : void
|
public verwenden(figur : klasse_figur) : void
|
||||||
{
|
{
|
||||||
// TODO
|
figur.verwerfen();
|
||||||
console.warn("not implemented");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ module mod_vtm_aufbau
|
||||||
/**
|
/**
|
||||||
* @author kcf <vidofnir@folksprak.org>
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
*/
|
*/
|
||||||
private felder : mod_vtm_helfer.klasse_hashmap<typ_position, schnittstelle_aktor>;
|
private felder : mod_vtm_helfer.klasse_hashmap<typ_stelle, schnittstelle_aktor>;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -25,7 +25,7 @@ module mod_vtm_aufbau
|
||||||
*/
|
*/
|
||||||
public constructor
|
public constructor
|
||||||
(
|
(
|
||||||
felder : mod_vtm_helfer.klasse_hashmap<typ_position, schnittstelle_aktor> = new mod_vtm_helfer.klasse_hashmap<typ_position, schnittstelle_aktor>(position_hash),
|
felder : mod_vtm_helfer.klasse_hashmap<typ_stelle, schnittstelle_aktor> = new mod_vtm_helfer.klasse_hashmap<typ_stelle, schnittstelle_aktor>(stelle_hash),
|
||||||
figur : klasse_figur = new klasse_figur()
|
figur : klasse_figur = new klasse_figur()
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
@ -37,24 +37,77 @@ module mod_vtm_aufbau
|
||||||
/**
|
/**
|
||||||
* @author kcf <vidofnir@folksprak.org>
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
*/
|
*/
|
||||||
public feld_setzen(position : typ_position, aktor : schnittstelle_aktor) : void
|
public felder_lesen() : Array<{stelle : typ_stelle; aktor : schnittstelle_aktor;}>
|
||||||
{
|
{
|
||||||
this.felder.setzen(position, aktor);
|
let felder : Array<{stelle : typ_stelle; aktor : schnittstelle_aktor;}> = [];
|
||||||
|
this.felder.iterieren
|
||||||
|
(
|
||||||
|
(stelle, aktor) => felder.push({"stelle": stelle, "aktor": aktor})
|
||||||
|
)
|
||||||
|
;
|
||||||
|
return felder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kcf <vidofnir@folksprak.org>
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
*/
|
*/
|
||||||
public fortfahren() : void
|
public figur_lesen() : klasse_figur
|
||||||
{
|
{
|
||||||
let position : typ_position = this.figur.position_lesen();
|
return this.figur;
|
||||||
let aktor_ : schnittstelle_fehlermonade<schnittstelle_aktor> = this.felder.holen(position);
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
public feld_setzen(stelle : typ_stelle, aktor : schnittstelle_aktor) : void
|
||||||
|
{
|
||||||
|
this.felder.setzen(stelle, aktor);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
public fortfahren() : boolean
|
||||||
|
{
|
||||||
|
let stelle : typ_stelle = this.figur.stelle_lesen();
|
||||||
|
let aktor_ : schnittstelle_fehlermonade<schnittstelle_aktor> = this.felder.holen(stelle);
|
||||||
let aktor : schnittstelle_aktor = (aktor_.ist_schlicht() ? aktor_.lesen() : (new klasse_verwerfer()));
|
let aktor : schnittstelle_aktor = (aktor_.ist_schlicht() ? aktor_.lesen() : (new klasse_verwerfer()));
|
||||||
let ergebnis : any = aktor.verwenden(this.figur);
|
aktor.verwenden(this.figur);
|
||||||
//
|
let zustand : typ_zustand = this.figur.zustand_lesen();
|
||||||
let position_ : typ_position = this.figur.position_lesen();
|
let ergebnis : boolean;
|
||||||
console.info(JSON.stringify(position) + " -> " + JSON.stringify(position_));
|
switch (zustand)
|
||||||
|
{
|
||||||
|
case zustand_tot:
|
||||||
|
{
|
||||||
|
console.info("-- tot");
|
||||||
|
ergebnis = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case zustand_normal:
|
||||||
|
{
|
||||||
|
// console.info("-- normal");
|
||||||
|
ergebnis = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case zustand_fertig:
|
||||||
|
{
|
||||||
|
console.info("-- fertig");
|
||||||
|
ergebnis = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
let meldung : string = "unbehandelter Zustand";
|
||||||
|
throw (new Error(meldung));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ergebnis)
|
||||||
|
console.info(this.figur.zu_string());
|
||||||
|
return ergebnis;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
28
quelldatein/aufbau/zustand.ts
Normal file
28
quelldatein/aufbau/zustand.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
|
||||||
|
module mod_vtm_aufbau
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
export type typ_zustand = int;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
export var zustand_tot = -1;
|
||||||
|
export var zustand_normal = 0;
|
||||||
|
export var zustand_fertig = +1;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
export function zustand_zu_string(zustand : typ_zustand) : string
|
||||||
|
{
|
||||||
|
return zustand.toFixed(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
33
quelldatein/darstellung_steuerung/position.ts
Normal file
33
quelldatein/darstellung_steuerung/position.ts
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
|
||||||
|
module mod_vtm_darstellung_steuerung
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
export type typ_position = mod_vtm_helfer.typ_vektor;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
var position_basis1 : typ_position = mod_vtm_helfer.vektor_polar(0/6.0 * (2*Math.PI));
|
||||||
|
var position_basis2 : typ_position = mod_vtm_helfer.vektor_polar(2/6.0 * (2*Math.PI));
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
export function position_von_stelle(stelle : mod_vtm_aufbau.typ_stelle) : typ_position
|
||||||
|
{
|
||||||
|
return (
|
||||||
|
mod_vtm_helfer.vektor_addieren
|
||||||
|
(
|
||||||
|
mod_vtm_helfer.vektor_skalieren(position_basis1, stelle.u),
|
||||||
|
mod_vtm_helfer.vektor_skalieren(position_basis2, stelle.v)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
36
quelldatein/darstellung_steuerung/svg.ts
Normal file
36
quelldatein/darstellung_steuerung/svg.ts
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
|
||||||
|
module mod_vtm_darstellung_steuerung
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
export function svg_wurzel
|
||||||
|
(
|
||||||
|
von_x : float,
|
||||||
|
von_y : float,
|
||||||
|
bis_x : float,
|
||||||
|
bis_y : float,
|
||||||
|
hoehe : int = 500,
|
||||||
|
breite : int = 500,
|
||||||
|
kinder : Array<mod_vtm_helfer.schnittstelle_xmlknoten> = []
|
||||||
|
) : mod_vtm_helfer.schnittstelle_xmlknoten
|
||||||
|
{
|
||||||
|
return (
|
||||||
|
new mod_vtm_helfer.klasse_xmlknoten_normal
|
||||||
|
(
|
||||||
|
"svg",
|
||||||
|
{
|
||||||
|
"xmlns": "http://www.w3.org/2000/svg",
|
||||||
|
"xmlns:xlink": "http://www.w3.org/1999/xlink",
|
||||||
|
"width": breite.toFixed(0),
|
||||||
|
"height": hoehe.toFixed(0),
|
||||||
|
"viewBox": [von_x.toFixed(4), von_y.toFixed(4), (bis_x-von_x).toFixed(4), (bis_y-von_y).toFixed(4)].join(" "),
|
||||||
|
},
|
||||||
|
kinder,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
12
quelldatein/darstellung_steuerung/welt.css
Normal file
12
quelldatein/darstellung_steuerung/welt.css
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
.feld
|
||||||
|
{
|
||||||
|
stroke: none;
|
||||||
|
fill: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.figur
|
||||||
|
{
|
||||||
|
stroke: none;
|
||||||
|
fill: white;
|
||||||
|
}
|
||||||
|
|
||||||
242
quelldatein/darstellung_steuerung/welt.ts
Normal file
242
quelldatein/darstellung_steuerung/welt.ts
Normal file
|
|
@ -0,0 +1,242 @@
|
||||||
|
|
||||||
|
module mod_vtm_darstellung_steuerung
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
const svg_float_praezission : int = 4;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
function symbol_zu_farbe(symbol : mod_vtm_aufbau.typ_symbol) : string
|
||||||
|
{
|
||||||
|
switch (symbol)
|
||||||
|
{
|
||||||
|
case 0: {return "hsl( 0, 50%, 50%)"; break;}
|
||||||
|
case 1: {return "hsl(120, 50%, 50%)"; break;}
|
||||||
|
default: {throw (new Error("unbehandeltes Symbol")); break;}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
export class klasse_web_welt
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
protected aufbau : mod_vtm_aufbau.klasse_welt;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
public constructor(aufbau : mod_vtm_aufbau.klasse_welt)
|
||||||
|
{
|
||||||
|
this.aufbau = aufbau;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
public darstellen() : mod_vtm_helfer.schnittstelle_xmlknoten
|
||||||
|
{
|
||||||
|
let kinder_welt : Array<mod_vtm_helfer.schnittstelle_xmlknoten> = [];
|
||||||
|
// felder
|
||||||
|
{
|
||||||
|
let kinder_felder : Array<mod_vtm_helfer.schnittstelle_xmlknoten> = [];
|
||||||
|
this.aufbau.felder_lesen().forEach
|
||||||
|
(
|
||||||
|
({"stelle": stelle, "aktor": aktor}) =>
|
||||||
|
{
|
||||||
|
let kinder_feld : Array<mod_vtm_helfer.schnittstelle_xmlknoten> = [];
|
||||||
|
// rahmen
|
||||||
|
{
|
||||||
|
let knoten_rahmen : mod_vtm_helfer.schnittstelle_xmlknoten = (
|
||||||
|
new mod_vtm_helfer.klasse_xmlknoten_normal
|
||||||
|
(
|
||||||
|
"circle",
|
||||||
|
{
|
||||||
|
"cx": (0.0).toFixed(svg_float_praezission),
|
||||||
|
"cy": (0.0).toFixed(svg_float_praezission),
|
||||||
|
"r": (0.5).toFixed(svg_float_praezission),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
kinder_feld.push(knoten_rahmen);
|
||||||
|
}
|
||||||
|
// inhalt
|
||||||
|
{
|
||||||
|
if (aktor instanceof mod_vtm_aufbau.klasse_befoerderer)
|
||||||
|
{
|
||||||
|
let befoerderer : mod_vtm_aufbau.klasse_befoerderer = <mod_vtm_aufbau.klasse_befoerderer>(aktor);
|
||||||
|
let richtung : mod_vtm_aufbau.typ_richtung = befoerderer.richtung_lesen();
|
||||||
|
let knoten_pfeil = (
|
||||||
|
new mod_vtm_helfer.klasse_xmlknoten_normal
|
||||||
|
(
|
||||||
|
"path",
|
||||||
|
{
|
||||||
|
"class": "pfeil",
|
||||||
|
"d": "M +0.4 0.0 L -0.2 +0.1 L -0.2 -0.1 Z",
|
||||||
|
"style": ("stroke: none; fill: " + "hsl(0, 0%, 50%)" + ";"),
|
||||||
|
"transform": ("rotate(" + ((richtung/6.0) * 360).toFixed(svg_float_praezission) + ")"),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
kinder_feld.push(knoten_pfeil);
|
||||||
|
}
|
||||||
|
else if (aktor instanceof mod_vtm_aufbau.klasse_schreiber)
|
||||||
|
{
|
||||||
|
let schreiber : mod_vtm_aufbau.klasse_schreiber = <mod_vtm_aufbau.klasse_schreiber>(aktor);
|
||||||
|
let richtung : mod_vtm_aufbau.typ_richtung = schreiber.richtung_lesen();
|
||||||
|
let symbol : mod_vtm_aufbau.typ_symbol = schreiber.symbol_lesen();
|
||||||
|
let knoten_pfeil = (
|
||||||
|
new mod_vtm_helfer.klasse_xmlknoten_normal
|
||||||
|
(
|
||||||
|
"path",
|
||||||
|
{
|
||||||
|
"class": "pfeil",
|
||||||
|
"d": "M +0.4 0.0 L -0.2 +0.1 L -0.2 -0.1 Z",
|
||||||
|
"style": ("stroke: none; fill: " + symbol_zu_farbe(symbol) + ";"),
|
||||||
|
"transform": ("rotate(" + ((richtung/6.0) * 360).toFixed(svg_float_praezission) + ")"),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
kinder_feld.push(knoten_pfeil);
|
||||||
|
}
|
||||||
|
else if (aktor instanceof mod_vtm_aufbau.klasse_leser)
|
||||||
|
{
|
||||||
|
let leser : mod_vtm_aufbau.klasse_leser = <mod_vtm_aufbau.klasse_leser>(aktor);
|
||||||
|
let richtung : mod_vtm_aufbau.typ_richtung = leser.richtung_lesen();
|
||||||
|
// ausgang ersatz
|
||||||
|
{
|
||||||
|
let knoten_pfeil = (
|
||||||
|
new mod_vtm_helfer.klasse_xmlknoten_normal
|
||||||
|
(
|
||||||
|
"path",
|
||||||
|
{
|
||||||
|
"class": "pfeil",
|
||||||
|
"d": "M +0.4 0.0 L +0.1 +0.1 L +0.1 -0.1 Z",
|
||||||
|
"style": ("stroke: none; fill: " + "hsl(0, 0%, 50%)" + ";"),
|
||||||
|
"transform": ("rotate(" + ((richtung/6.0) * 360).toFixed(svg_float_praezission) + ")"),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
kinder_feld.push(knoten_pfeil);
|
||||||
|
}
|
||||||
|
// ausgang rot
|
||||||
|
{
|
||||||
|
let knoten_pfeil = (
|
||||||
|
new mod_vtm_helfer.klasse_xmlknoten_normal
|
||||||
|
(
|
||||||
|
"path",
|
||||||
|
{
|
||||||
|
"class": "pfeil",
|
||||||
|
"d": "M +0.4 0.0 L +0.1 +0.1 L +0.1 -0.1 Z",
|
||||||
|
"style": ("stroke: none; fill: " + symbol_zu_farbe(0) + ";"),
|
||||||
|
"transform": ("rotate(" + (((richtung+1)/6.0) * 360).toFixed(svg_float_praezission) + ")"),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
kinder_feld.push(knoten_pfeil);
|
||||||
|
}
|
||||||
|
// ausgang gruen
|
||||||
|
{
|
||||||
|
let knoten_pfeil = (
|
||||||
|
new mod_vtm_helfer.klasse_xmlknoten_normal
|
||||||
|
(
|
||||||
|
"path",
|
||||||
|
{
|
||||||
|
"class": "pfeil",
|
||||||
|
"d": "M +0.4 0.0 L +0.1 +0.1 L +0.1 -0.1 Z",
|
||||||
|
"style": ("stroke: none; fill: " + symbol_zu_farbe(1) + ";"),
|
||||||
|
"transform": ("rotate(" + (((richtung-1)/6.0) * 360).toFixed(svg_float_praezission) + ")"),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
kinder_feld.push(knoten_pfeil);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (aktor instanceof mod_vtm_aufbau.klasse_annehmer)
|
||||||
|
{
|
||||||
|
let annehmer : mod_vtm_aufbau.klasse_annehmer = <mod_vtm_aufbau.klasse_annehmer>(aktor);
|
||||||
|
// TODO
|
||||||
|
console.warn("not implemented");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
let meldung : string = ("unbehandelter Aktor-Typ");
|
||||||
|
throw (new Error(meldung));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let position : typ_position = position_von_stelle(stelle);
|
||||||
|
let knoten_feld : mod_vtm_helfer.schnittstelle_xmlknoten = (
|
||||||
|
new mod_vtm_helfer.klasse_xmlknoten_normal
|
||||||
|
(
|
||||||
|
"g",
|
||||||
|
{
|
||||||
|
"class": "feld",
|
||||||
|
"transform": ("translate(" + position.x.toFixed(svg_float_praezission) + ", " + position.y.toFixed(svg_float_praezission) + ")"),
|
||||||
|
},
|
||||||
|
kinder_feld
|
||||||
|
)
|
||||||
|
);
|
||||||
|
kinder_felder.push(knoten_feld);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
;
|
||||||
|
let knoten_felder : mod_vtm_helfer.schnittstelle_xmlknoten = (
|
||||||
|
new mod_vtm_helfer.klasse_xmlknoten_normal
|
||||||
|
(
|
||||||
|
"g",
|
||||||
|
{
|
||||||
|
"class": "felder",
|
||||||
|
},
|
||||||
|
kinder_felder
|
||||||
|
)
|
||||||
|
|
||||||
|
);
|
||||||
|
kinder_welt.push(knoten_felder);
|
||||||
|
}
|
||||||
|
// figur
|
||||||
|
{
|
||||||
|
let figur : mod_vtm_aufbau.klasse_figur = this.aufbau.figur_lesen();
|
||||||
|
let position : typ_position = position_von_stelle(figur.stelle_lesen());
|
||||||
|
let knoten_figur : mod_vtm_helfer.schnittstelle_xmlknoten = (
|
||||||
|
new mod_vtm_helfer.klasse_xmlknoten_normal
|
||||||
|
(
|
||||||
|
"circle",
|
||||||
|
{
|
||||||
|
"class": "figur",
|
||||||
|
"cx": position.x.toFixed(svg_float_praezission),
|
||||||
|
"cy": position.y.toFixed(svg_float_praezission),
|
||||||
|
"r": (0.2).toFixed(svg_float_praezission),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
kinder_welt.push(knoten_figur);
|
||||||
|
}
|
||||||
|
let knoten_welt : mod_vtm_helfer.schnittstelle_xmlknoten = (
|
||||||
|
new mod_vtm_helfer.klasse_xmlknoten_normal
|
||||||
|
(
|
||||||
|
"g",
|
||||||
|
{
|
||||||
|
"class": "welt",
|
||||||
|
},
|
||||||
|
kinder_welt
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return knoten_welt;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -17,7 +17,7 @@ module mod_vtm_helfer
|
||||||
/**
|
/**
|
||||||
* @author kcf <vidofnir@folksprak.org>
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
*/
|
*/
|
||||||
private speicher : {[hashwert : string] : typ_wert};
|
private speicher : {[hashwert : string] : {schluessel : typ_schluessel; wert : typ_wert;}};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -36,7 +36,7 @@ module mod_vtm_helfer
|
||||||
public setzen(schluessel : typ_schluessel, wert : typ_wert) : void
|
public setzen(schluessel : typ_schluessel, wert : typ_wert) : void
|
||||||
{
|
{
|
||||||
let hashwert : string = this.hashfunction(schluessel);
|
let hashwert : string = this.hashfunction(schluessel);
|
||||||
this.speicher[hashwert] = wert;
|
this.speicher[hashwert] = {"schluessel": schluessel, "wert": wert};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -48,7 +48,7 @@ module mod_vtm_helfer
|
||||||
let hashwert : string = this.hashfunction(schluessel);
|
let hashwert : string = this.hashfunction(schluessel);
|
||||||
if (hashwert in this.speicher)
|
if (hashwert in this.speicher)
|
||||||
{
|
{
|
||||||
let wert : typ_wert = this.speicher[hashwert];
|
let wert : typ_wert = this.speicher[hashwert].wert;
|
||||||
return (new klasse_schlicht<typ_wert>(wert));
|
return (new klasse_schlicht<typ_wert>(wert));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -57,6 +57,23 @@ module mod_vtm_helfer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
public iterieren(prozedur : (schluessel ?: typ_schluessel, wert ?: typ_wert)=>void) : void
|
||||||
|
{
|
||||||
|
Object.keys(this.speicher).forEach
|
||||||
|
(
|
||||||
|
(hashwert) =>
|
||||||
|
{
|
||||||
|
let paar : {schluessel : typ_schluessel; wert : typ_wert;} = this.speicher[hashwert];
|
||||||
|
prozedur(paar.schluessel, paar.wert);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
23
quelldatein/helfer/mathematik.ts
Normal file
23
quelldatein/helfer/mathematik.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
|
||||||
|
module mod_vtm_helfer
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
export function div(x : int, y : int) : int
|
||||||
|
{
|
||||||
|
return Math.floor(x/y);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
export function mod(x : int, y : int) : int
|
||||||
|
{
|
||||||
|
return (x - (y * div(x, y)));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
38
quelldatein/helfer/vektor.ts
Normal file
38
quelldatein/helfer/vektor.ts
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
|
||||||
|
module mod_vtm_helfer
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
export type typ_vektor = {x : float; y : float;};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
export function vektor_polar(winkel : float, radius : float = 1) : typ_vektor
|
||||||
|
{
|
||||||
|
return {"x": (radius * Math.cos(winkel)), "y": (radius * Math.sin(winkel))};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
export function vektor_skalieren(vektor : typ_vektor, faktor : float) : typ_vektor
|
||||||
|
{
|
||||||
|
return {"x": (vektor.x * faktor), "y": (vektor.y * faktor)};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
export function vektor_addieren(vektor1 : typ_vektor, vektor2 : typ_vektor) : typ_vektor
|
||||||
|
{
|
||||||
|
return {"x": (vektor1.x + vektor2.x), "y": (vektor1.y + vektor2.y)};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
143
quelldatein/helfer/xmlknoten.ts
Normal file
143
quelldatein/helfer/xmlknoten.ts
Normal file
|
|
@ -0,0 +1,143 @@
|
||||||
|
|
||||||
|
module mod_vtm_helfer
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
function einrueckung(tiefe : int, zeichen : string = "\t") : string
|
||||||
|
{
|
||||||
|
return ((tiefe === 0) ? "" : (zeichen + einrueckung(tiefe-1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
export interface schnittstelle_xmlknoten
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
darstellen(tiefe ?: int) : string;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
export class klasse_xmlknoten_text
|
||||||
|
implements schnittstelle_xmlknoten
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
private inhalt : string;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
public constructor(inhalt : string)
|
||||||
|
{
|
||||||
|
this.inhalt = inhalt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
* @implementation
|
||||||
|
*/
|
||||||
|
public darstellen(tiefe : int = 0) : string
|
||||||
|
{
|
||||||
|
return this.inhalt;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
export class klasse_xmlknoten_normal
|
||||||
|
implements schnittstelle_xmlknoten
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
private name : string;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
private attribute : {[schluessel : string] : string} = {};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
private kinder : Array<schnittstelle_xmlknoten> = [];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
*/
|
||||||
|
public constructor(name : string, attribute : {[schluessel : string] : string} = {}, kinder : Array<schnittstelle_xmlknoten> = [])
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
this.attribute = attribute;
|
||||||
|
this.kinder = kinder;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kcf <vidofnir@folksprak.org>
|
||||||
|
* @implementation
|
||||||
|
*/
|
||||||
|
public darstellen(tiefe : int = 0) : string
|
||||||
|
{
|
||||||
|
let str : string = "";
|
||||||
|
// anfang
|
||||||
|
{
|
||||||
|
let str_anfang : string = "";
|
||||||
|
str_anfang += this.name;
|
||||||
|
// attribute
|
||||||
|
{
|
||||||
|
let str_attribute : string = "";
|
||||||
|
Object.keys(this.attribute).forEach
|
||||||
|
(
|
||||||
|
schluessel =>
|
||||||
|
{
|
||||||
|
let wert : string = this.attribute[schluessel];
|
||||||
|
str_attribute += (" " + schluessel + "=" + "\"" + wert + "\"");
|
||||||
|
}
|
||||||
|
)
|
||||||
|
;
|
||||||
|
str_anfang += str_attribute;
|
||||||
|
}
|
||||||
|
str_anfang = (einrueckung(tiefe) + "<" + str_anfang + ">" + "\n");
|
||||||
|
str += str_anfang;
|
||||||
|
}
|
||||||
|
// kinder
|
||||||
|
{
|
||||||
|
this.kinder.forEach(kind => (str += kind.darstellen(tiefe+1)));
|
||||||
|
}
|
||||||
|
// ende
|
||||||
|
{
|
||||||
|
let str_ende : string = "";
|
||||||
|
str_ende += this.name;
|
||||||
|
str_ende = (einrueckung(tiefe) + "<" + "/" + str_ende + ">" + "\n");
|
||||||
|
str += str_ende;
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -7,9 +7,44 @@ module mod_vtm_test
|
||||||
*/
|
*/
|
||||||
function haupt() : void
|
function haupt() : void
|
||||||
{
|
{
|
||||||
let welt : mod_vtm_aufbau.klasse_welt = new mod_vtm_aufbau.klasse_welt();
|
let aufbau : mod_vtm_aufbau.klasse_welt = new mod_vtm_aufbau.klasse_welt();
|
||||||
welt.feld_setzen({"u": 0, "v": 0}, new mod_vtm_aufbau.klasse_befoerderer(0));
|
aufbau.feld_setzen({"u": 0, "v": 0}, new mod_vtm_aufbau.klasse_befoerderer(0));
|
||||||
welt.fortfahren();
|
aufbau.feld_setzen({"u": +1, "v": 0}, new mod_vtm_aufbau.klasse_schreiber(0, 1));
|
||||||
|
aufbau.feld_setzen({"u": +2, "v": 0}, new mod_vtm_aufbau.klasse_leser(0));
|
||||||
|
aufbau.feld_setzen({"u": +2, "v": -1}, new mod_vtm_aufbau.klasse_annehmer());
|
||||||
|
{
|
||||||
|
let darstellung_steuerung : mod_vtm_darstellung_steuerung.klasse_web_welt = new mod_vtm_darstellung_steuerung.klasse_web_welt(aufbau);
|
||||||
|
let xmlknoten : mod_vtm_helfer.schnittstelle_xmlknoten = mod_vtm_darstellung_steuerung.svg_wurzel
|
||||||
|
(
|
||||||
|
-4, -4,
|
||||||
|
+4, +4,
|
||||||
|
500, 500,
|
||||||
|
[
|
||||||
|
new mod_vtm_helfer.klasse_xmlknoten_normal
|
||||||
|
(
|
||||||
|
"style",
|
||||||
|
{},
|
||||||
|
[
|
||||||
|
new mod_vtm_helfer.klasse_xmlknoten_text(".feld {stroke: none; fill: black;}\n"),
|
||||||
|
new mod_vtm_helfer.klasse_xmlknoten_text(".figur {stroke: none; fill: white;}\n"),
|
||||||
|
// new mod_vtm_helfer.klasse_xmlknoten_text(".pfeil {stroke: none; fill: gray;}\n"),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
,
|
||||||
|
darstellung_steuerung.darstellen()
|
||||||
|
]
|
||||||
|
)
|
||||||
|
;
|
||||||
|
console.info(xmlknoten.darstellen());
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
let weiter : boolean = aufbau.fortfahren();
|
||||||
|
if (! weiter)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue