view clojure/com/aurellem/gb/types.clj @ 289:df9cad9909d2

Fixed missing delimiter in gb.moves; preparing to play with type effectiveness.
author Dylan Holmes <ocsenave@gmail.com>
date Thu, 29 Mar 2012 13:49:40 -0500
parents 32ac21c9a30d
children c31cb3043087
line wrap: on
line source
1 (ns com.aurellem.gb.types
2 (:use (com.aurellem.gb gb-driver util constants))
3 (:import [com.aurellem.gb.gb_driver SaveState]))
5 (def type-code->type-name
6 {0x00 :normal
7 0x01 :fighting
8 0x02 :flying
9 0x03 :poision
10 0x04 :ground
11 0x05 :rock
12 0x07 :bug
13 0x08 :ghost
14 0x14 :fire
15 0x15 :water
16 0x16 :grass
17 0x17 :electric
18 0x18 :psychic
19 0x19 :ice
20 0x1A :dragon })
22 (def type-name->type-code
23 (zipmap (vals type-code->type-name)
24 (keys type-code->type-name)))
26 (def pokemon-1-type-start-address 0xD16F)
28 (defn pokemon-type-start-address [poke-num]
29 (+ pokemon-1-type-start-address
30 (* pokemon-record-width poke-num)))
32 (defn give-type
33 ([^SaveState state poke-num types]
34 (assert (<= 0 poke-num 5))
35 (let [types*
36 (if (= (count types) 1)
37 [(first types) (first types)]
38 types)]
39 (set-memory-range
40 state
41 (pokemon-type-start-address poke-num)
42 (map type-name->type-code types*))))
43 ([poke-num types]
44 (give-type @current-state poke-num types)))
46 (defn read-type
47 ([^SaveState state poke-num]
48 (assert (<= 0 poke-num 5))
49 (let [types-start (pokemon-type-start-address poke-num)
50 [type-1 type-2]
51 (subvec (vec (memory state))
52 types-start (+ 2 types-start))]
53 (if (= type-1 type-2)
54 [(type-code->type-name type-1)]
55 (mapv type-code->type-name [type-1 type-2]))))
56 ([poke-num]
57 (read-type @current-state poke-num)))
59 (def pokemon->type
60 {:abra [:psychic]
61 :aerodactyl [:rock :flying]
62 :alakazam [:psychic]
63 :arbok [:poison]
64 :arcanine [:fire]
65 :articuno [:ice :flying]
66 :beedrill [:bug :poison]
67 :bellsprout [:grass :poison]
68 :blastoise [:water]
69 :bulbasaur [:grass :poison]
70 :butterfree [:bug :flying]
71 :caterpie [:bug]
72 :chansey [:normal]
73 :charizard [:fire :flying]
74 :charmander [:fire]
75 :charmeleon [:fire]
76 :clefable [:normal]
77 :clefairy [:normal]
78 :cloyster [:water :ice]
79 :cubone [:ground]
80 :dewgong [:water :ice]
81 :diglett [:ground]
82 :ditto [:normal]
83 :dodrio [:normal :flying]
84 :doduo [:normal :flying]
85 :dragonair [:dragon]
86 :dragonite [:dragon :flying]
87 :dratini [:dragon]
88 :drowzee [:psychic]
89 :dugtrio [:ground]
90 :eevee [:normal]
91 :ekans [:poison]
92 :electabuzz [:electric]
93 :electrode [:electric]
94 :exeggcute [:grass :psychic]
95 :exeggutor [:grass :psychic]
96 :farfetchd [:normal :flying]
97 :fearow [:normal :flying]
98 :flareon [:fire]
99 :gastly [:ghost :poison]
100 :gengar [:ghost :poison]
101 :geodude [:rock :ground]
102 :gloom [:grass :poison]
103 :golbat [:poison :flying]
104 :goldeen [:water]
105 :golduck [:water]
106 :golem [:rock :ground]
107 :graveler [:rock :ground]
108 :grimer [:poison]
109 :growlithe [:fire]
110 :gyarados [:water :flying]
111 :haunter [:ghost :poison]
112 :hitmonchan [:fighting]
113 :hitmonlee [:fighting]
114 :horsea [:water]
115 :hypno [:psychic]
116 :ivysaur [:grass :poison]
117 :jigglypuff [:normal]
118 :jolteon [:electric]
119 :jynx [:ice :psychic]
120 :kabuto [:rock :water]
121 :kabutops [:rock :water]
122 :kadabra [:psychic]
123 :kakuna [:bug :poison]
124 :kangaskhan [:normal]
125 :kingler [:water]
126 :koffing [:poison]
127 :krabby [:water]
128 :lapras [:water :ice]
129 :lickitung [:normal]
130 :machamp [:fighting]
131 :machoke [:fighting]
132 :machop [:fighting]
133 :magikarp [:water]
134 :magmar [:fire]
135 :magnemite [:electric]
136 :magneton [:electric]
137 :mankey [:fighting]
138 :marowak [:ground]
139 :meowth [:normal]
140 :metapod [:bug]
141 :mew [:psychic]
142 :mewtwo [:psychic]
143 :moltres [:fire :flying]
144 :mr-mime [:psychic]
145 :muk [:poison]
146 :nidoking [:poison :ground]
147 :nidoqueen [:poison :ground]
148 :nidoran-female [:poison]
149 :nidoran-male [:poison]
150 :nidorina [:poison]
151 :nidorino [:poison]
152 :ninetails [:fire]
153 :oddish [:grass :poison]
154 :omanyte [:rock :water]
155 :omastar [:rock :water]
156 :onix [:rock :ground]
157 :paras [:bug :grass]
158 :parasect [:bug :grass]
159 :persian [:normal]
160 :pidgeot [:normal :flying]
161 :pidgeotto [:normal :flying]
162 :pidgey [:normal :flying]
163 :pikachu [:electric]
164 :pinsir [:bug]
165 :poliwag [:water]
166 :poliwhirl [:water]
167 :poliwrath [:water :fighting]
168 :ponyta [:fire]
169 :porygon [:normal]
170 :primeape [:fighting]
171 :psyduck [:water]
172 :raichu [:electric]
173 :rapidash [:fire]
174 :raticate [:normal]
175 :rattata [:normal]
176 :rhydon [:ground :rock]
177 :rhyhorn [:ground :rock]
178 :sandshrew [:ground]
179 :sandslash [:ground]
180 :scyther [:bug :flying]
181 :seaking [:water]
182 :sedra [:water]
183 :seel [:water]
184 :shellder [:water]
185 :slowbro [:water :psychic]
186 :slowpoke [:water :psychic]
187 :snorlax [:normal]
188 :spearow [:normal :flying]
189 :squirtle [:water]
190 :starmie [:water :psychic]
191 :staryu [:water]
192 :tangela [:grass]
193 :tauros [:normal]
194 :tentacool [:water :poison]
195 :tentacruel [:water :poison]
196 :vaporeon [:water]
197 :venomoth [:bug :poison]
198 :venonat [:bug :poison]
199 :venusaur [:grass :poison]
200 :victreebel [:grass :poison]
201 :vileplume [:grass :poison]
202 :voltorb [:electric]
203 :vulpix [:fire]
204 :wartortle [:water]
205 :weedle [:bug :poison]
206 :weepenbell [:grass :poison]
207 :wheezing [:poison]
208 :wigglytuff [:normal]
209 :zapdos [:electric :flying]
210 :zubat [:poison :flying]})