Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lgassman committed Dec 29, 2024
0 parents commit 26c9846
Show file tree
Hide file tree
Showing 9 changed files with 244 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 .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

# Local history
.history

# Wollok Log
*.log
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@


## dolarito

TODO

Binary file added assets/dolarito.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions dolarito.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
let resultado:string | undefined

const dolarApi = {
*request(this: any, self: any) : any {
resultado = undefined
try {
buscarCotizacion((res: string) => {
resultado = res
})
}
catch (error) {
resultado = `Error: ${error}`
}
},

*response(this:any, self:any): any {
return this.reify(resultado)
},
}

function buscarCotizacion(callback: (resultado: string) => void): void {
const apiUrl = 'https://api.bluelytics.com.ar/v2/latest'

fetch(apiUrl)
.then(response => {
if (!response.ok) {
callback(`Error ${response}`)
return
}
return response.json()
})
.then(data => {
const compraBlue = data.blue.value_buy
const ventaBlue = data.blue.value_sell
callback(`Dólar Blue - Compra: $${compraBlue}, Venta: $${ventaBlue}`)
})
.catch(error => {
callback(`Error: ${error}`)
})
}


export { dolarApi }
43 changes: 43 additions & 0 deletions dolarito.wlk
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import wollok.game.*

object buscando {
method text() = "BUSCANDO"
method buscar(owner) { self.error ("Ya estoy buscando")}

method buscarResultado(owner) {
const r = dolarApi.response()
if (r != null) {
game.removeTickEvent("RESULTADO")
owner.estado(new Libre(text=r))
}
}

}

class Libre {
var property text = "Apretá enter!"
method buscar(owner) {
owner.estado(buscando)
dolarApi.request()
game.onTick(1,"RESULTADO", { buscando.buscarResultado(owner) } )
}

}

object dolarito {

var property estado = new Libre()
var property position = game.center()

method image() = "dolarito.gif"
method text() = estado.text()

method buscar() {
estado.buscar(self)
}
}

object dolarApi {
method request() native
method response() native
}
18 changes: 18 additions & 0 deletions mainDolarito.wpgm
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import wollok.game.*

import dolarito.dolarito

program Doralito {
game.title("Dolarito")
game.height(10)
game.width(10)

game.addVisualCharacter(dolarito)

keyboard.enter().onPressDo({
dolarito.buscar()
})


game.start()
}
106 changes: 106 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "dolarito",
"version": "1.0.0",
"resourceFolder": "assets",
"wollokVersion": "4.0.0",
"author": "leo",
"license": "ISC"
}

0 comments on commit 26c9846

Please sign in to comment.