comparison clojure/com/aurellem/gb/pokemon.clj @ 237:ff37bc3004a7

continuing work on map-function-addresses.
author Robert McIntyre <rlm@mit.edu>
date Sat, 24 Mar 2012 23:38:21 -0500
parents 1af1a279895b
children 8484e6f6db2c
comparison
equal deleted inserted replaced
236:30ced394823a 237:ff37bc3004a7
7 7
8 (def pokemon-names-start 0xD2B4) 8 (def pokemon-names-start 0xD2B4)
9 9
10 (defn set-party-number 10 (defn set-party-number
11 ([^SaveState state new-party-num] 11 ([^SaveState state new-party-num]
12 (set-memory state 0xD162 new-party-num)) 12 (-> state
13 (set-memory 0xD162 new-party-num)
14 (set-memory (+ 0xD162 new-party-num 1) 0xFF)))
13 ([new-party-num] 15 ([new-party-num]
14 (set-party-number @current-state new-party-num))) 16 (set-party-number @current-state new-party-num)))
15 17
16 (def party-number-address 0xD162) 18 (def party-number-address 0xD162)
17 19
199 (map pokemon-1-record backbone) 201 (map pokemon-1-record backbone)
200 poke-data)))) 202 poke-data))))
201 ([pokemon-num] 203 ([pokemon-num]
202 (print-pokemon-record @current-state pokemon-num))) 204 (print-pokemon-record @current-state pokemon-num)))
203 205
204 (def mint-berry-item-code-gsc 0x54)
205
206 (defn pokemon 206 (defn pokemon
207 ([^SaveState state poke-num] 207 ([^SaveState state poke-num]
208 (assert (<= 0 poke-num 5)) 208 (assert (<= 0 poke-num 5))
209 (let [dv-values (read-DV state poke-num) 209 (let [dv-values (read-DV state poke-num)
210 type (read-type state poke-num) 210 type (read-type state poke-num)
427 (if (nil? (:type pokemon)) 427 (if (nil? (:type pokemon))
428 (assoc pokemon :type 428 (assoc pokemon :type
429 (pokemon->type (:species pokemon))) 429 (pokemon->type (:species pokemon)))
430 pokemon))))) 430 pokemon)))))
431 431
432 (def mint-berry-item-code-gsc 0x54)
433
432 (defn give-pokemon 434 (defn give-pokemon
433 ([^SaveState state poke-num pokemon] 435 ([^SaveState state poke-num pokemon]
434 (let [pokemon* (expand-pokemon pokemon)] 436 (let [pokemon* (expand-pokemon pokemon)]
435 (-> state 437 (-> state
436 ;; expand roster if necessary 438 ;; expand roster if necessary
446 (set-OT-name poke-num (:original-trainer pokemon*)) 448 (set-OT-name poke-num (:original-trainer pokemon*))
447 (give-moves-pps poke-num (:moves pokemon*)) 449 (give-moves-pps poke-num (:moves pokemon*))
448 (give-status poke-num (:status pokemon*)) 450 (give-status poke-num (:status pokemon*))
449 (give-stats poke-num (:stats pokemon*)) 451 (give-stats poke-num (:stats pokemon*))
450 (give-experience poke-num (:experience pokemon*)) 452 (give-experience poke-num (:experience pokemon*))
451
452 ;; this was 11 dec
453 (set-memory (+ 0xD16D 453 (set-memory (+ 0xD16D
454 (* pokemon-record-width poke-num)) 454 (* pokemon-record-width poke-num))
455 0x00)))) 455 mint-berry-item-code-gsc))))
456 ([poke-num pokemon] 456 ([poke-num pokemon]
457 (give-pokemon @current-state poke-num pokemon))) 457 (give-pokemon @current-state poke-num pokemon)))
458 458
459 (defn edit-pokemon 459 (defn edit-pokemon
460 ([^SaveState state poke-num new-pokemon-data] 460 ([^SaveState state poke-num new-pokemon-data]
461 (give-pokemon state poke-num 461 (give-pokemon state poke-num
462 (merge (pokemon state poke-num) 462 (merge (pokemon state poke-num)
463 new-pokemon-data))) 463 new-pokemon-data)))
464 ([poke-num new-pokemon-data] 464 ([poke-num new-pokemon-data]
465 (edit-pokemon @current-state poke-num new-pokemon-data))) 465 (edit-pokemon @current-state poke-num new-pokemon-data)))
466
467 (def young-jigglypuff
468 {:name "JIGGLYPUFF", :species :jigglypuff, :species2 :jigglypuff,
469 :status :normal,
470 :moves [[:sing {:pp-ups 0, :current-pp 4}]],
471 :dv {:attack 8, :defense 7, :speed 4, :special 12, :hp 4},
472 :experience {:main-exp 21, :hp-exp 0, :attack-exp 0, :defense-exp
473 0, :speed-exp 0, :special-exp 0},
474 :type [:normal],
475 :original-trainer "RLM",
476 :stats {:level 3, :current-hp 5, :hp 20, :attack 8, :defense 6,
477 :speed 6, :special 7},
478 :ID 5195})