changeset 211:661d35f1b56e

merge.
author Robert McIntyre <rlm@mit.edu>
date Fri, 23 Mar 2012 05:58:41 -0500
parents 565f5d17f90a (diff) a67f1df5d096 (current diff)
children 8523faa122b0
files
diffstat 3 files changed, 64 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/gb/moves.clj	Fri Mar 23 04:43:44 2012 -0500
     1.2 +++ b/clojure/com/aurellem/gb/moves.clj	Fri Mar 23 05:58:41 2012 -0500
     1.3 @@ -264,6 +264,20 @@
     1.4       (give-pp @current-state
     1.5               pokemon-num move-num pp-ups current-pp)))
     1.6  
     1.7 +(defn give-moves-pps
     1.8 +  ([^SaveState state poke-num moves-pps]
     1.9 +     (let [new-moves
    1.10 +           (-> state
    1.11 +               (give-moves poke-num (map first moves-pps)))]
    1.12 +       (reduce (fn [state move-num]
    1.13 +                 (let [pp (second (nth moves-pps move-num))]
    1.14 +                   (give-pp state poke-num move-num
    1.15 +                            (:pp-ups pp)
    1.16 +                            (:current-pp    pp))))
    1.17 +               new-moves (range (count moves-pps)))))
    1.18 +  ([poke-num moves-pps]
    1.19 +     (give-moves-pps @current-state poke-num moves-pps)))
    1.20 +           
    1.21  
    1.22  (def move-name->move-pp
    1.23    {
    1.24 @@ -378,7 +392,7 @@
    1.25     :rock-throw    15
    1.26     :rolling-kick  15
    1.27     :sand-attack   15
    1.28 -   :scratch       30
    1.29 +   :scratch       35
    1.30     :screech       40
    1.31     :seismic-toss  20
    1.32     :selfdestruct   5
     2.1 --- a/clojure/com/aurellem/gb/pokemon.clj	Fri Mar 23 04:43:44 2012 -0500
     2.2 +++ b/clojure/com/aurellem/gb/pokemon.clj	Fri Mar 23 05:58:41 2012 -0500
     2.3 @@ -69,7 +69,7 @@
     2.4  (defn read-OT-name
     2.5    ([^SaveState state poke-num]
     2.6       (nth (original-trainers state) poke-num))
     2.7 -  ([poke-num] (read-OT @current-state poke-num)))
     2.8 +  ([poke-num] (read-OT-name @current-state poke-num)))
     2.9  
    2.10  (defn set-OT-name
    2.11    "Set the OT name for a pokemon.
    2.12 @@ -83,7 +83,7 @@
    2.13        (+ (* poke-num name-width) OT-start)
    2.14        (concat (str->character-codes new-name) [end-of-name-marker])))
    2.15    ([n new-name]
    2.16 -     (set-original-trainer @current-state n new-name)))
    2.17 +     (set-OT-name @current-state n new-name)))
    2.18  
    2.19  (def OT-ID-addresses [0xD176 0xD1A2 0xD1CE 0xD1FA 0xD226 0xD252])
    2.20  
    2.21 @@ -105,7 +105,7 @@
    2.22        (OT-ID-addresses poke-num)
    2.23        (disect-bytes-2 new-OT-num)))
    2.24    ([poke-num new-OT-num]
    2.25 -     (set-pokemon-id @current-state poke-num new-OT-num)))
    2.26 +     (set-OT-id @current-state poke-num new-OT-num)))
    2.27  
    2.28  (def unknown "[[[UNKNOWN]]]")
    2.29  
    2.30 @@ -203,7 +203,7 @@
    2.31  
    2.32  (def mint-berry-item-code-gsc 0x54)
    2.33  
    2.34 -(defn pokemon-info
    2.35 +(defn pokemon
    2.36    ([^SaveState state poke-num]
    2.37       (assert (<= 0 poke-num 5))
    2.38       (let [dv-values (read-DV state poke-num)
    2.39 @@ -236,7 +236,7 @@
    2.40          :experience experience
    2.41          }))
    2.42    ([poke-num]
    2.43 -     (pokemon-info @current-state poke-num)))
    2.44 +     (pokemon @current-state poke-num)))
    2.45  
    2.46  (def status-message
    2.47    {:sleep-6 "sleeping. It will wake in six turns."
    2.48 @@ -253,7 +253,7 @@
    2.49     
    2.50  (defn print-pokemon
    2.51    ([^SaveState state poke-num]
    2.52 -     (let [info (pokemon-info state poke-num)]
    2.53 +     (let [info (pokemon state poke-num)]
    2.54         (printf
    2.55          (str
    2.56           "##################################"
    2.57 @@ -366,24 +366,21 @@
    2.58     :status :normal
    2.59     :experience
    2.60     {:main-exp 500
    2.61 -    :attack-exp 0xFF
    2.62 -    :defense-exp 0xFF
    2.63 -    :speed-exp 0xFF
    2.64 -    :special-exp 0xFF
    2.65 -    :hp-exp 0xFF}
    2.66 +    :attack-exp 0xFFFF
    2.67 +    :defense-exp 0xFFFF
    2.68 +    :speed-exp 0xFFFF
    2.69 +    :special-exp 0xFFFF
    2.70 +    :hp-exp 0xFFFF}
    2.71  
    2.72     :stats
    2.73 -   ;; TODO recalculate these from a real ditto
    2.74     {:level 7
    2.75 -    :current-hp 50
    2.76 -    :hp 50
    2.77 -    :attack 50
    2.78 -    :defense 50
    2.79 -    :speed 50
    2.80 -    :special 50}
    2.81 -    
    2.82 -   
    2.83 -  :moves [[:transform {:pp-up 3 :pp 5}]]})
    2.84 +    :current-hp 30
    2.85 +    :hp 30
    2.86 +    :attack 18
    2.87 +    :defense 18
    2.88 +    :speed 18
    2.89 +    :special 18}
    2.90 +   :moves [[:transform {:pp-ups 3 :current-pp 5}]]})
    2.91  
    2.92  (defn expand-pokemon
    2.93    "Given a map describing a pokemon, fill in any missing
    2.94 @@ -403,7 +400,8 @@
    2.95        ;; same as species.
    2.96        ((fn [pokemon]
    2.97           (if (nil? (:species2 pokemon))
    2.98 -           (assoc pokemon :species2 (:species pokemon)))))
    2.99 +           (assoc pokemon :species2 (:species pokemon))
   2.100 +           pokemon)))
   2.101  
   2.102        ;; enable the date in :moves to be any combo of 
   2.103        ;; [:move-1 :move-2]
   2.104 @@ -417,11 +415,11 @@
   2.105                    (for [move moves]
   2.106                      (cond
   2.107                        (keyword? move)
   2.108 -                      [move {:pp (max-pp move) :pp-up 0}]
   2.109 +                      [move {:current-pp (max-pp move 0) :pp-ups 0}]
   2.110                        (vector? move)
   2.111                        [(first move)
   2.112 -                       (merge {:pp (max-pp (first move))
   2.113 -                               :pp-up 0} (second move))]))))))
   2.114 +                       (merge {:current-pp (max-pp (first move) 0)
   2.115 +                               :pp-ups 0} (second move))]))))))
   2.116        ;; The game stores the pokemon's type redundantly
   2.117        ;; along with the species.  If it's not specified
   2.118        ;; then it should default to that species default type.
   2.119 @@ -429,9 +427,26 @@
   2.120           (if (nil? (:type pokemon))
   2.121             (assoc pokemon :type
   2.122                    (pokemon->type (:species pokemon)))
   2.123 -           pokemon)))
   2.124 -             
   2.125 -      
   2.126 -      
   2.127 -      ))
   2.128 -      
   2.129 \ No newline at end of file
   2.130 +           pokemon)))))
   2.131 +
   2.132 +(defn give-pokemon
   2.133 +  ([^SaveState state poke-num pokemon]
   2.134 +     (let [pokemon* (expand-pokemon pokemon)]
   2.135 +       (-> state
   2.136 +           ;; expand roster if necessary
   2.137 +           ((fn [state]
   2.138 +              (if (< (dec (party-number state)) poke-num)
   2.139 +                (set-party-number state (inc poke-num)) state)))
   2.140 +           (rename-pokemon poke-num (:name pokemon*))
   2.141 +           (give-DV poke-num (:dv pokemon*))
   2.142 +           (give-type poke-num (:type pokemon*))
   2.143 +           (set-species poke-num (:species pokemon*))
   2.144 +           (set-species2 poke-num (:species2 pokemon*))
   2.145 +           (set-OT-id poke-num (:ID pokemon*))
   2.146 +           (set-OT-name poke-num (:original-trainer pokemon*))
   2.147 +           (give-moves-pps poke-num (:moves pokemon*))
   2.148 +           (give-status poke-num (:status pokemon*))
   2.149 +           (give-stats  poke-num (:stats  pokemon*))
   2.150 +           (give-experience poke-num (:experience pokemon*)))))
   2.151 +  ([poke-num pokemon]
   2.152 +     (give-pokemon @current-state poke-num pokemon)))
   2.153 \ No newline at end of file
     3.1 --- a/clojure/com/aurellem/gb/stats.clj	Fri Mar 23 04:43:44 2012 -0500
     3.2 +++ b/clojure/com/aurellem/gb/stats.clj	Fri Mar 23 05:58:41 2012 -0500
     3.3 @@ -28,7 +28,7 @@
     3.4  
     3.5  (defn set-current-hp
     3.6    ([^SaveState state poke-num new-hp]
     3.7 -     (set-memory state (current-hp-address poke-num)
     3.8 +     (set-memory-range state (current-hp-address poke-num)
     3.9                   (disect-bytes-2 new-hp)))
    3.10    ([poke-num new-hp]
    3.11       (set-current-hp @current-state poke-num new-hp)))
    3.12 @@ -71,9 +71,10 @@
    3.13               (disect-bytes-2 (:defense new-stats*))
    3.14               (disect-bytes-2 (:speed new-stats*))
    3.15               (disect-bytes-2 (:special new-stats*))])]
    3.16 -       (set-current-hp
    3.17 +       (set-current-hp 
    3.18          (set-memory-range state (pokemon-stats-address poke-num)
    3.19                            raw-stats)
    3.20 +        poke-num
    3.21          (:current-hp new-stats*))))
    3.22    ([poke-num new-stats]
    3.23       (give-stats @current-state poke-num new-stats)))