Bigace360

Bank System

Mar 24th, 2013
1,112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 40.04 KB | None | 0 0
  1. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  2. # ■ Bank System [RMXP]                                        
  3. # ■ Author: Bigace360  
  4. # ■ Type: Custom Scene
  5. # ■ Version: 1.00
  6. # ■ Date: March 24, 2013
  7. # ■ Blog: http://bigaceworld.wordpress.com/
  8. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  9. #                               VERSION HISTORY                                #
  10. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  11. # 03.24.2013 (v1.00) - Finished Script
  12. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  13. #                                INTRODUCTION                                  #
  14. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  15. # The ACE Banking System allows players to deposit and withdraw money from the
  16. # bank like in real life. As your money sits in the bank, the player can
  17. # accumulate interest over time, increasing the amount of money in the bank.
  18. # Savings bonds can also be purchase at the bank, to increase the players cash
  19. # flow as well.
  20. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  21. #                                  FEATURES                                    #
  22. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  23. # ▼ Interest Rates
  24. #   ● Let's your Account grow by a certain percent every gametime hour
  25. #    (But it updates every frame)
  26. # ▼ Savings Bonds
  27. #   ● Lets You purchase bonds that mature over time (in hours) and give you a
  28. #     direct interest amount from the bond
  29. #
  30. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  31. #                                INSTRUCTIONS                                  #
  32. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  33. # To install this script, open up your script editor and copy/paste this script
  34. # to an open slot below Scene_Debug, but above Main. Remember to save.
  35. #
  36. # --------------------------------------
  37. # ▼ Creating Savings Bonds
  38. # --------------------------------------
  39. # ● To Create you own Savings Bonds, go to the module and scroll down to
  40. #   Section IV and then read the instructions.
  41. #
  42. # --------------------------------------
  43. # ▼ Creating Dynamic Banks
  44. # --------------------------------------
  45. # ● You can easily make every bank in your game different, and have it's own
  46. #   interest rates & available bonds.
  47. #
  48. # ● First, the template to call a bank is:
  49. #   call_bank(interest_rate, bonds)
  50. #
  51. # ● To change the interest rate for the bank, just change interest_rate to the
  52. #   interger amount of the interest. (5 = 5%) To leave the interest rate alone,
  53. #   set this value to 0. It will use the last interest rate used.
  54. # ● For the savings bonds, bonds will be the bond ID used from the SAVINGS_BONDS
  55. #   hash in the script's module. Any items placed within the array assigned to
  56. #   the bond ID will be sold as savings bond.
  57. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  58. #                                  SECTIONS                                    #
  59. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  60. #  ■ Game_Objects
  61. # ** ACE Module
  62. # ** Object
  63. # ** Bitmap
  64. # ** Numeric
  65. # ** Game_BankSystem
  66. # ** Interpreter
  67. #
  68. #  ■ Windows
  69. # ** Window_Base
  70. # ** Window_Selectable
  71. # ** Window_CommandBase
  72. # ** Window_BankHelp
  73. # ** Window_BankCommand
  74. # ** Window_BondCommand
  75. # ** Window_BankSummary
  76. # ** Window_BankNumber
  77. # ** Window_Bond
  78. #
  79. #  ■ Scenes
  80. # ** Scene_Base
  81. # ** Scene_Title
  82. # ** Scene_Bank
  83. #
  84. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  85. #
  86. # Credits/Thanks:
  87. #   - Bigace360, for the script.
  88. #
  89. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  90. #                     Script Conflicts and Compatability                       #
  91. #=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
  92. # ● Compatibility
  93. #   Requires the script 'Scene_Base' v1.4 or higher
  94. #
  95. # ● Alias methods
  96. #   class Window_Base < Window
  97. #     def initialize(*args, &block)
  98. #
  99. #   class Scene_Title
  100. #     def command_new_game(*args)
  101. #
  102. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  103. #
  104. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  105. # ■ Module ACE::CORE
  106. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  107. module ACE
  108.     module CORE
  109.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  110.         # ◆ Section I. Bank Configurations ◆
  111.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  112.         # These are the general settings that govern the Bank settings.
  113.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  114.         BANK_CONFIG ={
  115.             # :bank_win - [Opacity, Window Border?]. (Opacity Limit: 0~255)
  116.             :bank_win => [200, false],
  117.             # :background - Background images
  118.             :background => 'back04',
  119.             # :fx - Back FX (0=Moving/ 1=Still/ 2=Map)  
  120.             :fx => 0,
  121.             # :tran_time - Transition Time.
  122.             :tran_time => 10,
  123.             # :tran_type - Transition Type (Name)
  124.             :tran_type => '004-Blind04',
  125.             # :layout - Image filename for window layout, must be in the Menu folder
  126.             :layout => '',
  127.         } # Do not remove this.
  128.        
  129.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  130.         # ◆ Section II. Main Command Settings ◆
  131.         # -------------------------------------------------------------------------
  132.         # This array adjusts what options appear in the initial item command window
  133.         # before the items are split into separate categories. Add commands, remove
  134.         # commands, or rearrange them. Here's a list of which does what:
  135.         #
  136.         # -------------------------------------------------------------------------
  137.         # :command         Description
  138.         # -------------------------------------------------------------------------
  139.         # :deposit         Desposit Money Into Your Account
  140.         # :withdraw        Withdraw Money From your Account
  141.         # :purchase        Purchase a Savings Bond
  142.         # :mature          Take Out Mature Savings Bond
  143.         # :exit            Exit Bank
  144.         #
  145.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=     
  146.         # This array arranges the order of which the commands appear in the Item
  147.         # Command window in the Item Scene.
  148.         BANK_COMMANDS =[
  149.             [:deposit,          "Deposit"],
  150.             [:withdraw,        "Withdraw"],
  151.             [:purchase,   "Purchase Bond"],
  152.             [:mature,   "Get Mature Bond"],
  153.             [:exit,                "Exit"],
  154.         ] # Do not remove this.
  155.        
  156.         BANK_DESCRIPTION ={
  157.             :deposit =>  "Desposit Money Into Your Account",
  158.             :withdraw => "Withdraw Money From your Account",
  159.             :purchase => "Purchase a Savings Bond",
  160.             :mature =>   "Take Out Mature Savings Bond",
  161.             :exit =>     "Exit Bank",
  162.         } # Do not remove this.
  163.        
  164.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  165.         # ◆ Section III. Bank Status Settings ◆
  166.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  167.         # The item status window displays information about the players bank
  168.         # statement. Adjust the settings below to change the text that appears in
  169.         # the status window.
  170.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  171.         BANK_VOCAB ={
  172.             :summary =>{
  173.                 :header =>   "Activity Summary", # Header Text
  174.                 :balance =>  "Account Balance:", # Account Balance Text
  175.                 :owned =>    "Bonds Owned:",     # Number of Savings Bond's Text
  176.                 :value =>    "Bonds Value:",     # Value of Savings Bond's Text
  177.                 :interest => "Interest Rate:",   # Current Interest Rate Text
  178.             }, # Do not remove this.
  179.             :bonds => {
  180.                 :cost =>     "Bond Cost:",     # Bond Cost Text
  181.                 :value =>    "Mature Value:",  # Bond Mature Value Text
  182.                 :interest => "Interest Rate:", # Bond Interest Rate Text
  183.                 :maturity => "Maturity Time:", # Length until Maturity Text
  184.                 :bought =>   "Time Bought:",   # Time Bought Text
  185.                 :finished => "Time Finished:"  # Time Finished Text
  186.             } # Do not remove this.
  187.         } # Do not remove this.
  188.        
  189.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  190.         # ◆ Section IV. Bank Savings Bond Settings ◆
  191.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  192.         # This section is for creating your own Savings Bonds. Go just right BELOW
  193.         # the Savings_Bond Class to customize your bank's savings bonds. PLEASE
  194.         # DO NOT TOUCH THE Savings_Bond Class UNLESS YOU KNOW WHAT YOUR DOING!!!
  195.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  196.         #
  197.         #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  198.         # ■ Savings_Bond [DO NOT TOUCH THIS CLASS] END Configuration
  199.         #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  200.         class Savings_Bond
  201.             attr_accessor(:name, :cost, :interest_rate, :length, :time_bought,
  202.                 :time_finished, :mature_value)
  203.             def initialize(name, cost, interest_rate, length)
  204.                 @name = name
  205.                 @cost = cost
  206.                 @interest_rate = interest_rate
  207.                 @length = length
  208.                 @mature_value = (@cost * (1+ @interest_rate / 100.0)).to_i
  209.             end
  210.             # DO NOT TOUCH THIS CLASS
  211.             def set_times
  212.                 @time_bought = Graphics.frame_count / Graphics.frame_rate
  213.                 @time_finished = @time_bought + @length * 3600
  214.             end
  215.             # DO NOT TOUCH THIS CLASS
  216.             def return_time(time)
  217.                 hours   = time / 60 / 60
  218.                 minutes = time / 60 % 60
  219.                 seconds = time % 60
  220.                 return sprintf("%02d:%02d:%02d", hours, minutes, seconds)
  221.             end
  222.         end
  223.        
  224.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  225.         # START Configurations
  226.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  227.         # Here you can configure your own savings bonds
  228.         #
  229.         #     bond_id => Savings_Bond.new("name", cost, interest_rate, length),
  230.         #
  231.         #     name            : Savings Bond Name
  232.         #     cost            : Savings Bond Cost
  233.         #     interest_rate   : Savings Bond Interest Rate (In Percent)
  234.         #     length          : Length of Hours until Mature
  235.         #-------------------------------------------------------------------------
  236.         BANK_BOND_LIST ={
  237.             1 => Savings_Bond.new("CD-7", 100, 7.5, 7),
  238.             2 => Savings_Bond.new("CD-14", 500, 15, 14),
  239.             3 => Savings_Bond.new("CD-28", 2000, 20, 28),
  240.             4 => Savings_Bond.new("CD-1", 150, 2, 3),
  241.             5 => Savings_Bond.new("CD-2", 350, 3, 0),
  242.         }  
  243.        
  244.     # This hash adjusts the savings bond's sold in each of the bank ID's. Insert
  245.         # the savings bond you want sold inside of the arrays with the bank ID as
  246.         # the hash key. You can use number ranges to add common events quicker.
  247.         SAVINGS_BONDS ={
  248.             #ID => [BANK_BOND_LIST ID's],
  249.             0 => [], # Do not delete this line.
  250.             1 => [1..3, 5],
  251.             2 => [4],
  252.         }
  253.        
  254.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  255.         # END Configuration
  256.         #===========================================================================
  257.         # ▼ Warning
  258.         # Editting anything past this point may potentially result in causing
  259.         # computer damage, incontinence, explosion of user's head, coma, death,
  260.         # and/or halitosis so edit at your own risk.
  261.         #===========================================================================
  262.        
  263.         module_function
  264.         #--------------------------------------------------------------------------
  265.         # convert_integer_array
  266.         #--------------------------------------------------------------------------
  267.         def convert_integer_array(array)
  268.             result = []
  269.             array.each do |i|
  270.                 case i
  271.                 when Range then result |= i.to_a
  272.                 when Integer then result |= [i]
  273.                 end
  274.             end
  275.             return result
  276.         end    
  277.         #--------------------------------------------------------------------------
  278.         # full_convert_hash
  279.         #--------------------------------------------------------------------------
  280.         def full_convert_hash(hash)
  281.             result = {}
  282.             hash.each {|key| result[key[0]] = convert_integer_array(key[1])}
  283.             return result
  284.         end    
  285.         SAVINGS_BONDS = full_convert_hash(SAVINGS_BONDS)
  286.     end
  287. end
  288. #
  289. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  290. #                         ▼ Import to Global Hash ▼                            #
  291. ($ace_script ||= {})["Bank System"] = true
  292. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  293.  
  294. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  295. # ■ Bitmap
  296. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  297. class Bitmap
  298.     def clear_rect(*args)
  299.         color = Color.new(0, 0, 0, 0)
  300.         args << color
  301.         fill_rect(*args)
  302.     end
  303. end
  304.  
  305. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  306. # ■ Numeric
  307. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  308. class Numeric
  309.     def group; return self.to_s; end unless $ace_script[:ace_warrior_module]
  310. end
  311.  
  312. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  313. # ■ Game_BankSystem
  314. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  315. class Game_BankSystem
  316.   attr_accessor(:account_balance, :interest_rate, :saving_bonds)
  317.   def initialize
  318.     @account_balance = 0
  319.     @interest_rate = 1
  320.     @saving_bonds = []
  321.     @last_interest_time = 0
  322.   end
  323.     def interest_time
  324.         (Graphics.frame_count / Graphics.frame_rate - @last_interest_time) / 3600.0
  325.     end
  326.     def interest_amount
  327.         (@account_balance * @interest_rate / 100.0 * interest_time).to_i
  328.     end
  329.   def update
  330.     # Updates Deposited Amount
  331.     if interest_amount > 0
  332.       @last_interest_time = Graphics.frame_count / Graphics.frame_rate
  333.       @account_balance += interest_amount
  334.       # Refreshes Data Windows
  335.       $scene.refresh_windows
  336.     end
  337.   end
  338.   def deposit(amount)
  339.     $game_party.lose_gold(amount)
  340.     @account_balance += amount
  341.   end
  342.   def withdraw(amount)
  343.     @account_balance -= amount
  344.     $game_party.gain_gold(amount)
  345.   end
  346.   def add_bond(bond)
  347.     @saving_bonds << bond
  348.     @saving_bonds.sort! {|a, b| a.name <=> b.name}
  349.   end
  350. end
  351.  
  352. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  353. # ■ Window_Base
  354. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  355. class Window_Base < Window
  356.     alias :ace_bankbase_initi :initialize unless $@
  357.     def initialize(*args, &block)
  358.         ace_bankbase_initi(*args, &block)
  359.         bank_opacity? if $scene.is_a?(Scene_Bank)
  360.     end
  361.     def bank_opacity?
  362.         bank_opacity = ACE::CORE::BANK_CONFIG[:bank_win]
  363.         self.back_opacity = bank_opacity[0]
  364.         self.opacity = bank_opacity[0] if bank_opacity[1]
  365.     end
  366.     def fitting_height(line_number)
  367.         (line_number * 32) + (standard_padding * 2)
  368.     end
  369.     def standard_padding; return 16; end   
  370.     def translucent_alpha; return 160; end
  371.     def line_height; return 32; end
  372.     def draw_icon(icon_index, x, y, enabled = true)
  373.         bitmap = RPG::Cache.icon(icon_index)
  374.         self.contents.blt(x, y, bitmap, Rect.new(0, 0, 24, 24),
  375.             enabled ? 255 : translucent_alpha)
  376.     end
  377.     def show; self.visible = true;  self; end
  378.     def hide; self.visible = false; self; end
  379.     def activate;   self.active = true;  self; end
  380.     def deactivate; self.active = false; self; end
  381.     def draw_horz_line(y, contents_width, x=0)
  382.         line_y = y + 24 / 2 - 1
  383.         contents.fill_rect(x, line_y, contents_width, 1, line_color)
  384.     end
  385.     def line_color
  386.         color = normal_color
  387.         color.alpha = 192
  388.         return color
  389.     end
  390. end
  391.  
  392. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  393. # ■ Window_Selectable
  394. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  395. class Window_Selectable < Window_Base
  396.   attr_reader   :item_max                 # item count
  397.     def select(index); self.index = index if index; end
  398.     def unselect;      self.index = -1;             end
  399.     def col_max(n);    return @column_max = n;      end
  400.     def item_rect(index)
  401.         rect = Rect.new(0, 0, 0, 32)
  402.         rect.width = self.width / @column_max - 32
  403.         rect.x = index % @column_max * (rect.width + 32)
  404.         rect.y = index / @column_max * 32
  405.         return rect
  406.     end
  407.   def item_rect_for_text(index)
  408.     rect = item_rect(index)
  409.     rect.x += 4; rect.width -= 8
  410.     rect
  411.   end
  412. end
  413.  
  414. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  415. # ■ Window_CommandBase
  416. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  417. class Window_CommandBase < Window_Selectable
  418.     include ACE::CORE
  419.     attr_reader :commands # command
  420.     def initialize(array, width = 160)
  421.         @data = array[1]
  422.         commands = array[0]
  423.         super(0, 0, width, commands.size * 32 + 32)
  424.         @item_max = commands.size; @commands = commands
  425.         self.contents = Bitmap.new(width - 32, @item_max * 32)
  426.         refresh
  427.         select(0)
  428.     end
  429.     def method; return @data[self.index]; end
  430.     def alignment
  431.         return Menu.main_menu_align if $ace_script[:ace_main_menu]
  432.         return 0
  433.     end
  434.     def refresh
  435.         self.contents = Bitmap.new(width - 32, @item_max * 32) if @item_max > 0
  436.         @item_max.times {|i| draw_item(i)} if @item_max > 0
  437.     end
  438.     def draw_item(index, enabled = true)   
  439.     end
  440. end
  441.  
  442. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  443. # ■ Window_BankHelp
  444. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  445. class Window_BankHelp < Window_Help
  446.     alias :multiline_set_text :set_text unless $@
  447.     def set_text(text, align = 0)
  448.         return unless text != nil
  449.         lines = text.split("\n")
  450.         if lines.size <= 1
  451.             multiline_set_text(text, align)
  452.         elsif @text != text || @align != align
  453.             self.contents.dispose
  454.             self.contents = Bitmap.new(self.width - 32, lines.size * 20)
  455.             lines.each_index do |i|
  456.                 if contents.text_size(lines[i]).width > contents.width-32
  457.                     contents.font.size = 14
  458.                 end
  459.                 contents.draw_text(0, i*20, contents.width, 20, lines[i], align)
  460.             end
  461.             @text = text; @align = align; @actor = nil
  462.         end
  463.         show
  464.     end
  465. end
  466.  
  467. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  468. # ■ Window_BankCommand
  469. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  470. class Window_BankCommand < Window_CommandBase
  471.     def initialize(array)
  472.         super(array, 196)
  473.     end
  474.     def draw_item(index, enabled = true)
  475.         rect = item_rect_for_text(index)
  476.         contents.clear_rect(rect)
  477.         contents.font.color = normal_color
  478.         contents.font.color.alpha = enabled ? 255 : translucent_alpha
  479.         contents.draw_text(rect, @commands[index], alignment)
  480.     end
  481. end
  482.  
  483. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  484. # ■ Window_BondCommand
  485. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  486. class Window_BondCommand < Window_Selectable
  487.   def initialize(commands)
  488.     super(0, 0, 196, commands.size * 32 + 32)
  489.     @item_max = commands.size; @commands = commands
  490.     refresh
  491.     select(0)
  492.   end  
  493.     def alignment
  494.         return Menu.main_menu_align if $ace_script[:ace_main_menu]
  495.         return 0
  496.     end
  497.     def refresh(commands = @commands)
  498.         @commands = commands
  499.         @item_max = commands.size
  500.         self.contents.dispose unless self.contents.nil?
  501.         self.contents = nil unless self.contents.nil?
  502.         self.contents = Bitmap.new(width - 32, @item_max * 32)
  503.         @item_max.times {|i| draw_item(i)}
  504.     end
  505.   def draw_item(index)
  506.         rect = Rect.new(4, 32 * index, contents.width - 8, 32)
  507.     contents.font.color = normal_color
  508.     contents.draw_text(rect, @commands[index], alignment)
  509.   end  
  510. end
  511.  
  512. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  513. # ■ Window_BankSummary
  514. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  515. class Window_BankSummary < Window_Base
  516.   def initialize
  517.     super(0, 0, 444, fitting_height(5))
  518.     self.contents = Bitmap.new(width - 32, height - 32)
  519.     refresh
  520.   end
  521.     def summary(sym)
  522.         ACE::CORE::BANK_VOCAB[:summary][sym]
  523.     end
  524.   def refresh
  525.     contents.clear
  526.         reset_font_settings if $ace_script[:ace_warrior_module]
  527.         summary_header
  528.         2.times {|i| draw_horz_line(9+(i*58), contents.width)}
  529.         summary_gold
  530.         summary_balance
  531.         summary_bonds_owned
  532.         summary_bonds_value
  533.         summary_interest
  534.   end
  535.     def summary_header
  536.         contents.font.color = normal_color
  537.         contents.draw_text(0, 0, contents.width, 24, summary(:header), 1)
  538.     end
  539.     def summary_gold
  540.         contents.font.color = system_color
  541.         text = "Current #{$data_system.words.gold}:"
  542.         contents.draw_text(4, 32, contents.width, 24, text)
  543.         contents.font.color = normal_color
  544.         contents.draw_text(-4, 32, contents.width, 24, $game_party.gold.group, 2)
  545.     end
  546.     def summary_balance
  547.         contents.font.color = system_color
  548.         contents.draw_text(4, 56, contents.width, 24, summary(:balance))
  549.         contents.font.color = normal_color
  550.         balance = $game_bank.account_balance.group
  551.         contents.draw_text(-4, 56, contents.width, 24, balance, 2)     
  552.     end
  553.     def summary_bonds_owned
  554.         contents.font.color = system_color
  555.         contents.draw_text(4, 90, contents.width, 24, summary(:owned))
  556.         contents.font.color = normal_color
  557.         owned = $game_bank.saving_bonds.size.group
  558.         contents.draw_text(-4, 90, contents.width, 24, owned, 2)
  559.     end
  560.     def summary_bonds_value
  561.         value = 0
  562.         $game_bank.saving_bonds.each {|x| value += x.mature_value}
  563.         contents.font.color = system_color
  564.         contents.draw_text(4, 114, contents.width, 24, summary(:value))
  565.         contents.font.color = normal_color
  566.         contents.draw_text(-4, 114, contents.width, 24, value.group, 2)
  567.     end
  568.     def summary_interest
  569.         contents.font.color = system_color
  570.         contents.draw_text(4, 138, contents.width, 24, summary(:interest))
  571.         contents.font.color = normal_color
  572.         interest = "#{$game_bank.interest_rate}%"
  573.         contents.draw_text(-4, 138, contents.width, 24, interest, 2)
  574.     end
  575. end
  576.  
  577. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  578. # ■ Window_BankNumber
  579. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  580. class Window_BankNumber < Window_Selectable
  581.     attr_reader :amount # money entered
  582.     def initialize(dummy)
  583.         super(dummy.x, dummy.y, dummy.width, dummy.height)
  584.         self.contents = Bitmap.new(width - 32, height - 32)
  585.         @amount = 0
  586.     end
  587.     def set(type)
  588.         @type = type
  589.         @amount = 0
  590.         refresh
  591.     end
  592.     def refresh
  593.         contents.clear
  594.         reset_font_settings if $ace_script[:ace_warrior_module]
  595.         draw_header
  596.         draw_balance
  597.         draw_transaction
  598.         draw_horz_line(88, contents.width)
  599.         draw_party_gold
  600.         draw_account_balance
  601.     end
  602.     def name
  603.         name = @type == :deposit ? "Deposit" : "Withdraw"
  604.         return name
  605.     end
  606.     def gold
  607.         money = $game_party.gold
  608.         money += @type == :deposit ? -@amount : @amount
  609.         return money
  610.     end
  611.     def account_balance
  612.         money = $game_bank.account_balance
  613.         money += @type == :deposit ? @amount : -@amount
  614.         return money
  615.     end
  616.     def max
  617.         max = @type == :deposit ? $game_party.gold : $game_bank.account_balance
  618.         return max
  619.     end
  620.     def draw_header
  621.         contents.font.color = normal_color
  622.         contents.draw_text(0, 0, contents.width, 24, "Amount to #{name}", 1)
  623.         draw_horz_line(10, contents.width/2, contents.width/4)
  624.     end
  625.     def draw_balance
  626.         rect = Rect.new(4, 48, contents.width, 24)
  627.         contents.font.color = system_color
  628.         case @type 
  629.         when :deposit
  630.             contents.draw_text(rect, "Current #{$data_system.words.gold}:")
  631.             contents.font.color = normal_color
  632.             rect.x -= 10
  633.             contents.draw_text(rect, $game_party.gold.group, 2)        
  634.         when :withdraw      
  635.             contents.draw_text(rect, "Account Balance:")
  636.             contents.font.color = normal_color
  637.             rect.x -= 10
  638.             contents.draw_text(rect, $game_bank.account_balance.group, 2)
  639.         end
  640.     end
  641.     def draw_transaction
  642.         rect = Rect.new(4, 72, contents.width, 24)
  643.         contents.font.color = system_color
  644.         contents.draw_text(rect, "#{name} Amount:")
  645.         contents.font.color = normal_color
  646.         rect.x -= 10
  647.         contents.draw_text(rect, "- #{@amount.group}", 2)      
  648.     end
  649.     def draw_party_gold
  650.         rect = Rect.new(4, 112, contents.width, 24)
  651.         contents.font.color = system_color
  652.         contents.draw_text(rect, "#{$data_system.words.gold} After:")
  653.         contents.font.color = normal_color
  654.         rect.x -= 10
  655.         contents.draw_text(rect, gold.group, 2)
  656.     end
  657.     def draw_account_balance
  658.         rect = Rect.new(4, 136, contents.width, 24)
  659.         contents.font.color = system_color
  660.         contents.draw_text(rect, "Balance After:")
  661.         contents.font.color = normal_color
  662.         rect.x -= 10
  663.         contents.draw_text(rect, account_balance.group, 2)
  664.     end
  665.     def update
  666.         super
  667.         return unless self.active
  668.         last_number = @amount
  669.         update_number
  670.         return if @amount == last_number
  671.         $game_system.se_play($data_system.cursor_se)
  672.         refresh
  673.     end
  674.     def update_number
  675.         change_number(1)    if Input.repeat?(Input::RIGHT)
  676.         change_number(-1)   if Input.repeat?(Input::LEFT)
  677.         change_number(max)  if Input.repeat?(Input::R) 
  678.         change_number(-max) if Input.repeat?(Input::L)   
  679.     end
  680.     def change_number(amount)
  681.         amount *= 10   if Input.press?(Input::SHIFT)
  682.         amount *= 100  if Input.press?(Input::CTRL)
  683.         amount *= 1000 if   Input.press?(Input::ALT)
  684.         @amount = [[@amount + amount, max].min, 0].max
  685.     end
  686.   def update_help
  687.     @help_window.set_text("#{name} #{@amount} #{$data_system.words.gold}", 1)
  688.   end
  689. end
  690.  
  691. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  692. # ■ Window_Bond
  693. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  694. class Window_Bond < Window_Base
  695.     def initialize(summary)
  696.         super(summary.x, summary.y, summary.width, summary.height)
  697.         self.contents = Bitmap.new(width - 32, height - 32)
  698.     end
  699.     def bonds(sym)
  700.         ACE::CORE::BANK_VOCAB[:bonds][sym]
  701.     end
  702.     def refresh(bond, bought = false)
  703.         contents.clear
  704.         reset_font_settings if $ace_script[:ace_warrior_module]
  705.         rect = Rect.new(0, 0, contents.width, 24)
  706.         return no_data(rect) if bond.nil?
  707.         bond_header(bond, rect)
  708.         2.times {|i| draw_horz_line(9+(i*89), contents.width)}
  709.         bond_cost(bond, rect)
  710.         bond_mature_value(bond, rect)
  711.         bond_interest_rate(bond, rect)
  712.         bond_time(bond, rect)
  713.         return unless bought # Display only if Purchased CD
  714.         bond_time_bought(bond, rect)
  715.         bond_time_finished(bond, rect)
  716.     end
  717.     def no_data(rect)
  718.         contents.font.color = normal_color; contents.font.size = 24
  719.         contents.draw_text(rect, "[Close]", 1)     
  720.     end
  721.     def bond_header(bond, rect)
  722.         contents.font.color = normal_color
  723.         contents.draw_text(rect, bond.name, 1)
  724.     end
  725.     def bond_cost(bond, rect)
  726.         rect.y += 22
  727.         contents.font.color = system_color
  728.         contents.draw_text(rect, bonds(:cost))
  729.         contents.font.color = normal_color
  730.         contents.draw_text(rect, bond.cost.group, 2)       
  731.     end
  732.     def bond_mature_value(bond, rect)
  733.         rect.y += 22
  734.         contents.font.color = system_color
  735.         contents.draw_text(rect, bonds(:value))
  736.         contents.font.color = normal_color
  737.         contents.draw_text(rect, "#{bond.mature_value}", 2)    
  738.     end
  739.     def bond_interest_rate(bond, rect)
  740.         rect.y += 22
  741.         contents.font.color = system_color
  742.         contents.draw_text(rect, bonds(:interest))
  743.         contents.font.color = normal_color
  744.         contents.draw_text(rect, "#{bond.interest_rate}%", 2)      
  745.     end
  746.     def bond_time(bond, rect)
  747.         rect.y += 22
  748.         contents.font.color = system_color
  749.         contents.draw_text(rect, bonds(:maturity))
  750.         contents.font.color = normal_color
  751.         contents.draw_text(rect, "#{bond.length} Hours", 2)    
  752.     end
  753.     def bond_time_bought(bond, rect)
  754.         rect.y += 24
  755.         contents.font.color = system_color
  756.         contents.draw_text(rect, bonds(:bought))
  757.         contents.font.color = normal_color
  758.         contents.draw_text(rect, bond.return_time(bond.time_bought), 2)    
  759.     end
  760.     def bond_time_finished(bond, rect)
  761.         rect.y += 22
  762.         contents.font.color = system_color
  763.         contents.draw_text(rect, bonds(:finished))
  764.         contents.font.color = normal_color
  765.         contents.draw_text(rect, bond.return_time(bond.time_finished), 2)      
  766.     end
  767. end
  768.  
  769. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  770. # ■ Interpreter
  771. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  772. class Interpreter
  773.     def call_bank(interest_rate = 1, savings_bond = 0)
  774.     return unless $scene.is_a?(Scene_Map)
  775.         bonds = ACE::CORE::SAVINGS_BONDS[savings_bond]
  776.         $scene = Scene_Bank.new(interest_rate, bonds)
  777.     end
  778. end
  779.  
  780. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  781. # ■ Scene_Title
  782. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  783. class Scene_Title
  784.     alias :ace_bank_command_new_game :command_new_game unless $@
  785.   def command_new_game(*args)
  786.     ace_bank_command_new_game(*args)
  787.         $game_bank = Game_BankSystem.new
  788.   end
  789. end
  790.  
  791. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  792. # ■ Scene_Bank
  793. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  794. class Scene_Bank < Scene_Base
  795.     include ACE::CORE
  796.     def initialize(interest_rate = $game_bank.interest_rate, bonds = [])
  797.         $game_bank.interest_rate = interest_rate unless interest_rate == 0
  798.         @bonds = bonds
  799.     end
  800.     def start
  801.         super
  802.         @current_bond = nil
  803.         @bond_bought = false
  804.         create_menu_layout
  805.         create_help_window
  806.         create_command_window
  807.         create_activity_summary_window
  808.         create_dummy_window
  809.         create_banknumber_window
  810.         create_avaliable_bond
  811.         create_owned_bond
  812.     end
  813.     def create_menu_layout
  814.         super
  815.         return if BANK_CONFIG[:layout].empty?
  816.         @menulay.bitmap = RPG::Cache.menu(BANK_CONFIG[:layout])
  817.     end
  818.     def create_help_window
  819.         @help_window = Window_Help.new
  820.         @bankhelp_window = Window_BankHelp.new
  821.         @bankhelp_window.y = @help_window.height + fitting_height(6)
  822.         @bankhelp_window.width = dw = 196
  823.         @bankhelp_window.height = dh = 480 - @bankhelp_window.y
  824.         @bankhelp_window.contents = Bitmap.new(dw - 32, dh - 32)
  825.         @bankhelp_window.contents.clear
  826.     end
  827.     def create_command_window
  828.         @command_window = Window_BankCommand.new(create_command_list)
  829.         @command_window.height = @ch = fitting_height(visible_line_number)
  830.         @command_window.y = @cy = @help_window.height
  831.         @command_window.activate   
  832.         update_help(BANK_DESCRIPTION)
  833.         @bankhelp_window.set_text(main_help)
  834.     end
  835.     def create_command_list
  836.         vocab = []; data = []
  837.         BANK_COMMANDS.each do |command|
  838.             case command[0]
  839.             when :deposit, :withdraw, :purchase, :mature, :exit
  840.             else next
  841.             end
  842.             vocab << command[1]; data << command[0]
  843.         end
  844.         return vocab, data
  845.     end
  846.     def create_activity_summary_window
  847.         @activity_summary = Window_BankSummary.new
  848.         @activity_summary.x = dx = @command_window.width
  849.         @activity_summary.y = @command_window.y
  850.     end
  851.     def create_dummy_window
  852.         dx = @activity_summary.x
  853.         dy = @activity_summary.height + @help_window.height
  854.         dw = @activity_summary.width
  855.         dh = 480 - (@activity_summary.height + @help_window.height)
  856.         @dummy_window = Window_Base.new(dx, dy, dw, dh)
  857.     end
  858.     def create_banknumber_window
  859.         @bank_number_window = Window_BankNumber.new(@dummy_window)
  860.         @bank_number_window.hide.deactivate
  861.         @bank_number_window.help_window = @help_window
  862.     end
  863.     def create_avaliable_bond
  864.         @av_bond_display_window = Window_Bond.new(@dummy_window)
  865.         @av_bond_display_window.hide
  866.         @av_bond_command = Window_BankCommand.new(create_avaliable_list)
  867.         @av_bond_command.height = @ch
  868.         @av_bond_command.y = @cy
  869.         @av_bond_command.deactivate.hide
  870.     end
  871.     def create_avaliable_list
  872.         vocab = []; data = []
  873.         @bonds.each do |x|
  874.             next if BANK_BOND_LIST[x].nil?
  875.             name = BANK_BOND_LIST[x].name
  876.             vocab << name; data << BANK_BOND_LIST[x]
  877.         end
  878.         vocab << "Back"
  879.         return vocab, data
  880.     end
  881.     def create_owned_bond
  882.         @own_bond_display_window = Window_Bond.new(@dummy_window)
  883.         @own_bond_display_window.hide
  884.         @own_bond_command = Window_BondCommand.new(create_owned_list)
  885.         @own_bond_command.height = @ch
  886.         @own_bond_command.y = @cy
  887.         @own_bond_command.deactivate.hide      
  888.     end
  889.     def create_owned_list
  890.         vocab = []
  891.         $game_bank.saving_bonds.each {|x| vocab << x.name}
  892.         vocab << "Back"
  893.         return vocab
  894.     end
  895.     def perform_transition
  896.         super; BANK_CONFIG[:fx] == 2 ? map_back : bank_back
  897.     end
  898.     def map_back
  899.         @spriteset = Spriteset_Map.new
  900.         Graphics.transition(transition_speed)  
  901.     end
  902.     def bank_back
  903.         @back = Plane.new
  904.         unless BANK_CONFIG[:background].empty?
  905.             if $ace_script[:ace_main_menu]
  906.                 @back.bitmap = RPG::Cache.menu("Background/#{BANK_CONFIG[:background]}")
  907.             else @back.bitmap = RPG::Cache.picture(BANK_CONFIG[:background])
  908.             end
  909.         end
  910.         @back.z = 10       
  911.         Graphics.transition(transition_speed,
  912.             "Graphics/Transitions/#{BANK_CONFIG[:tran_type]}")     
  913.     end
  914.     def transition_speed
  915.         return BANK_CONFIG[:tran_time]
  916.     end
  917.     def terminate
  918.         super; BANK_CONFIG[:fx] == 2 ? @spriteset.dispose : @back.dispose
  919.     end
  920.     def update
  921.         super
  922.         @spriteset.update if BANK_CONFIG[:fx] == 2
  923.         update_moving_windows?
  924.         if @command_window.active;        update_command_selection
  925.         elsif @bank_number_window.active; update_account_window
  926.         elsif @own_bond_command.active;   update_owned_bond_selection
  927.         elsif @av_bond_command.active;    update_avaliable_bond_selection
  928.         end
  929.     end
  930.     def update_moving_windows?
  931.         @back.ox += 1 if BANK_CONFIG[:fx] == 0
  932.         @back.oy += 1 if BANK_CONFIG[:fx] == 0     
  933.     end    
  934.     #--------------------------------------------------------------------------
  935.     # * update_command_selection
  936.     #--------------------------------------------------------------------------
  937.     def update_command_selection
  938.         if @last_status_index != @command_window.index
  939.             @last_status_index = @command_window.index
  940.             update_help(BANK_DESCRIPTION)
  941.         end
  942.         exit_command if Input.trigger?(Input::B)
  943.         view_command if Input.trigger?(Input::C)
  944.     end
  945.     def exit_command
  946.         $game_system.se_play($data_system.cancel_se)
  947.         $scene = Scene_Map.new
  948.     end
  949.     def view_command
  950.         case @command_window.method
  951.         when :deposit, :withdraw then command_account
  952.         when :purchase then command_purchase
  953.         when :mature   then command_mature
  954.         when :exit     then exit_command
  955.         end
  956.     end
  957.     def command_account
  958.         $game_system.se_play($data_system.decision_se)
  959.         @command_window.deactivate
  960.         @dummy_window.hide
  961.         @bank_number_window.set(@command_window.method)
  962.         @bank_number_window.show.activate
  963.         refresh_windows
  964.         refresh_help_window
  965.     end
  966.     def command_purchase
  967.         $game_system.se_play($data_system.decision_se)
  968.         @current_bond = @av_bond_command.method
  969.         @bond_bought = false
  970.         @command_window.deactivate.hide
  971.         @dummy_window.hide
  972.         refresh_windows
  973.         @av_bond_display_window.show
  974.         @av_bond_command.show.activate
  975.     end
  976.     def command_mature
  977.         $game_system.se_play($data_system.decision_se)
  978.         @current_bond = $game_bank.saving_bonds[@own_bond_command.index]
  979.         @bond_bought = true
  980.         @command_window.deactivate.hide
  981.         @dummy_window.hide
  982.         refresh_windows
  983.         @own_bond_display_window.show
  984.         @own_bond_command.show.activate
  985.     end
  986.     #--------------------------------------------------------------------------
  987.     # * update_owned_bond_selection
  988.     #--------------------------------------------------------------------------
  989.     def update_account_window
  990.         exit_account if Input.trigger?(Input::B)
  991.         open_account if Input.trigger?(Input::C)
  992.     end
  993.     def exit_account
  994.         $game_system.se_play($data_system.cancel_se)
  995.         close_transaction_window
  996.     end
  997.     def open_account
  998.         $game_system.se_play($data_system.shop_se)
  999.         case @command_window.method
  1000.         when :deposit  then $game_bank.deposit(amount)
  1001.         when :withdraw then $game_bank.withdraw(amount)
  1002.         end
  1003.         refresh_windows
  1004.         close_transaction_window
  1005.     end
  1006.     def close_transaction_window
  1007.         @command_window.activate.show
  1008.         @dummy_window.show
  1009.         @bank_number_window.hide.deactivate    
  1010.         update_help(BANK_DESCRIPTION)
  1011.         @bankhelp_window.set_text(main_help)
  1012.     end
  1013.     #--------------------------------------------------------------------------
  1014.     # * update_avaliable_bond_selection
  1015.     #--------------------------------------------------------------------------
  1016.     def update_avaliable_bond_selection
  1017.         get_bond_exit if Input.trigger?(Input::B)
  1018.         get_bond_open if Input.trigger?(Input::C)  
  1019.         updating_aval if Input.trigger?(Input::UP) || Input.trigger?(Input::DOWN)
  1020.     end
  1021.     def get_bond_exit
  1022.         $game_system.se_play($data_system.cancel_se)
  1023.         close_bond_selection(@av_bond_display_window, @av_bond_command)
  1024.     end
  1025.     def get_bond_open
  1026.         if @av_bond_command.index == @bonds.size
  1027.             $game_system.se_play($data_system.cancel_se)
  1028.             close_bond_selection(@av_bond_display_window, @av_bond_command)
  1029.         else
  1030.             current_bond = @av_bond_command.method.dup
  1031.             if current_bond.cost > $game_party.gold
  1032.                 $game_system.se_play($data_system.buzzer_se)
  1033.             else           
  1034.                 $game_system.se_play($data_system.decision_se)
  1035.                 $game_party.lose_gold(current_bond.cost)
  1036.                 current_bond.set_times
  1037.                 $game_bank.add_bond(current_bond)
  1038.                 refresh_windows
  1039.                 close_bond_selection(@av_bond_display_window, @av_bond_command)
  1040.             end
  1041.         end
  1042.     end
  1043.     def updating_aval
  1044.         @current_bond = @av_bond_command.method
  1045.         refresh_windows    
  1046.     end
  1047.     #--------------------------------------------------------------------------
  1048.     # * update_owned_bond_selection
  1049.     #--------------------------------------------------------------------------
  1050.     def update_owned_bond_selection
  1051.         buy_bond_exit if Input.trigger?(Input::B)
  1052.         buy_bond_open if Input.trigger?(Input::C)  
  1053.         updating_ownd if Input.trigger?(Input::UP) || Input.trigger?(Input::DOWN)
  1054.     end
  1055.     def buy_bond_exit
  1056.         $game_system.se_play($data_system.cancel_se)
  1057.         close_bond_selection(@own_bond_display_window, @own_bond_command)
  1058.     end
  1059.     def buy_bond_open
  1060.         if @own_bond_command.index == $game_bank.saving_bonds.size
  1061.             $game_system.se_play($data_system.cancel_se)
  1062.             close_bond_selection(@own_bond_display_window, @own_bond_command)
  1063.         else
  1064.             current_bond = $game_bank.saving_bonds[@own_bond_command.index]
  1065.             if current_bond.time_finished > Graphics.frame_count / Graphics.frame_rate
  1066.                 $game_system.se_play($data_system.buzzer_se)
  1067.                 @help_window.set_text("Savings Bond Not Mature Yet!", 1)
  1068.             else
  1069.                 $game_system.se_play($data_system.decision_se)
  1070.                 $game_party.gain_gold(current_bond.mature_value)
  1071.                 $game_bank.saving_bonds.delete_at(@own_bond_command.index)
  1072.                 refresh_windows
  1073.                 close_bond_selection(@own_bond_display_window, @own_bond_command)
  1074.             end
  1075.         end
  1076.     end
  1077.     def updating_ownd
  1078.         @current_bond = $game_bank.saving_bonds[@own_bond_command.index]
  1079.         refresh_windows    
  1080.     end
  1081.     #--------------------------------------------------------------------------
  1082.     # * refresh_help_window
  1083.     #--------------------------------------------------------------------------
  1084.     def refresh_help_window
  1085.         if !@command_window.active
  1086.             case @command_window.method
  1087.             when :deposit, :withdraw
  1088.                 text = "Menu Selection\n" +
  1089.                 "● Press Left / Right: ±1\n" +
  1090.                 "● Hold SHIFT: ±10\n" +
  1091.                 "● Hold CTRL: ±100\n" +
  1092.                 "● Hold ALT: ±1000\n" +
  1093.                 "● X / Enter: Confirm\n" +
  1094.                 "● B / Esc : Go Back"
  1095.             when :purchase, :mature
  1096.                 text = "Menu Selection\n" +
  1097.                 "● X / Enter: Select\n" +
  1098.                 "● B / Esc : Go Back"
  1099.             else text  = ""
  1100.             end
  1101.         else text = ""
  1102.         end
  1103.         @bankhelp_window.set_text(text)
  1104.     end
  1105.     def update_help(description)
  1106.         help_text = description[@command_window.method]
  1107.         @help_window.set_text(help_text) unless help_text.nil?
  1108.     end
  1109.     #--------------------------------------------------------------------------
  1110.     # * Refresh Windows
  1111.     #--------------------------------------------------------------------------
  1112.     def refresh_windows
  1113.         @activity_summary.refresh
  1114.         @av_bond_display_window.refresh(@current_bond, @bond_bought)
  1115.         @own_bond_display_window.refresh(@current_bond, @bond_bought)
  1116.         @bank_number_window.set(@command_window.method)
  1117.         @own_bond_command.refresh(create_owned_list)
  1118.     end
  1119.     #--------------------------------------------------------------------------
  1120.     # * Misc
  1121.     #--------------------------------------------------------------------------
  1122.     def amount
  1123.         return @bank_number_window.amount
  1124.     end
  1125.     def close_bond_selection(window, command)
  1126.         @command_window.activate.show
  1127.         @dummy_window.show
  1128.         window.hide
  1129.         command.hide.deactivate
  1130.         update_help(BANK_DESCRIPTION)
  1131.         @bankhelp_window.set_text(main_help)       
  1132.     end
  1133.     def main_help
  1134.         text = "Menu Selection\n" +
  1135.         "● B / Esc: Return to Main\n" +
  1136.         "● X / Enter: Select"
  1137.         return text
  1138.     end
  1139.     def fitting_height(line_number)
  1140.         (line_number * line_height) + (standard_padding * 2)
  1141.     end
  1142.     def line_height; return 32; end
  1143.     def standard_padding; return 16; end   
  1144.     def visible_line_number; return [[@command_window.height, 6].min, 1].max; end
  1145. end
Advertisement
Add Comment
Please, Sign In to add comment