83. #================================
84. # CRAFTING PROGRAM
85. #----------------------------------------------------------------
86. #-written by Deke
87. #-yes_no window code created by Phsylomortis
88. #----------------------------------------------------------------
89. #================================
90.
91. #updates to Game_Party class
92.
93. class Game_Party
94.
95. attr_accessor :recipes
96.
97. alias crafting_party_initialize initialize
98.
99. def initialize
100. crafting_party_initialize
101. @recipes=[]
102. end
103.
104. #----------------------------------------------------------------------
105. def know?(recipe, version = 1)
106. unless recipe.is_a?(Game_Recipe)
107. recipe = get_recipe_from_master_list(recipe, version)
108. end
109. return $game_party.recipes.include?(recipe)
110. end
111.
112. #----------------------------------------------------------------------
113. def learn_recipe(recipe , version = 1)
114. unless recipe.is_a?(Game_Recipe)
115. recipe = get_recipe_from_master_list(recipe, version)
116. end
117. if recipe.is_a?(Game_Recipe)
118. unless know?(recipe)
119. @recipes.push(recipe)
120. end
121. end
122. end
123.
124. #----------------------------------------------------------------------
125. def forget_recipe(recipe , version = 1)
126. if !recipe.is_a?(Game_Recipe)
127. recipe = get_recipe_from_master_list(recipe, version)
128. end
129. if recipe.is_a?(Game_Recipe)
130. for i in [email protected]
131. if recipe == @recipes
132. index = i
133. break
134. end
135. end
136. if index != nil
137. @recipes.delete(@recipes[index])
138. end
139. end
140. end
141.
142. #----------------------------------------------------------------------
143. def get_recipe_from_master_list(item, version)
144. index = nil
145. for i in 0...$game_temp.recipe_list.size
146. if item[0] == $game_temp.recipe_list.result and item[1] ==$game_temp.recipe_list.result_type
147. version -= 1
148. if version == 0
149. index = i
150. break
151. end
152. end
153. end
154. if index.is_a?(Integer)
155. return ($game_temp.recipe_list[index])
156. else
157. return false
158. end
159. end
160.
161. end # of Game_Party updates
162.
163. #================================
164. class Game_Recipe
165.
166. attr_reader :ingredients
167. attr_reader :quantities
168. attr_reader :result
169. attr_reader :result_type
170. attr_reader :ingredient_types
171.
172. #----------------------------------------------------------------------
173. def initialize( ingredients, ingredient_types, quantities, result, result_type)
174. @ingredients = ingredients
175. @ingredient_types = ingredient_types
176. @quantities = quantities
177. @result = result
178. @result_type = result_type
179. end
180.
181. #----------------------------------------------------------------------
182. def name
183. case @result_type
184. when 0
185. name = $data_items[@result].name
186. when 1
187. name = $data_armors[@result].name
188. when 2
189. name = $data_weapons[@result].name
190. end
191. return name
192. end
193.
194. #----------------------------------------------------------------------
195. def have
196. have_all = true
197. for i in [email protected]
198. case @ingredient_types
199. when 0
200. if $game_party.item_number(@ingredients) < @quantities
201. have_all=false
202. end
203. when 1
204. if $game_party.armor_number(@ingredients) < @quantities
205. have_all=false
206. end
207. when 2
208. if $game_party.weapon_number(@ingredients) < @quantities
209. have_all=false
210. end
211. end
212. end
213. return have_all
214. end
215.
216. #----------------------------------------------------------------------
217. def decrement
218. for i in [email protected]
219. case @ingredient_types
220. when 0
221. $game_party.lose_item(@ingredients, @quantities)
222. when 1
223. $game_party.lose_armor(@ingredients, @quantities)
224. when 2
225. $game_party.lose_weapon(@ingredients, @quantities)
226. end
227. end
228. end
229.
230. #----------------------------------------------------------------------
231. def make
232. if have
233. case @result_type
234. when 0
235. $game_party.gain_item(@result, 1)
236. when 1
237. $game_party.gain_armor(@result, 1)
238. when 2
239. $game_party.gain_weapon(@result, 1)
240. end
241. decrement
242. end
243. end
244.
245. #----------------------------------------------------------------------
246. def == (recipe)
247. if recipe.is_a?(Game_Recipe)
248. equal = true
249. if recipe.ingredients != self.ingredients
250. equal = false
251. end
252. if recipe.ingredient_types != self.ingredient_types
253. equal = false
254. end
255. if recipe.quantities != self.quantities
256. equal = false
257. end
258. if recipe.result != self.result
259. equal=false
260. end
261. if recipe.result_type != self.result_type
262. equal = false
263. end
264. else
265. equal = false
266. end
267. return equal
268. end
269.
270. end # of Game_Recipe class
271.