Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ** Window_Amount
- #------------------------------------------------------------------------------
- # Esta classe lida com a janela de quantidade.
- #------------------------------------------------------------------------------
- # Autor: Valentine
- #==============================================================================
- class Window_Amount < Window_Base
- def initialize
- super(400, 230, 150, 80)
- self.visible = false
- self.closable = true
- self.windowskin = Cache.system('Window2')
- self.title = Vocab::Amount
- @amount_box = Number_Box.new(self, 10, 20, 130, 5)
- @ok_button = Button.new(self, 60, 50, Vocab::Ok) { ok }
- end
- def show(type, item = nil, index = 0)
- super()
- @type = type
- @item = item
- @index = index
- @amount_box.clear
- @amount_box.active = true
- end
- def ok
- return if @amount_box.value == 0
- case @type
- when Constants::AMOUNT_BUY_ITEM
- buy_item
- when Constants::AMOUNT_SELL_ITEM
- sell_item
- when Constants::AMOUNT_DROP_ITEM
- drop_item
- when Constants::AMOUNT_ADD_TRADE_ITEM
- add_trade_item
- when Constants::AMOUNT_ADD_TRADE_GOLD
- add_trade_gold
- when Constants::AMOUNT_REMOVE_TRADE_ITEM
- remove_trade_item
- when Constants::AMOUNT_REMOVE_TRADE_GOLD
- remove_trade_gold
- when Constants::AMOUNT_DEPOSIT_ITEM
- deposit_item
- when Constants::AMOUNT_DEPOSIT_GOLD
- deposit_gold
- when Constants::AMOUNT_WITHDRAW_ITEM
- withdraw_item
- when Constants::AMOUNT_WITHDRAW_GOLD
- withdraw_gold
- end
- hide
- end
- def buy_item
- amount = [@amount_box.value, Configs::MAX_ITEMS - $game_party.item_number(@item)].min
- return if $game_party.full_inventory?(@item)
- if $game_party.gold < @item.price * amount
- $windows[:chat].write_message(Vocab::NotEnoughMoney, Configs::ERROR_COLOR)
- return
- end
- $network.send_buy_item(@index, amount)
- end
- def sell_item
- amount = @amount_box.value
- return if $game_party.item_number(@item) < amount
- $network.send_sell_item(@item.id, $game_party.kind_item(@item), amount)
- end
- def drop_item
- amount = @amount_box.value
- return if $game_party.item_number(@item) < amount
- if $game_map.drops.size >= Configs::MAX_MAP_DROPS
- $windows[:chat].write_message(Vocab::FullDrops, Configs::ERROR_COLOR)
- return
- end
- $network.send_add_drop(@item.id, $game_party.kind_item(@item), amount)
- end
- def add_trade_item
- amount = @amount_box.value
- return if $game_party.item_number(@item) < $game_trade.my_item_number(@item) + amount
- return if $game_trade.full_trade?(@item)
- $network.send_trade_item(@item.id, $game_party.kind_item(@item), amount)
- end
- def add_trade_gold
- amount = @amount_box.value
- return if $game_party.gold < $game_trade.my_gold + amount
- $network.send_trade_gold(amount)
- end
- def remove_trade_item
- amount = @amount_box.value
- return if $game_trade.my_item_number(@item) < amount
- return if $game_party.full_inventory?(@item)
- $network.send_trade_item(@item.id, $game_party.kind_item(@item), -amount)
- end
- def remove_trade_gold
- amount = @amount_box.value
- return if $game_trade.my_gold < amount
- $network.send_trade_gold(-amount)
- end
- def deposit_item
- amount = [@amount_box.value, Configs::MAX_ITEMS - $game_bank.item_number(@item)].min
- return if $game_party.item_number(@item) < amount
- return if $game_bank.full_bank?(@item)
- $network.send_bank_item(@item.id, $game_party.kind_item(@item), amount)
- end
- def deposit_gold
- amount = @amount_box.value
- return if $game_party.gold < amount
- $network.send_bank_gold(amount)
- end
- def withdraw_item
- amount = [@amount_box.value, Configs::MAX_ITEMS - $game_party.item_number(@item)].min
- return if $game_bank.item_number(@item) < amount
- return if $game_party.full_inventory?(@item)
- $network.send_bank_item(@item.id, $game_party.kind_item(@item), -amount)
- end
- def withdraw_gold
- amount = @amount_box.value
- return if $game_bank.gold < amount
- $network.send_bank_gold(-amount)
- end
- def update
- super
- ok if Input.trigger?(:C)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement