comparison clojure/com/aurellem/gb/species.clj @ 190:9a7a46c4aa1b

extending functionality of support namespaces in prepreation of give-pokemon
author Robert McIntyre <rlm@mit.edu>
date Thu, 22 Mar 2012 16:34:10 -0500
parents 76b031d2f586
children 893c753f8088
comparison
equal deleted inserted replaced
189:d954835b24a4 190:9a7a46c4aa1b
159 159
160 (def species-name->species-code 160 (def species-name->species-code
161 (zipmap (vals species-code->species-name) 161 (zipmap (vals species-code->species-name)
162 (keys species-code->species-name))) 162 (keys species-code->species-name)))
163 163
164 (defn pokemon-species-data-address [poke-num]
165 (+ species-ID-1 poke-num))
166
167 (defn read-species
168 ([^SaveState state poke-num]
169 (assert (<= 0 poke-num 5))
170 (species-code->species-name
171 (aget (memory state)
172 (pokemon-species-data-address poke-num))))
173 ([poke-num]
174 (read-species @current-state poke-num)))
175
164 (defn set-species 176 (defn set-species
165 ([^SaveState state pokemon-num species-name] 177 ([^SaveState state poke-num species-name]
166 (assert (<= 0 pokemon-num 5)) 178 (assert (<= 0 poke-num 5))
167 (let [species-code (species-name->species-code 179 (let [species-code (species-name->species-code
168 species-name 180 species-name
169 species-name)] 181 species-name)]
170 182
171 (set-memory state (+ species-ID-1 pokemon-num) 183 (set-memory state (pokemon-species-data-address poke-num)
172 species-code))) 184 species-code)))
173 ([pokemon-num species-name] 185 ([poke-num species-name]
174 (set-species @current-state pokemon-num species-name))) 186 (set-species @current-state poke-num species-name)))
175 187
176 188