end # of get_recipe_list method
end # of updates to Game_Temp Class
#================================
# CRAFTING PROGRAM
#-----------------------------------------------------
#-written by Deke
#-yes_no window code created by Phsylomortis
#-----------------------------------------------------
#================================
#updates to Game_Party class
class Game_Party
attr_accessor :recipes
alias crafting_party_initialize initialize
def initialize
crafting_party_initialize
@recipes=[]
end
#------------------------------------------------------
def know?(recipe, version = 1)
unless recipe.is_a?(Game_Recipe)
recipe = get_recipe_from_master_list(recipe, version)
end
return $game_party.recipes.include?(recipe)
end
#----------------------------------------------------
def learn_recipe(recipe , version = 1)
unless recipe.is_a?(Game_Recipe)
recipe = get_recipe_from_master_list(recipe, version)
end
if recipe.is_a?(Game_Recipe)
unless know?(recipe)
@recipes.push(recipe)
end
end
end
#------------------------------------------------------
def forget_recipe(recipe , version = 1)
if !recipe.is_a?(Game_Recipe)
recipe = get_recipe_from_master_list(recipe, version)
end
if recipe.is_a?(Game_Recipe)
for i in [email protected]
if recipe == @recipes
index = i
break
end
end
if index != nil
@recipes.delete(@recipes[index])
end
end
end
#---------------------------------------------------------
def get_recipe_from_master_list(item, version)
index = nil
for i in 0...$game_temp.recipe_list.size
if item[0] == $game_temp.recipe_list.result and item[1] ==$game_temp.recipe_list.result_type
version -= 1
if version == 0
index = i
break
end
end
end
if index.is_a?(Integer)
return ($game_temp.recipe_list[index])
else
return false
end
end
end # of Game_Party updates
#================================
class Game_Recipe
#---------------------------------------------------------
def name
case @result_type
when 0
name = $data_items[@result].name
when 1
name = $data_armors[@result].name
when 2
name = $data_weapons[@result].name
end
return name
end
def item
case @result_type
when 0
item = $data_items[@result]
when 1
item = $data_armors[@result]
when 2
item = $data_weapons[@result]
end
return item
end
#-----------------------------------------------------
def have
have_all = true
for i in [email protected]
case @ingredient_types
when 0
if $game_party.item_number(@ingredients) < @quantities
have_all=false
end
when 1
if $game_party.armor_number(@ingredients) < @quantities
have_all=false
end
when 2
if $game_party.weapon_number(@ingredients) < @quantities
have_all=false
end
end
end
return have_all
end
#---------------------------------------------------------
def decrement
for i in [email protected]
case @ingredient_types
when 0
$game_party.lose_item(@ingredients, @quantities)
when 1
$game_party.lose_armor(@ingredients, @quantities)
when 2
$game_party.lose_weapon(@ingredients, @quantities)
end
end
end
#-------------------------------------------------------
def make
if have
case @result_type
when 0
$game_party.gain_item(@result, 1)
when 1
$game_party.gain_armor(@result, 1)
when 2
$game_party.gain_weapon(@result, 1)
end
decrement
end
end
#---------------------------------------------------------
def == (recipe)
if recipe.is_a?(Game_Recipe)
equal = true
if recipe.ingredients != self.ingredients
equal = false
end
if recipe.ingredient_types != self.ingredient_types
equal = false
end
if recipe.quantities != self.quantities
equal = false
end
if recipe.result != self.result
equal=false
end
if recipe.result_type != self.result_type
equal = false
end
else
equal = false
end
return equal
end
#----------------------------------------------------------
def recipe
return @data[self.index]
end
#----------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for i in 0...$game_party.recipes.size
#@craft_type为0时就显示全部物品
#不为0时就显示对应物品
if @craft_type == 0
@data.push($game_party.recipes)
elsif $game_party.recipes.craft_type == @craft_type
@data.push($game_party.recipes)
end
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
self.contents.font.name = "黑体" # = "黑体"
self.contents.font.size = 18 # = 18
for i in 0...@item_max
x = 16
y = i * 32
able = true
for ingredient in 0...@data.ingredients.size
case @data.ingredient_types[ingredient]
when 0
count = $game_party.item_number(@data.ingredients[ingredient])
when 1
count = $game_party.armor_number(@data.ingredients[ingredient])
when 2
count = $game_party.weapon_number(@data.ingredients[ingredient])
end
if count < @data.quantities[ingredient]
able = false
break
end
end
draw_item_name(@data.item, x, y, able)
end
end
end
#------------------------------------------------------------
#def draw_item(index)
# recipe = @data[index]
# self.contents.font.color = recipe.have ? normal_color : disabled_color
# x = 16
# y = index * 32
# self.contents.draw_text(x , y, self.width-32, 32, recipe.name, 0)
#end
#--------------------------------------------------------------
# ● 描绘物品名
# item : 物品
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
#--------------------------------------------------------------
def draw_item_name(item, x, y, able = true)
if item == nil
return
end
if !able
self.contents.font.color = disabled_color
end
bitmap = RPG::Cache.icon(item.icon_name)
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.draw_text(x + 28, y, 212, 32, item.name)
self.contents.font.color = normal_color
end
#--------------------------------------------------------------
def update_help
current_recipe = recipe
if current_recipe.is_a?(Game_Recipe)
case current_recipe.result_type
when 0
description = $data_items[current_recipe.result].description
when 1
description = $data_armors[current_recipe.result].description
when 2
description = $data_weapons[current_recipe.result].description
end
else
description = ""
end
@help_window.set_text(description)
@help_window.update
end
end # of Window_Craft
#=======================================
class Window_CraftResult < Window_Base
#--------------------------------------------------------------------
def update
@craft_window.update
@ingredients_window.update
if @craft_window.active
update_craft
return
end
if @yes_no_window.active
confirm_update
return
end
end
#-------------------------------------------------------------------
def update_craft
if Input.dir4 != 0
if @craft_window.data.size > 0 #本类窗口物品大于0的话
@result_window.set_result(@craft_window.recipe.result, @craft_window.recipe.result_type)
@ingredients_window.set_ingredients(@craft_window.recipe.ingredients,
@craft_window.recipe.ingredient_types,
@craft_window.recipe.quantities)
end
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C) and $game_party.recipes.size != 0
@recipe = @craft_window.recipe
if @recipe != nil
if @recipe.have
@yes_no_window.active = true
@craft_window.active = false
else
$game_system.se_play($data_system.buzzer_se)
return
end
else
$game_system.se_play($data_system.buzzer_se)
return
end
end
end
#-------------------------------------------------------------------
def confirm_update
@craft_index = @craft_window.index
@confirm_window.visible = true
@confirm_window.z = 1500
@yes_no_window.visible = true
@yes_no_window.active = true
@yes_no_window.z = 1500
@yes_no_window.update
string = "合成 " + @recipe.name + "?"
cw = @confirm_window.contents.text_size(string).width
center = @confirm_window.contents.width/2 - cw /2
unless @drawn
@confirm_window.contents.draw_text(center, 0, cw, 30, string)
@drawn = true
end
if Input.trigger?(Input::C)
if @yes_no_window.index == 0
$game_system.se_play($data_system.decision_se)
@recipe.make
$game_system.se_play($data_system.save_se)
$scene=Scene_Craft.new(@craft_type,@craft_index)
else
$game_system.se_play($data_system.cancel_se)
$scene=Scene_Craft.new(@craft_type,@craft_index)
end
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene=Scene_Craft.new(@craft_type,@craft_index)
end
end