#=============================================
# ** Oni Monetary System
#---------------------------------------------
# Developed by Onidsouza
# Do not redestribute without permission
# Remember: MAX_GOLD always is 999.999
# Do not make a item that costs more than that
#==============================================
module OnidsouzaGold
# OPTIONAL
#If not using icons
GOLD = "Z"
SILVER = "S"
BRONZE = "B"
USE_ICON = true
#If using icons, icon ID
GOLD_ICON = 102
SILVER_ICON = 98
BRONZE_ICON = 97
end
class Game_Party < Game_Unit
alias onidsouzagoldinit initialize
def initialize
onidsouzagoldinit
@gold = [0, 0, 0]
end
def gold_array
return @gold
end
def gold
return total_gold
end
def gain_gold(n)
@gold[2] += n
update_gold
end
def lose_gold(n)
gain_gold(-n)
end
def total_gold
return (@gold[2] + (@gold[1]*21) + (@gold[0]*357))
end
def gold_to_silver
return (@gold[2]/21) + (@gold[1]) + (@gold[0]*17)
end
def gold_to_gold
return @gold[0] + (@gold[1]/17) + (@gold[2]/357)
end
def update_gold
times = @gold[2] / 21
@gold[2] -= times * 21
@gold[1] += times
times = @gold[1] / 17
@gold[1] -= times * 17
@gold[0] += times
if @gold[0] > 99
@gold[0] = @gold[1] = @gold[2] = 99
end
end
def make_gold_text
return to_monetary_system(total_gold)
end
end
class Window_Base < Window
def draw_currency_value(value, x, y, width, gold = true)
if not OnidsouzaGold::USE_ICON
self.contents.font.color = normal_color
self.contents.draw_text(x, y, width, WLH, to_monetary_system(value), 2)
elsif OnidsouzaGold::USE_ICON and gold
self.contents.font.color = normal_color
xx = 20
draw_icon(OnidsouzaGold::GOLD_ICON, x, y)
self.contents.draw_text(x + 20, y, xx, WLH, $game_party.gold_array[0])
x += 40
draw_icon(OnidsouzaGold::SILVER_ICON, x, y)
self.contents.draw_text(x + 20, y, xx, WLH, $game_party.gold_array[1])
x += 40
draw_icon(OnidsouzaGold::BRONZE_ICON, x, y)
self.contents.draw_text(x + 20, y, xx, WLH, $game_party.gold_array[2])
else
arr = to_monetary_array(value)
self.contents.font.color = normal_color
xx = 20
draw_icon(OnidsouzaGold::GOLD_ICON, x, y)
self.contents.draw_text(x + 20, y, xx, WLH, arr[0])
x += 40
draw_icon(OnidsouzaGold::SILVER_ICON, x, y)
self.contents.draw_text(x + 20, y, xx, WLH, arr[1])
x += 40
draw_icon(OnidsouzaGold::BRONZE_ICON, x, y)
self.contents.draw_text(x + 20, y, xx, WLH, arr[2])
end
end
end
class Window_ShopBuy < Window_Selectable
def draw_item(index)
item = @data[index]
number = $game_party.item_number(item)
enabled = (item.price <= $game_party.total_gold and number < 99)
rect = item_rect(index)
self.contents.clear_rect(rect)
if item != nil
draw_icon(item.icon_index, rect.x, rect.y, enabled)
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
wid = contents.text_size(item.name).width
self.contents.draw_text(rect.x + 24, rect.y, wid, WLH, item.name)
end
#rect.width -= 4
price = to_monetary_system(item.price)
self.contents.draw_text(rect.x + 24 + wid, rect.y, rect.width - 24 - wid, WLH, price, 2)
# NEW
#self.contents.draw_text(rect.x + 30, rect.y, rect.width - rect.x - 30, WLH, to_monetary_system(item.price), 2)
#draw_currency_value(item.price, rect.x + rect.width + 8, rect.y, rect.width, false, )
end
end
def to_monetary_system(integ)
data = [0, 0, 0]
data[2] = integ
times = data[2] / 100
data[2] -= times * 100
data[1] += times
times = data[1] / 100
data[1] -= times * 100
data[0] += times
return "#{data[0]} #{OnidsouzaGold::GOLD} - #{data[1]} #{OnidsouzaGold::SILVER} - #{data[2]} #{OnidsouzaGold::BRONZE}"
end
def to_monetary_array(integ)
data = [0, 0, 0]
data[2] = integ
times = data[2] / 100
data[2] -= times * 100
data[1] += times
times = data[1] / 100
data[1] -= times * 100
data[0] += times
return data
end