From d7f45333babec54db9ca2a8f00f39abe4d7ae5a1 Mon Sep 17 00:00:00 2001 From: Miranda-03 Date: Wed, 30 Oct 2024 18:23:27 -0300 Subject: [PATCH] Algunos test del mapa y del jugador --- enemigos.wlk | 1 + jugador.wlk | 1 + miscelaneos.wlk | 2 ++ muros.wlk | 2 ++ pruebas.wtest | 75 ++++++++++++++++++++++++++++++++++++++++++++++--- 5 files changed, 77 insertions(+), 4 deletions(-) diff --git a/enemigos.wlk b/enemigos.wlk index 587ce2e..541d895 100644 --- a/enemigos.wlk +++ b/enemigos.wlk @@ -12,6 +12,7 @@ class Enemigo1{ method image() = apariencia method soyBloque() = false + method esFruta() = false var property vector_movimiento = [0, 1, 0, 0] diff --git a/jugador.wlk b/jugador.wlk index c4b8c57..a91b58b 100644 --- a/jugador.wlk +++ b/jugador.wlk @@ -16,6 +16,7 @@ class Jugador inherits FiguraConMovimiento(position = game.at(1, 1)) { } method soyBloque() = false + method esFruta() = false method volver(){ if(sincronizadorDePantallas.pantallaActual() == "jugar"){ diff --git a/miscelaneos.wlk b/miscelaneos.wlk index ea72790..37b80e6 100644 --- a/miscelaneos.wlk +++ b/miscelaneos.wlk @@ -59,6 +59,8 @@ object fondoJuego{ var property position = game.origin() var property valor = "f_slime.png" method image() = valor + method esFruta() = false + method soyBloque() = false /*method image(){ if(jugador.image() == "helado.png"){ return "f_slime.png" diff --git a/muros.wlk b/muros.wlk index 8c1bbc4..3ebf716 100644 --- a/muros.wlk +++ b/muros.wlk @@ -2,6 +2,7 @@ class Bloque{ var property position = game.center() //habrĂ¡ que posicionar los limites method image() = visual.valor() method soyBloque() = true + method esFruta() = false method ubicarYDibujar(posicion){ self.position(posicion) game.addVisual(self) @@ -17,6 +18,7 @@ class Bloque_mapa{ method image() = visual.valor() method soyBloque() = true + method esFruta() = false method Dibujar(){ game.addVisual(self) diff --git a/pruebas.wtest b/pruebas.wtest index 7342cd1..295ca13 100644 --- a/pruebas.wtest +++ b/pruebas.wtest @@ -1,9 +1,76 @@ -import pepita.* +import muros.* +import wollok.game.* +import jugador.* +import puntos.* +import niveles.* -describe "group of tests for pepita" { +describe "gruop of test for the map"{ - test "pepita has initial energy" { - assert.equals(100, pepita.energy()) + method initialize(){ + game.clear() + game.cellSize(40) + game.height(18) + game.width(18) + game.start() + nivel_1.iniciar_mapa() } + + + test "Well allocated blocks on the map"{ + assert.that(game.getObjectsIn(game.at(2, 2)).get(0).soyBloque()) + assert.that(game.getObjectsIn(game.at(2, 3)).get(0).soyBloque()) + assert.notThat(game.getObjectsIn(game.at(0, 0)).get(0).soyBloque()) + } + + test "Well allocated fruits on the map"{ + assert.equals(10, game.allVisuals().count({element => element.esFruta()})) + } + + +} + +describe "group of tests for the player" { + + const jugador = new Jugador() + + method initialize(){ + game.clear() + game.cellSize(40) + game.height(18) + game.width(18) + game.start() + jugador.posicionate() + } + + test "Player spaw is correct" { + assert.equals(game.at(1, 1), jugador.position()) + } + + test "Player collides to the left wall"{ + jugador.position(game.at(0, 1)) + assert.equals(game.at(1, 1), jugador.position()) + } + + test "Player collides to the right wall"{ + jugador.position(game.at(20, 1)) + assert.equals(game.at(1, 1), jugador.position()) + } + + test "Player collides to the top wall"{ + jugador.position(game.at(1, 20)) + assert.equals(game.at(1, 1), jugador.position()) + } + + test "Player collides to the bottom wall"{ + jugador.position(game.at(1, 0)) + assert.equals(game.at(1, 1), jugador.position()) + } + + /*test "Player can pick up a fruit"{ + var fruta = new Fruta() + fruta.ubicarYDibujar(game.at(1, 1)) + assert.equals(2, jugador.position()) + }*/ + } \ No newline at end of file