-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit efce10f
Showing
8 changed files
with
6,222 additions
and
0 deletions.
There are no files selected for viewing
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,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 |
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,6 @@ | ||
|
||
|
||
## example | ||
|
||
TODO | ||
|
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,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){ | ||
} | ||
|
||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
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
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" | ||
} |
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,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()) | ||
} | ||
} |
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,9 @@ | ||
import example.pepita | ||
|
||
describe "group of tests for pepita" { | ||
|
||
test "pepita has initial energy" { | ||
assert.equals(100, pepita.energy()) | ||
} | ||
|
||
} |