about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorelioat <elioat@tilde.institute>2022-12-22 09:54:52 -0500
committerelioat <elioat@tilde.institute>2022-12-22 09:54:52 -0500
commitcff6b2bf1f562a93a9de189d22d0b361af3b4531 (patch)
tree7b34e8a681ba86602e6fa1ed11619a30e50d88db /src
parent2130cf09ce0340eb1239160dd9ecce2583322391 (diff)
downloaddecember-2022-cff6b2bf1f562a93a9de189d22d0b361af3b4531.tar.gz
clean up
Diffstat (limited to 'src')
-rw-r--r--src/pokedex/pokedex.rkt22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/pokedex/pokedex.rkt b/src/pokedex/pokedex.rkt
index 962d427..75918de 100644
--- a/src/pokedex/pokedex.rkt
+++ b/src/pokedex/pokedex.rkt
@@ -29,11 +29,11 @@
     "selects the info we need from the api, builds a hash table of the data that will build the entry"
     (let ([poke-data (get-pokemon id)])
         (define entry-data (make-hash))
-        (hash-set! entry-data "name" (hash-ref poke-data 'name))
-        (hash-set! entry-data "id" (hash-ref poke-data 'id))
+        (hash-set! entry-data "name"   (hash-ref poke-data 'name))
+        (hash-set! entry-data "id"     (hash-ref poke-data 'id))
         (hash-set! entry-data "sprite" (hash-ref (hash-ref poke-data 'sprites) 'front_default))
-        (hash-set! entry-data "stats" (hash-ref poke-data 'stats))
-        (hash-set! entry-data "types" (hash-ref poke-data 'types))
+        (hash-set! entry-data "stats"  (hash-ref poke-data 'stats))
+        (hash-set! entry-data "types"  (hash-ref poke-data 'types))
         entry-data))
 
 (define (inspector h)
@@ -48,6 +48,17 @@
 ; (inspector (dex-entry 11))
 ; (inspector (dex-entry "bulbasaur"))
 
+(define (capitalize-first-letter str)
+  "utility to capitalize the first letter of a string"
+  (cond
+    [(non-empty-string? str)
+     (define first-letter-str
+       (substring str 0 1))
+     (define rest-str
+       (substring str 1 (string-length str)))
+     (string-append (string-upcase first-letter-str)
+                    rest-str)]
+    [else ""]))
 
 (define (get-image id sprite-file-name)
   "download a sprite"
@@ -86,7 +97,8 @@
   (define poke-data (dex-entry id))
   (when debug
       (inspector poke-data))
-  (displayln (~a "name: " (hash-ref poke-data "name")))
+  (displayln (~a "name: "
+                 (capitalize-first-letter (hash-ref poke-data "name"))))
   (displayln (~a "id:   " (hash-ref poke-data "id")))
   (see-pokemon (hash-ref poke-data "name"))) ; using name here prevents duplicate files with different names, id.png v name.png