Skip to content

Commit

Permalink
Adding Una fiesta arruinada exercise
Browse files Browse the repository at this point in the history
  • Loading branch information
dlopezalvas committed Jul 29, 2022
1 parent 27949b0 commit 5684ccd
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/escenas/ElCangrejoAguafiestas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,34 @@
this.fondo = new Fondo('fondo.cangrejo_aguafiestas.png',0,0);
this.cantidadFilas=5;
this.cantidadColumnas=6;
var matriz= [
['T','T','T','T','T','T'],
['T','F','F','F','F','T'],
['T','T','T','T','T','T'],
['T','F','F','F','F','T'],
['T','T','T','T','T','T']]
var matriz= this.matriz()
this.cuadricula = new CuadriculaEsparsa(0,15,{alto: 360, ancho:400},{grilla:'casilla.cangrejo_aguafiestas.png'},matriz)
this.completarConGlobos();
this.automata = new CangrejoAnimado(0,0);
this.automata.escala *= 1.2;
this.cuadricula.agregarActor(this.automata,0,0);
this.agregarAutomata()

this.estado = new EstadoParaContarBuilder(this, 'explotar', 18).estadoInicial();
}

private completarConGlobos(){
agregarAutomata(){
this.cuadricula.agregarActor(this.automata,0,0);
}

completarConGlobos(){
this.cuadricula.forEachCasilla(c => {if(!c.esEsquina()) this.agregarGlobo(c)});
}

private agregarGlobo(casilla){
matriz(){
return [
['T','T','T','T','T','T'],
['T','F','F','F','F','T'],
['T','T','T','T','T','T'],
['T','F','F','F','F','T'],
['T','T','T','T','T','T']]
}

agregarGlobo(casilla){
var globo = new GloboAnimado();
this.cuadricula.agregarActorEnCasilla(globo,casilla,false);
globo.y += 20;
Expand Down
30 changes: 30 additions & 0 deletions src/escenas/UnaFiestaArruinada.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/// <reference path = "ElCangrejoAguafiestas.ts" />

class UnaFiestaArruinada extends ElCangrejoAguafiestas{
matriz(){
return [
['T','T','T','T','T'],
['F','F','T','F','F'],
['F','F','T','F','F'],
['F','F','T','F','F']]
}

agregarAutomata(){
this.cuadricula.agregarActor(this.automata,0,this.cuadricula.cantColumnas-1);
}

estaResueltoElProblema(){
return this.contarActoresConEtiqueta('GloboAnimado')==0;
}

completarColumnaConGlobos(columna, filas){
filas.forEach(fila => this.agregarGlobo(this.cuadricula.casilla(fila, columna)))
}

completarConGlobos(){
this.agregarGlobo(this.cuadricula.casilla(0,0))
if(Math.random() > 0.5){
this.completarColumnaConGlobos(2, [0,1,2,3])
}
}
}

0 comments on commit 5684ccd

Please sign in to comment.