Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- # ■ Bank System [RMXP]
- # ■ Author: Bigace360
- # ■ Type: Custom Scene
- # ■ Version: 1.00
- # ■ Date: March 24, 2013
- # ■ Blog: http://bigaceworld.wordpress.com/
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- # VERSION HISTORY #
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- # 03.24.2013 (v1.00) - Finished Script
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- # INTRODUCTION #
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- # The ACE Banking System allows players to deposit and withdraw money from the
- # bank like in real life. As your money sits in the bank, the player can
- # accumulate interest over time, increasing the amount of money in the bank.
- # Savings bonds can also be purchase at the bank, to increase the players cash
- # flow as well.
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- # FEATURES #
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- # ▼ Interest Rates
- # ● Let's your Account grow by a certain percent every gametime hour
- # (But it updates every frame)
- # ▼ Savings Bonds
- # ● Lets You purchase bonds that mature over time (in hours) and give you a
- # direct interest amount from the bond
- #
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- # INSTRUCTIONS #
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- # To install this script, open up your script editor and copy/paste this script
- # to an open slot below Scene_Debug, but above Main. Remember to save.
- #
- # --------------------------------------
- # ▼ Creating Savings Bonds
- # --------------------------------------
- # ● To Create you own Savings Bonds, go to the module and scroll down to
- # Section IV and then read the instructions.
- #
- # --------------------------------------
- # ▼ Creating Dynamic Banks
- # --------------------------------------
- # ● You can easily make every bank in your game different, and have it's own
- # interest rates & available bonds.
- #
- # ● First, the template to call a bank is:
- # call_bank(interest_rate, bonds)
- #
- # ● To change the interest rate for the bank, just change interest_rate to the
- # interger amount of the interest. (5 = 5%) To leave the interest rate alone,
- # set this value to 0. It will use the last interest rate used.
- # ● For the savings bonds, bonds will be the bond ID used from the SAVINGS_BONDS
- # hash in the script's module. Any items placed within the array assigned to
- # the bond ID will be sold as savings bond.
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- # SECTIONS #
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- # ■ Game_Objects
- # ** ACE Module
- # ** Object
- # ** Bitmap
- # ** Numeric
- # ** Game_BankSystem
- # ** Interpreter
- #
- # ■ Windows
- # ** Window_Base
- # ** Window_Selectable
- # ** Window_CommandBase
- # ** Window_BankHelp
- # ** Window_BankCommand
- # ** Window_BondCommand
- # ** Window_BankSummary
- # ** Window_BankNumber
- # ** Window_Bond
- #
- # ■ Scenes
- # ** Scene_Base
- # ** Scene_Title
- # ** Scene_Bank
- #
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- #
- # Credits/Thanks:
- # - Bigace360, for the script.
- #
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- # Script Conflicts and Compatability #
- #=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
- # ● Compatibility
- # Requires the script 'Scene_Base' v1.4 or higher
- #
- # ● Alias methods
- # class Window_Base < Window
- # def initialize(*args, &block)
- #
- # class Scene_Title
- # def command_new_game(*args)
- #
- #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
- #
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- # ■ Module ACE::CORE
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- module ACE
- module CORE
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # ◆ Section I. Bank Configurations ◆
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # These are the general settings that govern the Bank settings.
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- BANK_CONFIG ={
- # :bank_win - [Opacity, Window Border?]. (Opacity Limit: 0~255)
- :bank_win => [200, false],
- # :background - Background images
- :background => 'back04',
- # :fx - Back FX (0=Moving/ 1=Still/ 2=Map)
- :fx => 0,
- # :tran_time - Transition Time.
- :tran_time => 10,
- # :tran_type - Transition Type (Name)
- :tran_type => '004-Blind04',
- # :layout - Image filename for window layout, must be in the Menu folder
- :layout => '',
- } # Do not remove this.
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # ◆ Section II. Main Command Settings ◆
- # -------------------------------------------------------------------------
- # This array adjusts what options appear in the initial item command window
- # before the items are split into separate categories. Add commands, remove
- # commands, or rearrange them. Here's a list of which does what:
- #
- # -------------------------------------------------------------------------
- # :command Description
- # -------------------------------------------------------------------------
- # :deposit Desposit Money Into Your Account
- # :withdraw Withdraw Money From your Account
- # :purchase Purchase a Savings Bond
- # :mature Take Out Mature Savings Bond
- # :exit Exit Bank
- #
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # This array arranges the order of which the commands appear in the Item
- # Command window in the Item Scene.
- BANK_COMMANDS =[
- [:deposit, "Deposit"],
- [:withdraw, "Withdraw"],
- [:purchase, "Purchase Bond"],
- [:mature, "Get Mature Bond"],
- [:exit, "Exit"],
- ] # Do not remove this.
- BANK_DESCRIPTION ={
- :deposit => "Desposit Money Into Your Account",
- :withdraw => "Withdraw Money From your Account",
- :purchase => "Purchase a Savings Bond",
- :mature => "Take Out Mature Savings Bond",
- :exit => "Exit Bank",
- } # Do not remove this.
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # ◆ Section III. Bank Status Settings ◆
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # The item status window displays information about the players bank
- # statement. Adjust the settings below to change the text that appears in
- # the status window.
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- BANK_VOCAB ={
- :summary =>{
- :header => "Activity Summary", # Header Text
- :balance => "Account Balance:", # Account Balance Text
- :owned => "Bonds Owned:", # Number of Savings Bond's Text
- :value => "Bonds Value:", # Value of Savings Bond's Text
- :interest => "Interest Rate:", # Current Interest Rate Text
- }, # Do not remove this.
- :bonds => {
- :cost => "Bond Cost:", # Bond Cost Text
- :value => "Mature Value:", # Bond Mature Value Text
- :interest => "Interest Rate:", # Bond Interest Rate Text
- :maturity => "Maturity Time:", # Length until Maturity Text
- :bought => "Time Bought:", # Time Bought Text
- :finished => "Time Finished:" # Time Finished Text
- } # Do not remove this.
- } # Do not remove this.
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # ◆ Section IV. Bank Savings Bond Settings ◆
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # This section is for creating your own Savings Bonds. Go just right BELOW
- # the Savings_Bond Class to customize your bank's savings bonds. PLEASE
- # DO NOT TOUCH THE Savings_Bond Class UNLESS YOU KNOW WHAT YOUR DOING!!!
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- #
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- # ■ Savings_Bond [DO NOT TOUCH THIS CLASS] END Configuration
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- class Savings_Bond
- attr_accessor(:name, :cost, :interest_rate, :length, :time_bought,
- :time_finished, :mature_value)
- def initialize(name, cost, interest_rate, length)
- @name = name
- @cost = cost
- @interest_rate = interest_rate
- @length = length
- @mature_value = (@cost * (1+ @interest_rate / 100.0)).to_i
- end
- # DO NOT TOUCH THIS CLASS
- def set_times
- @time_bought = Graphics.frame_count / Graphics.frame_rate
- @time_finished = @time_bought + @length * 3600
- end
- # DO NOT TOUCH THIS CLASS
- def return_time(time)
- hours = time / 60 / 60
- minutes = time / 60 % 60
- seconds = time % 60
- return sprintf("%02d:%02d:%02d", hours, minutes, seconds)
- end
- end
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # START Configurations
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # Here you can configure your own savings bonds
- #
- # bond_id => Savings_Bond.new("name", cost, interest_rate, length),
- #
- # name : Savings Bond Name
- # cost : Savings Bond Cost
- # interest_rate : Savings Bond Interest Rate (In Percent)
- # length : Length of Hours until Mature
- #-------------------------------------------------------------------------
- BANK_BOND_LIST ={
- 1 => Savings_Bond.new("CD-7", 100, 7.5, 7),
- 2 => Savings_Bond.new("CD-14", 500, 15, 14),
- 3 => Savings_Bond.new("CD-28", 2000, 20, 28),
- 4 => Savings_Bond.new("CD-1", 150, 2, 3),
- 5 => Savings_Bond.new("CD-2", 350, 3, 0),
- }
- # This hash adjusts the savings bond's sold in each of the bank ID's. Insert
- # the savings bond you want sold inside of the arrays with the bank ID as
- # the hash key. You can use number ranges to add common events quicker.
- SAVINGS_BONDS ={
- #ID => [BANK_BOND_LIST ID's],
- 0 => [], # Do not delete this line.
- 1 => [1..3, 5],
- 2 => [4],
- }
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # END Configuration
- #===========================================================================
- # ▼ Warning
- # Editting anything past this point may potentially result in causing
- # computer damage, incontinence, explosion of user's head, coma, death,
- # and/or halitosis so edit at your own risk.
- #===========================================================================
- module_function
- #--------------------------------------------------------------------------
- # convert_integer_array
- #--------------------------------------------------------------------------
- def convert_integer_array(array)
- result = []
- array.each do |i|
- case i
- when Range then result |= i.to_a
- when Integer then result |= [i]
- end
- end
- return result
- end
- #--------------------------------------------------------------------------
- # full_convert_hash
- #--------------------------------------------------------------------------
- def full_convert_hash(hash)
- result = {}
- hash.each {|key| result[key[0]] = convert_integer_array(key[1])}
- return result
- end
- SAVINGS_BONDS = full_convert_hash(SAVINGS_BONDS)
- end
- end
- #
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- # ▼ Import to Global Hash ▼ #
- ($ace_script ||= {})["Bank System"] = true
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- # ■ Bitmap
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- class Bitmap
- def clear_rect(*args)
- color = Color.new(0, 0, 0, 0)
- args << color
- fill_rect(*args)
- end
- end
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- # ■ Numeric
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- class Numeric
- def group; return self.to_s; end unless $ace_script[:ace_warrior_module]
- end
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- # ■ Game_BankSystem
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- class Game_BankSystem
- attr_accessor(:account_balance, :interest_rate, :saving_bonds)
- def initialize
- @account_balance = 0
- @interest_rate = 1
- @saving_bonds = []
- @last_interest_time = 0
- end
- def interest_time
- (Graphics.frame_count / Graphics.frame_rate - @last_interest_time) / 3600.0
- end
- def interest_amount
- (@account_balance * @interest_rate / 100.0 * interest_time).to_i
- end
- def update
- # Updates Deposited Amount
- if interest_amount > 0
- @last_interest_time = Graphics.frame_count / Graphics.frame_rate
- @account_balance += interest_amount
- # Refreshes Data Windows
- $scene.refresh_windows
- end
- end
- def deposit(amount)
- $game_party.lose_gold(amount)
- @account_balance += amount
- end
- def withdraw(amount)
- @account_balance -= amount
- $game_party.gain_gold(amount)
- end
- def add_bond(bond)
- @saving_bonds << bond
- @saving_bonds.sort! {|a, b| a.name <=> b.name}
- end
- end
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- # ■ Window_Base
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- class Window_Base < Window
- alias :ace_bankbase_initi :initialize unless $@
- def initialize(*args, &block)
- ace_bankbase_initi(*args, &block)
- bank_opacity? if $scene.is_a?(Scene_Bank)
- end
- def bank_opacity?
- bank_opacity = ACE::CORE::BANK_CONFIG[:bank_win]
- self.back_opacity = bank_opacity[0]
- self.opacity = bank_opacity[0] if bank_opacity[1]
- end
- def fitting_height(line_number)
- (line_number * 32) + (standard_padding * 2)
- end
- def standard_padding; return 16; end
- def translucent_alpha; return 160; end
- def line_height; return 32; end
- def draw_icon(icon_index, x, y, enabled = true)
- bitmap = RPG::Cache.icon(icon_index)
- self.contents.blt(x, y, bitmap, Rect.new(0, 0, 24, 24),
- enabled ? 255 : translucent_alpha)
- end
- def show; self.visible = true; self; end
- def hide; self.visible = false; self; end
- def activate; self.active = true; self; end
- def deactivate; self.active = false; self; end
- def draw_horz_line(y, contents_width, x=0)
- line_y = y + 24 / 2 - 1
- contents.fill_rect(x, line_y, contents_width, 1, line_color)
- end
- def line_color
- color = normal_color
- color.alpha = 192
- return color
- end
- end
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- # ■ Window_Selectable
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- class Window_Selectable < Window_Base
- attr_reader :item_max # item count
- def select(index); self.index = index if index; end
- def unselect; self.index = -1; end
- def col_max(n); return @column_max = n; end
- def item_rect(index)
- rect = Rect.new(0, 0, 0, 32)
- rect.width = self.width / @column_max - 32
- rect.x = index % @column_max * (rect.width + 32)
- rect.y = index / @column_max * 32
- return rect
- end
- def item_rect_for_text(index)
- rect = item_rect(index)
- rect.x += 4; rect.width -= 8
- rect
- end
- end
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- # ■ Window_CommandBase
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- class Window_CommandBase < Window_Selectable
- include ACE::CORE
- attr_reader :commands # command
- def initialize(array, width = 160)
- @data = array[1]
- commands = array[0]
- super(0, 0, width, commands.size * 32 + 32)
- @item_max = commands.size; @commands = commands
- self.contents = Bitmap.new(width - 32, @item_max * 32)
- refresh
- select(0)
- end
- def method; return @data[self.index]; end
- def alignment
- return Menu.main_menu_align if $ace_script[:ace_main_menu]
- return 0
- end
- def refresh
- self.contents = Bitmap.new(width - 32, @item_max * 32) if @item_max > 0
- @item_max.times {|i| draw_item(i)} if @item_max > 0
- end
- def draw_item(index, enabled = true)
- end
- end
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- # ■ Window_BankHelp
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- class Window_BankHelp < Window_Help
- alias :multiline_set_text :set_text unless $@
- def set_text(text, align = 0)
- return unless text != nil
- lines = text.split("\n")
- if lines.size <= 1
- multiline_set_text(text, align)
- elsif @text != text || @align != align
- self.contents.dispose
- self.contents = Bitmap.new(self.width - 32, lines.size * 20)
- lines.each_index do |i|
- if contents.text_size(lines[i]).width > contents.width-32
- contents.font.size = 14
- end
- contents.draw_text(0, i*20, contents.width, 20, lines[i], align)
- end
- @text = text; @align = align; @actor = nil
- end
- show
- end
- end
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- # ■ Window_BankCommand
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- class Window_BankCommand < Window_CommandBase
- def initialize(array)
- super(array, 196)
- end
- def draw_item(index, enabled = true)
- rect = item_rect_for_text(index)
- contents.clear_rect(rect)
- contents.font.color = normal_color
- contents.font.color.alpha = enabled ? 255 : translucent_alpha
- contents.draw_text(rect, @commands[index], alignment)
- end
- end
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- # ■ Window_BondCommand
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- class Window_BondCommand < Window_Selectable
- def initialize(commands)
- super(0, 0, 196, commands.size * 32 + 32)
- @item_max = commands.size; @commands = commands
- refresh
- select(0)
- end
- def alignment
- return Menu.main_menu_align if $ace_script[:ace_main_menu]
- return 0
- end
- def refresh(commands = @commands)
- @commands = commands
- @item_max = commands.size
- self.contents.dispose unless self.contents.nil?
- self.contents = nil unless self.contents.nil?
- self.contents = Bitmap.new(width - 32, @item_max * 32)
- @item_max.times {|i| draw_item(i)}
- end
- def draw_item(index)
- rect = Rect.new(4, 32 * index, contents.width - 8, 32)
- contents.font.color = normal_color
- contents.draw_text(rect, @commands[index], alignment)
- end
- end
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- # ■ Window_BankSummary
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- class Window_BankSummary < Window_Base
- def initialize
- super(0, 0, 444, fitting_height(5))
- self.contents = Bitmap.new(width - 32, height - 32)
- refresh
- end
- def summary(sym)
- ACE::CORE::BANK_VOCAB[:summary][sym]
- end
- def refresh
- contents.clear
- reset_font_settings if $ace_script[:ace_warrior_module]
- summary_header
- 2.times {|i| draw_horz_line(9+(i*58), contents.width)}
- summary_gold
- summary_balance
- summary_bonds_owned
- summary_bonds_value
- summary_interest
- end
- def summary_header
- contents.font.color = normal_color
- contents.draw_text(0, 0, contents.width, 24, summary(:header), 1)
- end
- def summary_gold
- contents.font.color = system_color
- text = "Current #{$data_system.words.gold}:"
- contents.draw_text(4, 32, contents.width, 24, text)
- contents.font.color = normal_color
- contents.draw_text(-4, 32, contents.width, 24, $game_party.gold.group, 2)
- end
- def summary_balance
- contents.font.color = system_color
- contents.draw_text(4, 56, contents.width, 24, summary(:balance))
- contents.font.color = normal_color
- balance = $game_bank.account_balance.group
- contents.draw_text(-4, 56, contents.width, 24, balance, 2)
- end
- def summary_bonds_owned
- contents.font.color = system_color
- contents.draw_text(4, 90, contents.width, 24, summary(:owned))
- contents.font.color = normal_color
- owned = $game_bank.saving_bonds.size.group
- contents.draw_text(-4, 90, contents.width, 24, owned, 2)
- end
- def summary_bonds_value
- value = 0
- $game_bank.saving_bonds.each {|x| value += x.mature_value}
- contents.font.color = system_color
- contents.draw_text(4, 114, contents.width, 24, summary(:value))
- contents.font.color = normal_color
- contents.draw_text(-4, 114, contents.width, 24, value.group, 2)
- end
- def summary_interest
- contents.font.color = system_color
- contents.draw_text(4, 138, contents.width, 24, summary(:interest))
- contents.font.color = normal_color
- interest = "#{$game_bank.interest_rate}%"
- contents.draw_text(-4, 138, contents.width, 24, interest, 2)
- end
- end
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- # ■ Window_BankNumber
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- class Window_BankNumber < Window_Selectable
- attr_reader :amount # money entered
- def initialize(dummy)
- super(dummy.x, dummy.y, dummy.width, dummy.height)
- self.contents = Bitmap.new(width - 32, height - 32)
- @amount = 0
- end
- def set(type)
- @type = type
- @amount = 0
- refresh
- end
- def refresh
- contents.clear
- reset_font_settings if $ace_script[:ace_warrior_module]
- draw_header
- draw_balance
- draw_transaction
- draw_horz_line(88, contents.width)
- draw_party_gold
- draw_account_balance
- end
- def name
- name = @type == :deposit ? "Deposit" : "Withdraw"
- return name
- end
- def gold
- money = $game_party.gold
- money += @type == :deposit ? -@amount : @amount
- return money
- end
- def account_balance
- money = $game_bank.account_balance
- money += @type == :deposit ? @amount : -@amount
- return money
- end
- def max
- max = @type == :deposit ? $game_party.gold : $game_bank.account_balance
- return max
- end
- def draw_header
- contents.font.color = normal_color
- contents.draw_text(0, 0, contents.width, 24, "Amount to #{name}", 1)
- draw_horz_line(10, contents.width/2, contents.width/4)
- end
- def draw_balance
- rect = Rect.new(4, 48, contents.width, 24)
- contents.font.color = system_color
- case @type
- when :deposit
- contents.draw_text(rect, "Current #{$data_system.words.gold}:")
- contents.font.color = normal_color
- rect.x -= 10
- contents.draw_text(rect, $game_party.gold.group, 2)
- when :withdraw
- contents.draw_text(rect, "Account Balance:")
- contents.font.color = normal_color
- rect.x -= 10
- contents.draw_text(rect, $game_bank.account_balance.group, 2)
- end
- end
- def draw_transaction
- rect = Rect.new(4, 72, contents.width, 24)
- contents.font.color = system_color
- contents.draw_text(rect, "#{name} Amount:")
- contents.font.color = normal_color
- rect.x -= 10
- contents.draw_text(rect, "- #{@amount.group}", 2)
- end
- def draw_party_gold
- rect = Rect.new(4, 112, contents.width, 24)
- contents.font.color = system_color
- contents.draw_text(rect, "#{$data_system.words.gold} After:")
- contents.font.color = normal_color
- rect.x -= 10
- contents.draw_text(rect, gold.group, 2)
- end
- def draw_account_balance
- rect = Rect.new(4, 136, contents.width, 24)
- contents.font.color = system_color
- contents.draw_text(rect, "Balance After:")
- contents.font.color = normal_color
- rect.x -= 10
- contents.draw_text(rect, account_balance.group, 2)
- end
- def update
- super
- return unless self.active
- last_number = @amount
- update_number
- return if @amount == last_number
- $game_system.se_play($data_system.cursor_se)
- refresh
- end
- def update_number
- change_number(1) if Input.repeat?(Input::RIGHT)
- change_number(-1) if Input.repeat?(Input::LEFT)
- change_number(max) if Input.repeat?(Input::R)
- change_number(-max) if Input.repeat?(Input::L)
- end
- def change_number(amount)
- amount *= 10 if Input.press?(Input::SHIFT)
- amount *= 100 if Input.press?(Input::CTRL)
- amount *= 1000 if Input.press?(Input::ALT)
- @amount = [[@amount + amount, max].min, 0].max
- end
- def update_help
- @help_window.set_text("#{name} #{@amount} #{$data_system.words.gold}", 1)
- end
- end
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- # ■ Window_Bond
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- class Window_Bond < Window_Base
- def initialize(summary)
- super(summary.x, summary.y, summary.width, summary.height)
- self.contents = Bitmap.new(width - 32, height - 32)
- end
- def bonds(sym)
- ACE::CORE::BANK_VOCAB[:bonds][sym]
- end
- def refresh(bond, bought = false)
- contents.clear
- reset_font_settings if $ace_script[:ace_warrior_module]
- rect = Rect.new(0, 0, contents.width, 24)
- return no_data(rect) if bond.nil?
- bond_header(bond, rect)
- 2.times {|i| draw_horz_line(9+(i*89), contents.width)}
- bond_cost(bond, rect)
- bond_mature_value(bond, rect)
- bond_interest_rate(bond, rect)
- bond_time(bond, rect)
- return unless bought # Display only if Purchased CD
- bond_time_bought(bond, rect)
- bond_time_finished(bond, rect)
- end
- def no_data(rect)
- contents.font.color = normal_color; contents.font.size = 24
- contents.draw_text(rect, "[Close]", 1)
- end
- def bond_header(bond, rect)
- contents.font.color = normal_color
- contents.draw_text(rect, bond.name, 1)
- end
- def bond_cost(bond, rect)
- rect.y += 22
- contents.font.color = system_color
- contents.draw_text(rect, bonds(:cost))
- contents.font.color = normal_color
- contents.draw_text(rect, bond.cost.group, 2)
- end
- def bond_mature_value(bond, rect)
- rect.y += 22
- contents.font.color = system_color
- contents.draw_text(rect, bonds(:value))
- contents.font.color = normal_color
- contents.draw_text(rect, "#{bond.mature_value}", 2)
- end
- def bond_interest_rate(bond, rect)
- rect.y += 22
- contents.font.color = system_color
- contents.draw_text(rect, bonds(:interest))
- contents.font.color = normal_color
- contents.draw_text(rect, "#{bond.interest_rate}%", 2)
- end
- def bond_time(bond, rect)
- rect.y += 22
- contents.font.color = system_color
- contents.draw_text(rect, bonds(:maturity))
- contents.font.color = normal_color
- contents.draw_text(rect, "#{bond.length} Hours", 2)
- end
- def bond_time_bought(bond, rect)
- rect.y += 24
- contents.font.color = system_color
- contents.draw_text(rect, bonds(:bought))
- contents.font.color = normal_color
- contents.draw_text(rect, bond.return_time(bond.time_bought), 2)
- end
- def bond_time_finished(bond, rect)
- rect.y += 22
- contents.font.color = system_color
- contents.draw_text(rect, bonds(:finished))
- contents.font.color = normal_color
- contents.draw_text(rect, bond.return_time(bond.time_finished), 2)
- end
- end
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- # ■ Interpreter
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- class Interpreter
- def call_bank(interest_rate = 1, savings_bond = 0)
- return unless $scene.is_a?(Scene_Map)
- bonds = ACE::CORE::SAVINGS_BONDS[savings_bond]
- $scene = Scene_Bank.new(interest_rate, bonds)
- end
- end
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- # ■ Scene_Title
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- class Scene_Title
- alias :ace_bank_command_new_game :command_new_game unless $@
- def command_new_game(*args)
- ace_bank_command_new_game(*args)
- $game_bank = Game_BankSystem.new
- end
- end
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- # ■ Scene_Bank
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- class Scene_Bank < Scene_Base
- include ACE::CORE
- def initialize(interest_rate = $game_bank.interest_rate, bonds = [])
- $game_bank.interest_rate = interest_rate unless interest_rate == 0
- @bonds = bonds
- end
- def start
- super
- @current_bond = nil
- @bond_bought = false
- create_menu_layout
- create_help_window
- create_command_window
- create_activity_summary_window
- create_dummy_window
- create_banknumber_window
- create_avaliable_bond
- create_owned_bond
- end
- def create_menu_layout
- super
- return if BANK_CONFIG[:layout].empty?
- @menulay.bitmap = RPG::Cache.menu(BANK_CONFIG[:layout])
- end
- def create_help_window
- @help_window = Window_Help.new
- @bankhelp_window = Window_BankHelp.new
- @bankhelp_window.y = @help_window.height + fitting_height(6)
- @bankhelp_window.width = dw = 196
- @bankhelp_window.height = dh = 480 - @bankhelp_window.y
- @bankhelp_window.contents = Bitmap.new(dw - 32, dh - 32)
- @bankhelp_window.contents.clear
- end
- def create_command_window
- @command_window = Window_BankCommand.new(create_command_list)
- @command_window.height = @ch = fitting_height(visible_line_number)
- @command_window.y = @cy = @help_window.height
- @command_window.activate
- update_help(BANK_DESCRIPTION)
- @bankhelp_window.set_text(main_help)
- end
- def create_command_list
- vocab = []; data = []
- BANK_COMMANDS.each do |command|
- case command[0]
- when :deposit, :withdraw, :purchase, :mature, :exit
- else next
- end
- vocab << command[1]; data << command[0]
- end
- return vocab, data
- end
- def create_activity_summary_window
- @activity_summary = Window_BankSummary.new
- @activity_summary.x = dx = @command_window.width
- @activity_summary.y = @command_window.y
- end
- def create_dummy_window
- dx = @activity_summary.x
- dy = @activity_summary.height + @help_window.height
- dw = @activity_summary.width
- dh = 480 - (@activity_summary.height + @help_window.height)
- @dummy_window = Window_Base.new(dx, dy, dw, dh)
- end
- def create_banknumber_window
- @bank_number_window = Window_BankNumber.new(@dummy_window)
- @bank_number_window.hide.deactivate
- @bank_number_window.help_window = @help_window
- end
- def create_avaliable_bond
- @av_bond_display_window = Window_Bond.new(@dummy_window)
- @av_bond_display_window.hide
- @av_bond_command = Window_BankCommand.new(create_avaliable_list)
- @av_bond_command.height = @ch
- @av_bond_command.y = @cy
- @av_bond_command.deactivate.hide
- end
- def create_avaliable_list
- vocab = []; data = []
- @bonds.each do |x|
- next if BANK_BOND_LIST[x].nil?
- name = BANK_BOND_LIST[x].name
- vocab << name; data << BANK_BOND_LIST[x]
- end
- vocab << "Back"
- return vocab, data
- end
- def create_owned_bond
- @own_bond_display_window = Window_Bond.new(@dummy_window)
- @own_bond_display_window.hide
- @own_bond_command = Window_BondCommand.new(create_owned_list)
- @own_bond_command.height = @ch
- @own_bond_command.y = @cy
- @own_bond_command.deactivate.hide
- end
- def create_owned_list
- vocab = []
- $game_bank.saving_bonds.each {|x| vocab << x.name}
- vocab << "Back"
- return vocab
- end
- def perform_transition
- super; BANK_CONFIG[:fx] == 2 ? map_back : bank_back
- end
- def map_back
- @spriteset = Spriteset_Map.new
- Graphics.transition(transition_speed)
- end
- def bank_back
- @back = Plane.new
- unless BANK_CONFIG[:background].empty?
- if $ace_script[:ace_main_menu]
- @back.bitmap = RPG::Cache.menu("Background/#{BANK_CONFIG[:background]}")
- else @back.bitmap = RPG::Cache.picture(BANK_CONFIG[:background])
- end
- end
- @back.z = 10
- Graphics.transition(transition_speed,
- "Graphics/Transitions/#{BANK_CONFIG[:tran_type]}")
- end
- def transition_speed
- return BANK_CONFIG[:tran_time]
- end
- def terminate
- super; BANK_CONFIG[:fx] == 2 ? @spriteset.dispose : @back.dispose
- end
- def update
- super
- @spriteset.update if BANK_CONFIG[:fx] == 2
- update_moving_windows?
- if @command_window.active; update_command_selection
- elsif @bank_number_window.active; update_account_window
- elsif @own_bond_command.active; update_owned_bond_selection
- elsif @av_bond_command.active; update_avaliable_bond_selection
- end
- end
- def update_moving_windows?
- @back.ox += 1 if BANK_CONFIG[:fx] == 0
- @back.oy += 1 if BANK_CONFIG[:fx] == 0
- end
- #--------------------------------------------------------------------------
- # * update_command_selection
- #--------------------------------------------------------------------------
- def update_command_selection
- if @last_status_index != @command_window.index
- @last_status_index = @command_window.index
- update_help(BANK_DESCRIPTION)
- end
- exit_command if Input.trigger?(Input::B)
- view_command if Input.trigger?(Input::C)
- end
- def exit_command
- $game_system.se_play($data_system.cancel_se)
- $scene = Scene_Map.new
- end
- def view_command
- case @command_window.method
- when :deposit, :withdraw then command_account
- when :purchase then command_purchase
- when :mature then command_mature
- when :exit then exit_command
- end
- end
- def command_account
- $game_system.se_play($data_system.decision_se)
- @command_window.deactivate
- @dummy_window.hide
- @bank_number_window.set(@command_window.method)
- @bank_number_window.show.activate
- refresh_windows
- refresh_help_window
- end
- def command_purchase
- $game_system.se_play($data_system.decision_se)
- @current_bond = @av_bond_command.method
- @bond_bought = false
- @command_window.deactivate.hide
- @dummy_window.hide
- refresh_windows
- @av_bond_display_window.show
- @av_bond_command.show.activate
- end
- def command_mature
- $game_system.se_play($data_system.decision_se)
- @current_bond = $game_bank.saving_bonds[@own_bond_command.index]
- @bond_bought = true
- @command_window.deactivate.hide
- @dummy_window.hide
- refresh_windows
- @own_bond_display_window.show
- @own_bond_command.show.activate
- end
- #--------------------------------------------------------------------------
- # * update_owned_bond_selection
- #--------------------------------------------------------------------------
- def update_account_window
- exit_account if Input.trigger?(Input::B)
- open_account if Input.trigger?(Input::C)
- end
- def exit_account
- $game_system.se_play($data_system.cancel_se)
- close_transaction_window
- end
- def open_account
- $game_system.se_play($data_system.shop_se)
- case @command_window.method
- when :deposit then $game_bank.deposit(amount)
- when :withdraw then $game_bank.withdraw(amount)
- end
- refresh_windows
- close_transaction_window
- end
- def close_transaction_window
- @command_window.activate.show
- @dummy_window.show
- @bank_number_window.hide.deactivate
- update_help(BANK_DESCRIPTION)
- @bankhelp_window.set_text(main_help)
- end
- #--------------------------------------------------------------------------
- # * update_avaliable_bond_selection
- #--------------------------------------------------------------------------
- def update_avaliable_bond_selection
- get_bond_exit if Input.trigger?(Input::B)
- get_bond_open if Input.trigger?(Input::C)
- updating_aval if Input.trigger?(Input::UP) || Input.trigger?(Input::DOWN)
- end
- def get_bond_exit
- $game_system.se_play($data_system.cancel_se)
- close_bond_selection(@av_bond_display_window, @av_bond_command)
- end
- def get_bond_open
- if @av_bond_command.index == @bonds.size
- $game_system.se_play($data_system.cancel_se)
- close_bond_selection(@av_bond_display_window, @av_bond_command)
- else
- current_bond = @av_bond_command.method.dup
- if current_bond.cost > $game_party.gold
- $game_system.se_play($data_system.buzzer_se)
- else
- $game_system.se_play($data_system.decision_se)
- $game_party.lose_gold(current_bond.cost)
- current_bond.set_times
- $game_bank.add_bond(current_bond)
- refresh_windows
- close_bond_selection(@av_bond_display_window, @av_bond_command)
- end
- end
- end
- def updating_aval
- @current_bond = @av_bond_command.method
- refresh_windows
- end
- #--------------------------------------------------------------------------
- # * update_owned_bond_selection
- #--------------------------------------------------------------------------
- def update_owned_bond_selection
- buy_bond_exit if Input.trigger?(Input::B)
- buy_bond_open if Input.trigger?(Input::C)
- updating_ownd if Input.trigger?(Input::UP) || Input.trigger?(Input::DOWN)
- end
- def buy_bond_exit
- $game_system.se_play($data_system.cancel_se)
- close_bond_selection(@own_bond_display_window, @own_bond_command)
- end
- def buy_bond_open
- if @own_bond_command.index == $game_bank.saving_bonds.size
- $game_system.se_play($data_system.cancel_se)
- close_bond_selection(@own_bond_display_window, @own_bond_command)
- else
- current_bond = $game_bank.saving_bonds[@own_bond_command.index]
- if current_bond.time_finished > Graphics.frame_count / Graphics.frame_rate
- $game_system.se_play($data_system.buzzer_se)
- @help_window.set_text("Savings Bond Not Mature Yet!", 1)
- else
- $game_system.se_play($data_system.decision_se)
- $game_party.gain_gold(current_bond.mature_value)
- $game_bank.saving_bonds.delete_at(@own_bond_command.index)
- refresh_windows
- close_bond_selection(@own_bond_display_window, @own_bond_command)
- end
- end
- end
- def updating_ownd
- @current_bond = $game_bank.saving_bonds[@own_bond_command.index]
- refresh_windows
- end
- #--------------------------------------------------------------------------
- # * refresh_help_window
- #--------------------------------------------------------------------------
- def refresh_help_window
- if !@command_window.active
- case @command_window.method
- when :deposit, :withdraw
- text = "Menu Selection\n" +
- "● Press Left / Right: ±1\n" +
- "● Hold SHIFT: ±10\n" +
- "● Hold CTRL: ±100\n" +
- "● Hold ALT: ±1000\n" +
- "● X / Enter: Confirm\n" +
- "● B / Esc : Go Back"
- when :purchase, :mature
- text = "Menu Selection\n" +
- "● X / Enter: Select\n" +
- "● B / Esc : Go Back"
- else text = ""
- end
- else text = ""
- end
- @bankhelp_window.set_text(text)
- end
- def update_help(description)
- help_text = description[@command_window.method]
- @help_window.set_text(help_text) unless help_text.nil?
- end
- #--------------------------------------------------------------------------
- # * Refresh Windows
- #--------------------------------------------------------------------------
- def refresh_windows
- @activity_summary.refresh
- @av_bond_display_window.refresh(@current_bond, @bond_bought)
- @own_bond_display_window.refresh(@current_bond, @bond_bought)
- @bank_number_window.set(@command_window.method)
- @own_bond_command.refresh(create_owned_list)
- end
- #--------------------------------------------------------------------------
- # * Misc
- #--------------------------------------------------------------------------
- def amount
- return @bank_number_window.amount
- end
- def close_bond_selection(window, command)
- @command_window.activate.show
- @dummy_window.show
- window.hide
- command.hide.deactivate
- update_help(BANK_DESCRIPTION)
- @bankhelp_window.set_text(main_help)
- end
- def main_help
- text = "Menu Selection\n" +
- "● B / Esc: Return to Main\n" +
- "● X / Enter: Select"
- return text
- end
- def fitting_height(line_number)
- (line_number * line_height) + (standard_padding * 2)
- end
- def line_height; return 32; end
- def standard_padding; return 16; end
- def visible_line_number; return [[@command_window.height, 6].min, 1].max; end
- end
Advertisement
Add Comment
Please, Sign In to add comment