def decrease_stock(amount)
return if @unlimited
@stock = [@stock - amount, 0].max
end
end
class Game_Shop
alias :th_shop_stock_include? :include?
def include?(index)
return false if stock(index) == 0
th_shop_stock_include?(index)
end
def stock(index)
@shop_goods[index].stock
end
end
class Window_ShopBuy < Window_Selectable
alias :th_shop_stock_include? :include?
def include?(shopGood)
return false if shopGood.stock == 0
th_shop_stock_include?(shopGood)
end
alias :th_shop_stock_draw_item :draw_item
def draw_item(index)
th_shop_stock_draw_item(index)
rect = item_rect(index)
item = @data[index]
shopGood = @goods[item]
draw_text(rect, sprintf("庫存:%d", shopGood.stock), 1) unless shopGood.unlimited?
end
alias :th_shop_stock_process_ok :process_ok
def process_ok
unless @data[index]
Sound.play_buzzer
return
end
th_shop_stock_process_ok
end
end
class Scene_Shop < Scene_MenuBase
#--------------------------------------------------------------------------
# Get amount you could buy, compared to the amount in-stock
#--------------------------------------------------------------------------
alias :th_shop_stock_max_buy :max_buy
def max_buy
party_max = th_shop_stock_max_buy
@selected_good.unlimited? ? party_max : [party_max, @selected_good.stock].min
end
#--------------------------------------------------------------------------
# Decrease the amount of stock of the selected good
#--------------------------------------------------------------------------
alias :th_shop_stock_do_buy :do_buy
def do_buy(number)
th_shop_stock_do_buy(number)
@selected_good.decrease_stock(number)
end
end