Skip to content

Commit

Permalink
first and expression
Browse files Browse the repository at this point in the history
  • Loading branch information
tfloxolodeiro committed May 23, 2023
1 parent 1ff022c commit c7908dd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/escenas/libroPrimaria/EscenaDesdeMapa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ abstract class EscenaDesdeMapa extends EscenaActividad {
llenarCasilla(cuadricula : Cuadricula, casilla : Casilla, mapa : MapaEscena) : void {
let nroFila : number = casilla.nroFila;
let nroColumna : number = casilla.nroColumna;
let id : string = mapa[nroFila][nroColumna];
if (id != '' && id != ' ' && id != '-') { // si no es casilla libre
let actor = this.mapearIdentificadorAActor(id, nroFila, nroColumna);
cuadricula.agregarActorEnCasilla(actor, casilla, true);
}
let ids : string[] = mapa[nroFila][nroColumna].split("&");
ids.forEach(id => {
if (id != '' && id != ' ' && id != '-') { // si no es casilla libre
let actor = this.mapearIdentificadorAActor(id, nroFila, nroColumna);
cuadricula.agregarActorEnCasilla(actor, casilla, true);
}
})
}

/**
Expand Down Expand Up @@ -440,6 +442,17 @@ class GeneradorDeCasillaMaybe implements GeneradorDeCasilla {
return 0 < proba && proba < 1;
}
}
//TODO: se asume que siempre es un simple
class GeneradorDeCasillaAnd implements GeneradorDeCasilla {
generador2: GeneradorDeCasilla
constructor(private generador1 : GeneradorDeCasilla, generador2: GeneradorDeCasilla) {this.generador2 = generador2}
generarSemillaDeCasilla(generador : GeneradorDeMapasAleatorios) : SemillaDeCasilla {
return new GeneradorDeCasillaSimple(`${this.generador1.generarSemillaDeCasilla({} as any).contenido}&${this.generador2.generarSemillaDeCasilla({} as any).contenido}`).generarSemillaDeCasilla(generador)
}
esAleatorioPara(generador): boolean {
return false
}
}

/** Corresponde al modificador `|` (recursivo). */
class GeneradorDeCasillaOpcion implements GeneradorDeCasilla {
Expand Down
4 changes: 4 additions & 0 deletions src/gramaticaAleatoria.ne
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ Option -> Subterm2 _ "|" _ Subterm2

Subterm2 -> Atom {% id %}
| Maybe {% id %}
| And {% id %}

Maybe -> Atom _ "?" {% d => new GeneradorDeCasillaMaybe(d[0]) %}
| Atom _ "?" _ "(" _ decimal _ ")"
{% d => new GeneradorDeCasillaMaybe(d[0],d[6]) %}
Expand All @@ -50,3 +52,5 @@ Col -> "*" {% d => new GeneradorDeCasillaColeccion() %}
Nil -> "-" {% d => new GeneradorDeCasillaVacia() %}

Macro -> "#" _ Id {% d => new GeneradorDeCasillaMacro(d[2]) %}

And -> Atom _ "&" _ Atom {% d => new GeneradorDeCasillaAnd(d[0], d[4]) %}

0 comments on commit c7908dd

Please sign in to comment.