diff options
author | elioat <elioat@tilde.institute> | 2022-12-21 21:59:42 -0500 |
---|---|---|
committer | elioat <elioat@tilde.institute> | 2022-12-21 21:59:42 -0500 |
commit | 3207b030bbfb70d95c8953a5be397c53e392f732 (patch) | |
tree | 1e80ba321fb995d8b6181a83cdccba199a1b34d5 /src/pokedex | |
parent | 8ea136db5417727a5bb286fd3c6c1cb94793474a (diff) | |
download | december-2022-3207b030bbfb70d95c8953a5be397c53e392f732.tar.gz |
*
Diffstat (limited to 'src/pokedex')
-rw-r--r-- | src/pokedex/pokedex.rkt | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/src/pokedex/pokedex.rkt b/src/pokedex/pokedex.rkt index 0adebbf..3f8d840 100644 --- a/src/pokedex/pokedex.rkt +++ b/src/pokedex/pokedex.rkt @@ -1,5 +1,11 @@ #lang racket +(require net/url + net/url-connect + json + slideshow/pict + racket/draw) + ;; let's try to make a pokedex in racket! ;; first step will be to write a function to query the pokeAPI @@ -10,15 +16,6 @@ ;; do I want to cache results, or do I want to create an offline ;; repository of poke-data to search through and sometimes update? - -;; basic GET request -(require net/url - net/url-connect - json - slideshow/pict - racket/draw) - - ;; API URL (define *POKE-API* "https://pokeapi.co/api/v2/") @@ -51,6 +48,7 @@ ; (inspector (dex-entry 11)) ; (inspector (dex-entry "bulbasaur")) + (define (get-image id sprite-file-name) "download a sprite" (define img (hash-ref (dex-entry id) "sprite")) @@ -77,7 +75,19 @@ (display-image sprite-file-name) (get-image id sprite-file-name))) -(see-pokemon "bulbasaur") -(see-pokemon "butterfree") -(see-pokemon "pikachu") -(see-pokemon 33) \ No newline at end of file +; (see-pokemon "bulbasaur") +; (see-pokemon "butterfree") +; (see-pokemon "pikachu") +; (see-pokemon 33) + +;; FIXME: I'd very much like to sort out how to display stats, types, and maybe the evolution chain. +(define (poke id [debug #f]) + "display some basic info about a pokemon given it's name or id" + (define poke-data (dex-entry id)) + (when debug + (inspector poke-data)) + (displayln (~a "name: " (hash-ref poke-data "name"))) + (displayln (~a "id: " (hash-ref poke-data "id"))) + (see-pokemon id)) + +(poke "zapdos") \ No newline at end of file |