Mercurial > vba-clojure
diff clojure/com/aurellem/gb/pokemon.clj @ 203:85a2c2e2d318
have to add default types for all pokemon.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Fri, 23 Mar 2012 04:00:42 -0500 |
parents | 1ce54929bc0c |
children | 32ac21c9a30d |
line wrap: on
line diff
1.1 --- a/clojure/com/aurellem/gb/pokemon.clj Fri Mar 23 03:31:49 2012 -0500 1.2 +++ b/clojure/com/aurellem/gb/pokemon.clj Fri Mar 23 04:00:42 2012 -0500 1.3 @@ -349,3 +349,76 @@ 1.4 (range (party-number state)))) 1.5 ([status] 1.6 (give-status-all @current-state status))) 1.7 + 1.8 + 1.9 +(def pokemon-base 1.10 + {:dv {:attack 15 :hp 15 :defense 15 1.11 + :special 15 :speed 15} 1.12 + :species :ditto 1.13 + :original-trainer "RLM" 1.14 + :ID 5195 1.15 + :status :normal 1.16 + :experience 1.17 + {:main-exp 500 1.18 + :attack-exp 0xFF 1.19 + :defense-exp 0xFF 1.20 + :speed-exp 0xFF 1.21 + :special-exp 0xFF 1.22 + :hp-exp 0xFF} 1.23 + 1.24 + :stats 1.25 + ;; TODO recalculate these from a real ditto 1.26 + {:level 7 1.27 + :current-hp 50 1.28 + :hp 50 1.29 + :attack 50 1.30 + :defense 50 1.31 + :speed 50 1.32 + :special 50} 1.33 + 1.34 + 1.35 + :moves [[:transform {:pp-up 3 :pp 5}]]}) 1.36 + 1.37 +(defn expand-pokemon 1.38 + "Given a map describing a pokemon, fill in any missing 1.39 + values based on the ones already present." 1.40 + [pokemon] 1.41 + (-> (merge pokemon-base pokemon) 1.42 + ;; if no nickname is supplied, default to the 1.43 + ;; uppercase name of the species, as r/b/y do 1.44 + ;; when a pokemon is captured. 1.45 + ((fn [pokemon] 1.46 + (if (nil? (:name pokemon)) 1.47 + (assoc pokemon :name (.toUpperCase 1.48 + (.substring 1.49 + (str (:species pokemon)) 1))) 1.50 + pokemon))) 1.51 + ;; species2 should almost always just be the 1.52 + ;; same as species. 1.53 + ((fn [pokemon] 1.54 + (if (nil? (:species2 pokemon)) 1.55 + (assoc pokemon :species2 (:species pokemon))))) 1.56 + 1.57 + ;; enable the date in :moves to be any combo of 1.58 + ;; [:move-1 :move-2] 1.59 + ;; [[:move-1 {:pp 20}] :move-2] 1.60 + ;; [[:move-1 {:pp 20 :pp-up 3}] :move-2] 1.61 + ;; default to full pp for the move, with no 1.62 + ;; pp-ups. 1.63 + ((fn [pokemon] 1.64 + (let [moves (:moves pokemon)] 1.65 + (assoc pokemon :moves 1.66 + (for [move moves] 1.67 + (cond 1.68 + (keyword? move) 1.69 + [move {:pp (max-pp move) :pp-up 0}] 1.70 + (vector? move) 1.71 + [(first move) 1.72 + (merge {:pp (max-pp (first move)) 1.73 + :pp-up 0} (second move))])))))) 1.74 + 1.75 + 1.76 + 1.77 + 1.78 + )) 1.79 + 1.80 \ No newline at end of file