Skip to content

Commit

Permalink
solucion
Browse files Browse the repository at this point in the history
  • Loading branch information
lspigariol committed Aug 20, 2024
0 parents commit efce10f
Show file tree
Hide file tree
Showing 8 changed files with 6,222 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: build

on: [push, pull_request]
jobs:
wollok-ts:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- run: |
wget -O wollok-ts-cli https://github.com/uqbar-project/wollok-ts-cli/releases/latest/download/wollok-ts-cli-linux-x64
chmod a+x ./wollok-ts-cli
./wollok-ts-cli test --skipValidations -p ./
shell: bash
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@


## example

TODO

139 changes: 139 additions & 0 deletions hechizos.wlk
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
class Casa {
var property opuesta
var property puntaje
}

object grifindor inherits Casa(opuesta=slyterin,puntaje=3){
method consideraPeligroso(estudiante) = false
}

object slyterin{
method consideraPeligroso(estudiante) = true
method puntaje() = 4
method opuesta() = grifindor

}

object ravenclow{
method consideraPeligroso(estudiante) = estudiante.habilidoso()
method puntaje() = 1
method opuesta() = huple

}

object huple{
method consideraPeligroso(estudiante) = estudiante.sangrePura()
method puntaje() = 1
method opuesta() = ravenclow
}


class Materia {
var property profesor
const estudiantes = []

method inscribir(e){ estudiantes.add(e)}
method darDeBaja(e){ estudiantes.remove(e)}

method dictar(){
estudiantes.forEach{e=>
e.aprender(profesor.hechizo())
e.aumentaHabilidad()}
}
method practicar(destinatario){
estudiantes.forEach{e=>
e.lanzar(profesor.hechizo(),destinatario)}
}

}

class Profesor inherits Estudiante{
var property hechizo
}


class Estudiante inherits Personaje{
const hechizos = []
var property habilidad
var casa
var property sangrePura = false

method habiloso() = habilidad > 10

method irCasaOpuesta() {
casa = casa.opuesta()
}

method aumentarHabilidad(){
habilidad = habilidad + casa.puntaje()
}
method esPeligroso() = salud > 0 and casa.consideraPeligroso(self)
method lanzar(hechizo,destinatario){
if (self.puedeLanzar(hechizo)){
hechizo.consecuencias(destinatario)
hechizo.pagarCosto(self)
}
}
method puedeLanzar(hechizo) =
hechizos.contains(hechizo) and hechizo.estaHabilitado(self)
}

class Hechizo {
var dificultad
method consecuencias(destinatario){
destinatario.disminuirSalud(self.danio())
}
method estaHabilitado(estudiante) =
estudiante.habilidad() > dificultad

method pagarCosto(estudiante) {}

method danio() = dificultad * 0.8 + 10

}

class HechizoPeligroso inherits Hechizo{

override method estaHabilitado(estudiante) =
not estudiante.esPeligroso()

override method pagarCosto(estudiante){
estudiante.disminuirHabilidad(1)
}
}

class HechizoImperdonable inherits Hechizo{
var costo
override method danio() = super() * 2

override method pagarCosto(estudiante) {
estudiante.disminuirSalud(costo)
}
}

class HechizoInventado inherits Hechizo{

override method estaHabilitado(estudiante) =
estudiante.sangrePura()

override method pagarCosto(estudiante) {
estudiante.irCasaOpuesta()
}
}

class Personaje{
var salud = 100

method disminuirSalud(cant){
salud = salud - cant
}
method salud() = salud

}

class Inmune inherits Personaje{

override method disminuirSalud(cant){
}

}
2,941 changes: 2,941 additions & 0 deletions log/wollok.log

Large diffs are not rendered by default.

3,087 changes: 3,087 additions & 0 deletions log/wollok1.log

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "hechizos",
"version": "1.0.0",
"wollokVersion": "4.0.0",
"author": "lucas",
"license": "ISC"
}
19 changes: 19 additions & 0 deletions pruebaHechizos.wtest
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import hechizos.*

describe "tests de HP"{
var inmobi = new Hechizo(dificultad = 9)
var imperius = new HechizoImperdonable(dificultad = 5,costo=30)
var her = new Estudiante(habilidad = 10, hechizos = [inmobi,imperius])
var lechuza = new Personaje(salud = 100)

test "Estudiante lanza hechizo comun"{
her.lanzar(inmobi,lechuza)
// assert.equals(82.8, lechuza.salud())
assert.equals(100 - (9*0.8 + 10), lechuza.salud())
}
test "Estudiante lanza hechizo imperdonable"{
her.lanzar(imperius,lechuza)
assert.equals(100 - (5*0.8 + 10)*2, lechuza.salud())
assert.equals(100 - 30, her.salud())
}
}
9 changes: 9 additions & 0 deletions testExample.wtest
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import example.pepita

describe "group of tests for pepita" {

test "pepita has initial energy" {
assert.equals(100, pepita.energy())
}

}

0 comments on commit efce10f

Please sign in to comment.