-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reciclando papeles #59
Merged
Merged
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2f1fa39
reciclando
danielferro69 74d7e51
+ en gramatica
dlopezalvas d5e028f
Merge branch 'master' into gramatica-end
dlopezalvas a557472
1.4.14
dlopezalvas a0fe18a
EstaResueltoElProblema
danielferro69 8b0205c
EstaResueltoElProblema
danielferro69 3f77ecd
ChequeandoPapeles
danielferro69 c4d12f1
no comments
danielferro69 830429a
Merge tag '1.4.14' of github.com:Program-AR/pilas-bloques-exercises i…
danielferro69 2094cb6
1.4.15
danielferro69 8e87c77
Sugerencia de Diana
danielferro69 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,30 @@ | ||
/// <reference path="../../ActorAnimado.ts"/> | ||
class Tacho extends ActorAnimado { | ||
lleno; | ||
static _grilla = 'actor.tacho.png' | ||
|
||
constructor(lleno = false) { | ||
super(0, 0, {cantColumnas: 2}); | ||
this.definirAnimacion("vacio", [0], 1); | ||
this.definirAnimacion("lleno", [1], 1); | ||
|
||
this.lleno = lleno; | ||
if(lleno) | ||
this.cargarAnimacion("lleno") | ||
else | ||
this.cargarAnimacion("vacio") | ||
} | ||
|
||
vaciar() { | ||
this.cargarAnimacion("vacio") | ||
this.lleno = false; | ||
} | ||
|
||
llenar() { | ||
this.cargarAnimacion("lleno") | ||
this.lleno = true; | ||
} | ||
|
||
estaLleno(): boolean { | ||
return this.lleno; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/// <reference path = "EscenaActividad.ts" /> | ||
/// <reference path = "../actores/CuadriculaMultiple.ts" /> | ||
/// <reference path = "../actores/segundoCiclo/Capy/Tacho.ts" /> | ||
/// <reference path = "../actores/segundoCiclo/Capy/Papel.ts" /> | ||
/// <reference path = "../actores/segundoCiclo/Capy/Capy.ts" /> | ||
|
||
class ReciclandoPapeles extends EscenaActividad { | ||
cuadricula : CuadriculaMultiple; | ||
definidor: DefinidorColumnasFijo; | ||
automata; | ||
tachos; | ||
papeles; | ||
|
||
iniciar() { | ||
this.fondo = new Fondo('fondo.capy.png',0,0); | ||
this.definidor = new DefinidorColumnasFijo(5,[5,6,8,4,7]); | ||
this.cuadricula = new CuadriculaMultiple( | ||
this.definidor, | ||
0,0, | ||
{separacionEntreCasillas: 5}, | ||
{grilla:'casilla.futbolRobots2.png', | ||
cantFilas: 5, | ||
cantColumnas: 16, | ||
alto:45,ancho:45} | ||
); | ||
this.cuadricula.cambiarImagenInicio('casillainiciomono.png'); | ||
|
||
var capy = new Capy() | ||
capy.escala *= 0.5; | ||
this.automata = new ActorCompuesto(0, 0, { subactores: [capy] }); | ||
this.cuadricula.agregarActor(this.automata, 0, 0); | ||
this.automata.escala *= 0.3; | ||
this.automata.y += 40; | ||
|
||
this.papeles=[] | ||
this.tachos=[] | ||
|
||
this.cuadricula.forEachFila((nroFila: number) => this.agregarTacho(nroFila)) | ||
this.cuadricula.forEachFila((nroFila: number) => this.agregarPapel(nroFila)) | ||
|
||
} | ||
|
||
agregarPapel(fila: number) { | ||
var elPapel = new Papel() | ||
this.cuadricula.agregarActor(elPapel, fila, 0) | ||
elPapel.aprender(Flotar, { Desvio: 2 }); | ||
this.papeles.push( new ActorCompuesto(0, 0, { subactores: [elPapel] })); | ||
} | ||
|
||
agregarTacho(fila: number) { | ||
var elTacho = new Tacho() | ||
this.cuadricula.agregarActor(elTacho, fila, this.definidor.tamanos[fila]-1) | ||
this.tachos.push( new ActorCompuesto(0, 0, { subactores: [elTacho] })); | ||
this.tachos.escala *= 0.8; | ||
} | ||
|
||
estaResueltoElProblema(){ | ||
return this.hayTachosLlenosAlFinalDeLasFilas() && this.cuadricula.cantFilas === this.cantidadDeTachosLlenos() && !this.cantidadDePapelesSinLevantar(); | ||
} | ||
|
||
hayTachosLlenosAlFinalDeLasFilas(){ | ||
return this.tachos.every( tacho => tacho.subactores[0].estaLleno() ); | ||
} | ||
|
||
cantidadDePapelesSinLevantar(): number { | ||
var cant: number = 0; | ||
this.papeles.forEach( papel => cant += papel.subactores[0].vivo ); | ||
return cant; | ||
} | ||
|
||
cantidadDeTachosLlenos(): number { | ||
var cant: number = 0; | ||
this.tachos.forEach( tacho => cant += tacho.subactores[0].estaLleno() ); | ||
return cant; | ||
} | ||
|
||
ultimasCasillas(){ | ||
return this.cuadricula.filterCasillas(casilla => casilla.esFin()); | ||
} | ||
|
||
actualizar(): void { | ||
super.actualizar(); | ||
if( !this.tachos[this.automata.casillaActual().nroFila].subactores[0].estaLleno() && | ||
this.automata.tieneAlgoEnLaMano() && | ||
this.automata.casillaActual() === this.tachos[this.automata.casillaActual().nroFila].subactores[0].casillaActual() ) | ||
this.tachos[this.automata.casillaActual().nroFila].subactores[0].llenar(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
¿Se usa la cantidad para algo más que si está resuelto el problema?
Si es solo para verificar si hay papeles quizás queda mas expresivo así
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Por un "problema en la logica" donde puedo levantar un papel y poner ese MISMO papel, sin soltarlo en todos los tachos, es que corroboro que sea la cantidad de filas. Por eso hice la cuenta. Es mas que nada para manejar el error.
No... estoy mal yo... Eso es con los tachos, no con los papeles. Esta perfecto lo que sugeris. Ya lo uso asi. Gracias
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
de todas formas, me bajo tu reforma y la pruebo en los tests y en el ejemplo. Gracias