comparison clojure/com/aurellem/gb/items.clj @ 185:c8ec477beeac

added world directory for practice worldbuilding.
author Dylan Holmes <ocsenave@gmail.com>
date Thu, 22 Mar 2012 07:02:50 -0500
parents 8665160f0f3d
children 531e1342ff56
comparison
equal deleted inserted replaced
184:d585b91de06c 185:c8ec477beeac
22 0x02 :ultra-ball 22 0x02 :ultra-ball
23 0x03 :great-ball 23 0x03 :great-ball
24 0x04 :poke-ball 24 0x04 :poke-ball
25 0x05 :town-map 25 0x05 :town-map
26 0x06 :bicycle 26 0x06 :bicycle
27 0x07 :surfboard
27 0x08 :safari-ball 28 0x08 :safari-ball
28 0x09 :pokedex 29 0x09 :pokedex
29 0x0A :moon-stone 30 0x0A :moon-stone
30 0x0B :antidote 31 0x0B :antidote
31 0x0C :burn-heal 32 0x0C :burn-heal
156 0xFA :TM50 ;; substitute 157 0xFA :TM50 ;; substitute
157 0xFB :TM51 ;; "cut" 158 0xFB :TM51 ;; "cut"
158 0xFC :TM52 ;; "fly" 159 0xFC :TM52 ;; "fly"
159 0xFD :TM53 ;; "surf" 160 0xFD :TM53 ;; "surf"
160 0xFE :TM54 ;; "strength" 161 0xFE :TM54 ;; "strength"
161 0xFF :end-of-list-sentinel)) 162 0xFF :end-of-list-sentinel ;; also "flash"
163 ))
162 164
163 (def item-name->item-code 165 (def item-name->item-code
164 (zipmap (vals item-code->item-name) 166 (zipmap (vals item-code->item-name)
165 (keys item-code->item-name))) 167 (keys item-code->item-name)))
166 168
168 (let [items (item-list state)] 170 (let [items (item-list state)]
169 (map 171 (map
170 (fn [[item-code quantity]] 172 (fn [[item-code quantity]]
171 [(item-code->item-name 173 [(item-code->item-name
172 item-code 174 item-code
173 (str ":0x" (.toUpperCase (Integer/toHexString item-code)))) 175 item-code)
174 quantity]) 176 quantity])
175 (partition 177 (partition
176 2 178 2
177 (next (take-while (partial not= 255) items)))))) 179 (next (take-while (partial not= 255) items))))))
178 180
200 202
201 (defn inventory-codes [inventory] 203 (defn inventory-codes [inventory]
202 (flatten 204 (flatten
203 (concat [(count inventory)] 205 (concat [(count inventory)]
204 (map (fn [[item-name quantity]] 206 (map (fn [[item-name quantity]]
205 [(item-name->item-code item-name) 207 [(item-name->item-code item-name item-name)
206 quantity]) inventory) 208 quantity]) inventory)
207 [(item-name->item-code :end-of-list-sentinel)]))) 209 [(item-name->item-code :end-of-list-sentinel)])))
208 210
209 (defn set-inv-mem [^SaveState state inv-codes] 211 (defn set-inv-mem [^SaveState state inv-codes]
210 (set-memory-range state item-list-start 212 (set-memory-range state item-list-start