changeset 363:79252378fd22

saving progress...]
author Robert McIntyre <rlm@mit.edu>
date Mon, 09 Apr 2012 10:35:22 -0500
parents 8d8023057b3c
children 958a333f16e2
files clojure/com/aurellem/gb/items.clj clojure/com/aurellem/run/bootstrap_1.clj
diffstat 2 files changed, 89 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/gb/items.clj	Mon Apr 09 09:25:33 2012 -0500
     1.2 +++ b/clojure/com/aurellem/gb/items.clj	Mon Apr 09 10:35:22 2012 -0500
     1.3 @@ -179,7 +179,7 @@
     1.4     0xFC :TM52     ;; "fly"	   
     1.5     0xFD :TM53     ;; "surf"	   
     1.6     0xFE :TM54     ;; "strength"      
     1.7 -   0xFF :end-of-list-sentinel ;; also "flash"
     1.8 +   0xFF :TM55     ;; "flash" (also end-of-list-sentinel)
     1.9     ))
    1.10  
    1.11  (def item-name->item-code
    1.12 @@ -198,10 +198,15 @@
    1.13        2
    1.14        raw-inventory)))
    1.15  
    1.16 -(defn inventory [^SaveState state]
    1.17 -  (let [items (item-list state)]
    1.18 -    (raw-inventory->inventory
    1.19 -     (next (take-while (partial not= 255) items)))))
    1.20 +(defn total-held-items [state]
    1.21 +  (aget (memory state) item-list-start))
    1.22 +
    1.23 +(defn inventory
    1.24 +  ([^SaveState state]
    1.25 +     (let [items (item-list state)]
    1.26 +       (raw-inventory->inventory
    1.27 +        (take (* 2 (total-held-items state)) (next items)))))
    1.28 +  ([] (inventory @current-state)))
    1.29  
    1.30  (defn print-inventory
    1.31    ([] (print-inventory @current-state))
    1.32 @@ -231,7 +236,7 @@
    1.33             (map (fn [[item-name quantity]]
    1.34                    [(item-name->item-code item-name item-name)
    1.35                     quantity]) inventory)
    1.36 -           [(item-name->item-code :end-of-list-sentinel)])))
    1.37 +           [(item-name->item-code :TM55)])))
    1.38  
    1.39  (defn set-inv-mem [^SaveState state inv-codes]
    1.40    (set-memory-range state item-list-start
     2.1 --- a/clojure/com/aurellem/run/bootstrap_1.clj	Mon Apr 09 09:25:33 2012 -0500
     2.2 +++ b/clojure/com/aurellem/run/bootstrap_1.clj	Mon Apr 09 10:35:22 2012 -0500
     2.3 @@ -550,7 +550,7 @@
     2.4            (scroll-text 6)
     2.5            close-menu)))
     2.6  
     2.7 -(defn to-celadon-poke-center
     2.8 +(defn-memo to-celadon-poke-center
     2.9    ([] (to-celadon-poke-center (get-TM13)))
    2.10    ([script]
    2.11       (->> script
    2.12 @@ -568,3 +568,80 @@
    2.13            (walk [↑ ↑ ↑ ↑])                     ; enter poke center
    2.14            (walk [↑ ↑ ↑ → → → → → → → → → →])   ; to computer
    2.15            (turn ↑))))
    2.16 +
    2.17 +(defn activate-rlm-pc [script]
    2.18 +  (->> script
    2.19 +       talk
    2.20 +       scroll-text
    2.21 +       wait-for-cursor
    2.22 +       (set-cursor 1)
    2.23 +       select-menu-entry
    2.24 +       (scroll-text 2)))
    2.25 +
    2.26 +(defn begin-deposit [script]
    2.27 +  (->> script
    2.28 +       (set-cursor 1)
    2.29 +       select-menu-entry))
    2.30 +
    2.31 +(defn begin-withdraw [script]
    2.32 +  (->> script
    2.33 +       (set-cursor 0)
    2.34 +       (select-menu-entry)))
    2.35 +
    2.36 +(defn deposit-held-item-named
    2.37 +  [item-name quantity [moves state :as script]]
    2.38 +  (let [index (count
    2.39 +               (take-while
    2.40 +                (fn [[name quant]]
    2.41 +                  (or (not= name item-name)
    2.42 +                      (< quant quantity)))
    2.43 +                  (inventory state)))]
    2.44 +    (println "index" index)
    2.45 +    (deposit-held-item index quantity script)))
    2.46 +
    2.47 +
    2.48 +(defn-memo begin-hacking
    2.49 +  ([] (begin-hacking(to-celadon-poke-center)))
    2.50 +  ([script]
    2.51 +     (->> script
    2.52 +          activate-rlm-pc
    2.53 +          begin-deposit
    2.54 +          (deposit-held-item-named 0x00           30)
    2.55 +          (deposit-held-item-named :TM01          63)
    2.56 +          (deposit-held-item-named :awakening      4)
    2.57 +          (deposit-held-item-named :thunderstone  98)
    2.58 +          (deposit-held-item-named :TM09          55)
    2.59 +          (deposit-held-item-named 0x00           55))))
    2.60 +
    2.61 +(defn open-held-items
    2.62 +  [script]
    2.63 +  (->> script
    2.64 +       select-menu-entry))
    2.65 +
    2.66 +(defn-memo hacking-2
    2.67 +  ([] (hacking-2 (begin-hacking)))
    2.68 +  ([script]
    2.69 +     (->> script
    2.70 +          close-menu
    2.71 +          close-menu
    2.72 +          end-text;;; grr
    2.73 +
    2.74 +          activate-start-menu
    2.75 +          open-held-items
    2.76 +          (toss-held-item 0 166) ;; discard cruft
    2.77 +          close-menu
    2.78 +          close-menu)))
    2.79 +
    2.80 +(defn-memo hacking-3
    2.81 +  ([] (hacking-3 (hacking-2)))
    2.82 +  ([script]
    2.83 +     (->> script
    2.84 +          activate-rlm-pc
    2.85 +          begin-withdraw
    2.86 +          (widthdraw-pc-item 0 99)
    2.87 +          (widthdraw-pc-item 0 1)
    2.88 +          (widthdraw-pc-item 2 0xFE)
    2.89 +          (widthdraw-pc-item 3 0xFE))))
    2.90 +          
    2.91 +
    2.92 +         
    2.93 \ No newline at end of file