class Scene_Shop < Scene_MenuBase
def create_command_window
@command_window = Window_ShopCommand.new(@gold_window.x, @purchase_only)
@command_window.viewport = @viewport
@command_window.y = @help_window.height
@command_window.set_handler(:buy, method(:command_buy))
@command_window.set_handler(:sell, method(:command_sell))
#~ @command_window.set_handler(:sellalli, method(:command_sellalli))
@command_window.set_handler(:sellallw, method(:command_sellallw))
@command_window.set_handler(:sellalla, method(:command_sellalla))
@command_window.set_handler(:cancel, method(:return_scene))
end
#~ def command_sellalli
#~ for item in $game_party.items
#~ $game_party.gain_gold($game_party.item_number(item) * (item.price / 2))
#~ $game_party.lose_item(item, $game_party.item_number(item))
#~ end
#~ @gold_window.refresh
#~ @status_window.refresh
#~ @category_window.activate
#~ end
#~ def command_sellallw
#~ for item in $game_party.weapons
#~ $game_party.gain_gold($game_party.item_number(item) * (item.price / 2))
#~ $game_party.lose_item(item, $game_party.item_number(item))
#~ end
#~ @gold_window.refresh
#~ @status_window.refresh
#~ @category_window.activate
#~ end
#~ def command_sellalla
#~ for item in $game_party.armors
#~ $game_party.gain_gold($game_party.item_number(item) * (item.price / 2))
#~ $game_party.lose_item(item, $game_party.item_number(item))
#~ end
#~ @gold_window.refresh
#~ @status_window.refresh
#~ @category_window.activate
#~ end
def hasbestprefix(name)
return false if $game_variables[241] == 0
for prefix in $game_variables[241]
return true if name.include?prefix
end
return false
end
def command_sellallw
dw = load_data("Data/Weapons.rvdata2").size
for item in $game_party.weapons
if item.id >= dw and !hasbestprefix(item.name)
$game_party.gain_gold($game_party.item_number(item) * (item.price / 2))
$game_party.lose_item(item, $game_party.item_number(item))
end
end
@gold_window.refresh
@status_window.refresh
@command_window.activate
#~ @category_window.activate
#~ @category_window.hide
end
def command_sellalla
da = load_data("Data/Armors.rvdata2").size
for item in $game_party.armors
if item.id >= da and !hasbestprefix(item.name)
$game_party.gain_gold($game_party.item_number(item) * (item.price / 2))
$game_party.lose_item(item, $game_party.item_number(item))
end
end
@gold_window.refresh
@status_window.refresh
@command_window.activate
#~ @category_window.activate
#~ @category_window.hide
end
end
class Window_ShopCommand < Window_HorzCommand
def col_max
return 5#6
end
def make_command_list
add_command(Vocab::ShopBuy, :buy)
add_command(Vocab::ShopSell, :sell, !@purchase_only)
#~ add_command("卖全部物品", :sellalli, !@purchase_only)
add_command("卖全部武器", :sellallw, !@purchase_only)
add_command("卖全部防具", :sellalla, !@purchase_only)
add_command(Vocab::ShopCancel, :cancel)
end
end