TheoAllen

AMA - Automatic Price

Mar 21st, 2013
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.43 KB | None | 0 0
  1. # =======================================
  2. # ALUMNEA MAGIC ACADEMY - Automatic Price
  3. # =======================================
  4. =begin
  5.  
  6.   Script ini dibuat karena gw males masukin price satu2 ke database
  7.   Karena ga mau repot, jadinya ya gw bikin aja script yg masukin price otomatis
  8.   berdasar rumus :v
  9.  
  10.   Script ini comotable dan kompatible dengan semua script :v
  11.  
  12. =end
  13. module AMA
  14.   module PRICE
  15.    
  16.     # Semua harga masuk sini
  17.     # misal 0 => 900 artinya tiap parameter nambah 1, harganya nambah 900
  18.     # kalo nambah 3 berarti 900*3
  19.     HASH = {
  20.    
  21.     0 => 900,   # MHP
  22.     1 => 400,   # MMP
  23.     2 => 1000,  # ATK
  24.     3 => 400,   # DEF
  25.     4 => 900,   # MAT
  26.     5 => 400,   # MDF
  27.     6 => 300,   # AGI
  28.     7 => 100,   # LUK
  29.    
  30.     }
  31.    
  32.   end
  33. end
  34.  
  35. module DataManager
  36.  
  37.   class << self
  38.     alias ama_price_db load_database
  39.   end
  40.  
  41.   def self.load_database
  42.     ama_price_db
  43.     automatic_prices
  44.   end
  45.  
  46.   def self.automatic_prices
  47.     groups = [$data_armors, $data_weapons]
  48.     for group in groups
  49.       for obj in group
  50.         next if obj.nil?
  51.         obj.load_price unless obj.no_auto?
  52.       end
  53.     end
  54.   end
  55.  
  56. end
  57.  
  58. class RPG::EquipItem < RPG::BaseItem
  59.  
  60.   def load_price
  61.     hash = AMA::PRICE::HASH.dup
  62.     hash.each {|id,value|
  63.       @price += params[id] * value unless @price > 0
  64.     }
  65.   end
  66.  
  67.   def no_auto?
  68.     return self.note.include?("<no auto>")
  69.   end
  70.  
  71. end
Advertisement
Add Comment
Please, Sign In to add comment