Mercurial > vba-clojure
view clojure/com/aurellem/gb/money.clj @ 263:a44a2c459aeb
Corrected hxc-evolution so that pokemon with branched evolutions (i.e. eevee) will be fully included. As a result, altered hxc-evolution to return a list of hashes, one per evolution.
author | Dylan Holmes <ocsenave@gmail.com> |
---|---|
date | Mon, 26 Mar 2012 21:25:10 -0500 |
parents | 10e26e7ceedb |
children |
line wrap: on
line source
1 (ns com.aurellem.gb.money2 (:use (com.aurellem.gb gb-driver util))3 (:import [com.aurellem.gb.gb_driver SaveState]))5 (def money-address 0xD346)7 (defn read-money8 "lol money is stored in BCD."9 ([^SaveState state]10 (Integer/parseInt11 (apply str12 (map13 #(Integer/toHexString %)14 (subvec (vec (memory state)) money-address15 (+ money-address 3)))) 10))16 ([] (read-money @current-state)))18 (defn set-money19 ([^SaveState state new-money]20 (let [str-money (str new-money)]21 (assert (<= 0 (count str-money) 6))22 (set-memory-range23 state24 money-address25 (map #(Integer/parseInt % 16)26 (map (partial apply str)27 (partition28 229 (concat (repeat (- 6 (count str-money)) "0")30 (vec str-money))))))))31 ([new-money] (set-money @current-state new-money)))