Mercurial > vba-clojure
diff 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 |
line wrap: on
line diff
1.1 --- a/clojure/com/aurellem/gb/pokemon.clj Fri Mar 23 02:44:45 2012 -0500 1.2 +++ b/clojure/com/aurellem/gb/pokemon.clj Fri Mar 23 03:31:49 2012 -0500 1.3 @@ -238,6 +238,19 @@ 1.4 ([poke-num] 1.5 (pokemon-info @current-state poke-num))) 1.6 1.7 +(def status-message 1.8 + {:sleep-6 "sleeping. It will wake in six turns." 1.9 + :sleep-5 "sleeping. It will wake in five turns." 1.10 + :sleep-4 "sleeping. It will wake in four turns." 1.11 + :sleep-3 "sleeping. It will wake in three turns." 1.12 + :sleep-2 "sleeping. It will wake in two turns." 1.13 + :sleep-1 "sleeping. It will wake in one turn." 1.14 + :poisoned "poisoned." 1.15 + :frozen "frozen solid." 1.16 + :burned "burned." 1.17 + :paralyzed "paralyzed."}) 1.18 + 1.19 + 1.20 (defn print-pokemon 1.21 ([^SaveState state poke-num] 1.22 (let [info (pokemon-info state poke-num)] 1.23 @@ -257,7 +270,8 @@ 1.24 (str 1.25 (:name info) 1.26 (str 1.27 - " (" (.substring (str (:species info)) 1) ")") 1.28 + " [" (.toUpperCase 1.29 + (.substring (str (:species info)) 1)) "]") 1.30 (str " Lvl." (format "%-3d" (:level (:stats info))))) 1.31 (str (:original-trainer info) " / " (:ID info))) 1.32 1.33 @@ -271,24 +285,24 @@ 1.34 "+----------+----------+----------+"))) 1.35 1.36 (printf 1.37 - (str "|%-11s| %5d | %5d " 1.38 - "| %5d | %5d | %5d |\n") 1.39 + (str "|%-11s| %5d | %5d " 1.40 + "| %5d | %5d | %5d |\n") 1.41 "DV Values" (:hp (:dv info)) (:attack (:dv info)) 1.42 (:defense (:dv info)) (:speed (:dv info)) 1.43 (:special (:dv info))) 1.44 1.45 (let [c (:stats info)] 1.46 (printf 1.47 - (str "|%-11s| %5d | %5d " 1.48 - "| %5d | %5d | %5d |\n") 1.49 - "Current" (:hp c) (:attack c) 1.50 + (str "|%-11s|%8s | %5d " 1.51 + "| %5d | %5d | %5d |\n") 1.52 + "Current" (str (:current-hp c) "/" (:hp c)) (:attack c) 1.53 (:defense c) (:speed c) 1.54 (:special c))) 1.55 1.56 (let [e (:experience info)] 1.57 (printf 1.58 - (str "|%-11s| %5d | %5d " 1.59 - "| %5d | %5d | %5d |\n") 1.60 + (str "|%-11s| %5d | %5d " 1.61 + "| %5d | %5d | %5d |\n") 1.62 "Experience" (:hp-exp e) (:attack-exp e) 1.63 (:defense-exp e) (:speed-exp e) 1.64 (:special-exp e))) 1.65 @@ -311,18 +325,22 @@ 1.66 (println "+------------------+----+--------+--------+\n") 1.67 1.68 (println "Total Experience:" (:main-exp (:experience info))) 1.69 + (if (not= :normal (:status info)) 1.70 + (println "\n* This pokemon is currently" 1.71 + (status-message (:status info)))) 1.72 (if (not= (:species info) (:species2 info)) 1.73 - (println "\nThis pokemon has a secondary species" 1.74 + (println "\n* This pokemon has a secondary species" 1.75 (str 1.76 "(" 1.77 (.substring (str (:species2 info)) 1) ")\n") 1.78 - "that does not match its primary species.")) 1.79 - (if (not= :normal (:status info)) 1.80 - (println "\nThis pokemon is currently" 1.81 - (.substring (str (:status info) ".") 1))))) 1.82 + " that does not match its primary species.")))) 1.83 ([poke-num] 1.84 (print-pokemon @current-state poke-num))) 1.85 1.86 +(defn print-team [] 1.87 + (dorun (map print-pokemon (range (party-number))))) 1.88 + 1.89 + 1.90 (defn give-status-all 1.91 ([^SaveState state status] 1.92 (reduce (fn [state num]