changeset 206:32ac21c9a30d

augmented print-pokemon to report inconsistent types; fixed error in give-type
author Robert McIntyre <rlm@mit.edu>
date Fri, 23 Mar 2012 04:36:16 -0500
parents 28d35c9e3ab6
children a67f1df5d096 45f1376b578c
files clojure/com/aurellem/gb/pokemon.clj clojure/com/aurellem/gb/types.clj
diffstat 2 files changed, 17 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/gb/pokemon.clj	Fri Mar 23 04:25:17 2012 -0500
     1.2 +++ b/clojure/com/aurellem/gb/pokemon.clj	Fri Mar 23 04:36:16 2012 -0500
     1.3 @@ -333,7 +333,13 @@
     1.4                    (str
     1.5                     "("
     1.6                     (.substring (str (:species2 info)) 1) ")\n")
     1.7 -                  "  that does not match its primary species."))))
     1.8 +                  "  that does not match its primary species."))
     1.9 +       (if (not= (:type info) (pokemon->type (:species info)))
    1.10 +         (println "\n* This pokemon has a type"
    1.11 +                  (str (:type info))
    1.12 +                  "which \n"
    1.13 +                  "  is inconsistent with the default type for its"
    1.14 +                  "species."))))
    1.15    ([poke-num]
    1.16       (print-pokemon @current-state poke-num)))
    1.17  
    1.18 @@ -416,9 +422,16 @@
    1.19                        [(first move)
    1.20                         (merge {:pp (max-pp (first move))
    1.21                                 :pp-up 0} (second move))]))))))
    1.22 -
    1.23 +      ;; The game stores the pokemon's type redundantly
    1.24 +      ;; along with the species.  If it's not specified
    1.25 +      ;; then it should default to that species default type.
    1.26 +      ((fn [pokemon]
    1.27 +         (if (nil? (:type pokemon))
    1.28 +           (assoc pokemon :type
    1.29 +                  (pokemon->type (:species pokemon)))
    1.30 +           pokemon)))
    1.31 +             
    1.32        
    1.33 -
    1.34        
    1.35        ))
    1.36        
    1.37 \ No newline at end of file
     2.1 --- a/clojure/com/aurellem/gb/types.clj	Fri Mar 23 04:25:17 2012 -0500
     2.2 +++ b/clojure/com/aurellem/gb/types.clj	Fri Mar 23 04:36:16 2012 -0500
     2.3 @@ -39,7 +39,7 @@
     2.4         (set-memory-range
     2.5          state
     2.6          (pokemon-type-start-address poke-num)
     2.7 -        (map type-name->type-code types))))
     2.8 +        (map type-name->type-code types*))))
     2.9    ([poke-num types]
    2.10       (give-type @current-state poke-num types)))
    2.11