comparison clojure/com/aurellem/gb/pokemon.clj @ 202:1ce54929bc0c

enhanced pokemon printing to print out current HP as well as current total HP.
author Robert McIntyre <rlm@mit.edu>
date Fri, 23 Mar 2012 03:31:49 -0500
parents 53a74450dc8a
children 85a2c2e2d318
comparison
equal deleted inserted replaced
201:53a74450dc8a 202:1ce54929bc0c
236 :experience experience 236 :experience experience
237 })) 237 }))
238 ([poke-num] 238 ([poke-num]
239 (pokemon-info @current-state poke-num))) 239 (pokemon-info @current-state poke-num)))
240 240
241 (def status-message
242 {:sleep-6 "sleeping. It will wake in six turns."
243 :sleep-5 "sleeping. It will wake in five turns."
244 :sleep-4 "sleeping. It will wake in four turns."
245 :sleep-3 "sleeping. It will wake in three turns."
246 :sleep-2 "sleeping. It will wake in two turns."
247 :sleep-1 "sleeping. It will wake in one turn."
248 :poisoned "poisoned."
249 :frozen "frozen solid."
250 :burned "burned."
251 :paralyzed "paralyzed."})
252
253
241 (defn print-pokemon 254 (defn print-pokemon
242 ([^SaveState state poke-num] 255 ([^SaveState state poke-num]
243 (let [info (pokemon-info state poke-num)] 256 (let [info (pokemon-info state poke-num)]
244 (printf 257 (printf
245 (str 258 (str
255 "##################################\n\n") 268 "##################################\n\n")
256 269
257 (str 270 (str
258 (:name info) 271 (:name info)
259 (str 272 (str
260 " (" (.substring (str (:species info)) 1) ")") 273 " [" (.toUpperCase
274 (.substring (str (:species info)) 1)) "]")
261 (str " Lvl." (format "%-3d" (:level (:stats info))))) 275 (str " Lvl." (format "%-3d" (:level (:stats info)))))
262 (str (:original-trainer info) " / " (:ID info))) 276 (str (:original-trainer info) " / " (:ID info)))
263 277
264 (println 278 (println
265 (str 279 (str
269 "| Defense | Speed | Special |\n") 283 "| Defense | Speed | Special |\n")
270 (str "+-----------+----------+----------" 284 (str "+-----------+----------+----------"
271 "+----------+----------+----------+"))) 285 "+----------+----------+----------+")))
272 286
273 (printf 287 (printf
274 (str "|%-11s| %5d | %5d " 288 (str "|%-11s| %5d | %5d "
275 "| %5d | %5d | %5d |\n") 289 "| %5d | %5d | %5d |\n")
276 "DV Values" (:hp (:dv info)) (:attack (:dv info)) 290 "DV Values" (:hp (:dv info)) (:attack (:dv info))
277 (:defense (:dv info)) (:speed (:dv info)) 291 (:defense (:dv info)) (:speed (:dv info))
278 (:special (:dv info))) 292 (:special (:dv info)))
279 293
280 (let [c (:stats info)] 294 (let [c (:stats info)]
281 (printf 295 (printf
282 (str "|%-11s| %5d | %5d " 296 (str "|%-11s|%8s | %5d "
283 "| %5d | %5d | %5d |\n") 297 "| %5d | %5d | %5d |\n")
284 "Current" (:hp c) (:attack c) 298 "Current" (str (:current-hp c) "/" (:hp c)) (:attack c)
285 (:defense c) (:speed c) 299 (:defense c) (:speed c)
286 (:special c))) 300 (:special c)))
287 301
288 (let [e (:experience info)] 302 (let [e (:experience info)]
289 (printf 303 (printf
290 (str "|%-11s| %5d | %5d " 304 (str "|%-11s| %5d | %5d "
291 "| %5d | %5d | %5d |\n") 305 "| %5d | %5d | %5d |\n")
292 "Experience" (:hp-exp e) (:attack-exp e) 306 "Experience" (:hp-exp e) (:attack-exp e)
293 (:defense-exp e) (:speed-exp e) 307 (:defense-exp e) (:speed-exp e)
294 (:special-exp e))) 308 (:special-exp e)))
295 (println 309 (println
296 (str "+-----------+----------+----------" 310 (str "+-----------+----------+----------"
309 current-pp (max-pp name pp-ups) pp-ups))) 323 current-pp (max-pp name pp-ups) pp-ups)))
310 324
311 (println "+------------------+----+--------+--------+\n") 325 (println "+------------------+----+--------+--------+\n")
312 326
313 (println "Total Experience:" (:main-exp (:experience info))) 327 (println "Total Experience:" (:main-exp (:experience info)))
328 (if (not= :normal (:status info))
329 (println "\n* This pokemon is currently"
330 (status-message (:status info))))
314 (if (not= (:species info) (:species2 info)) 331 (if (not= (:species info) (:species2 info))
315 (println "\nThis pokemon has a secondary species" 332 (println "\n* This pokemon has a secondary species"
316 (str 333 (str
317 "(" 334 "("
318 (.substring (str (:species2 info)) 1) ")\n") 335 (.substring (str (:species2 info)) 1) ")\n")
319 "that does not match its primary species.")) 336 " that does not match its primary species."))))
320 (if (not= :normal (:status info))
321 (println "\nThis pokemon is currently"
322 (.substring (str (:status info) ".") 1)))))
323 ([poke-num] 337 ([poke-num]
324 (print-pokemon @current-state poke-num))) 338 (print-pokemon @current-state poke-num)))
339
340 (defn print-team []
341 (dorun (map print-pokemon (range (party-number)))))
342
325 343
326 (defn give-status-all 344 (defn give-status-all
327 ([^SaveState state status] 345 ([^SaveState state status]
328 (reduce (fn [state num] 346 (reduce (fn [state num]
329 (give-status state num status)) 347 (give-status state num status))