Код:
if $imported["DenKyz_CalTime"]
=begin
###############################################################################
# #
# Банковская система #
# #
###############################################################################
Автор: Денис Кузнецов (http://vk.com/id8137201)
Версия: 1.0 alpha
Релиз от: 27.10.14
Зависимость: Game_Time by Denis Kyznetsov (минимум 5.0 версия)
Установка: разместить ниже Game_Time (Время/Дата)
Инструкция:
call_bank(value1, value2) - чтобы вызвать банк
value1 - проценты по вкладам, value2 - проценты по кредитам
add_bank_reputation(value) - чтобы изменить репутацию
=end
module Bank_Settings
# Название Банка
BANK_NAME = "Государственный Банк"
# Минимальная сумма вклада
MINIMUM_HOLDING = 100
# Минимальная сумма кредита
MINIMUM_CREDIT = 100
# Максимальная сумма вклада
HOLDING_MAXIMUM = 100000
# Максимальная сумма кредита
CREDIT_MAXIMUM = 100000
# Минимальный порог репутации, когда вы можете получить кредит
REPUTATION_MINIMUM = -50
# Скорость текста (верхнего). Чем меньше, тем быстрее
TEXT_SPEED1 = 2
# Прокрутка текста сверху влево ? true/false. false - вправо
SCROLL_TEXT1 = true
# Настройка верхнего текста. "Приветствие" - зарезервированное слово и окно
# отображает "Добро пожаловать в /название банка/"
# "Информация по вкладам" - "Проценты по вкладам начисляются в конце каждого месяца"
# "Информация по кредитам" - "Сумма по кредиту списывается ежемесячно"
# "Предупреждение" - "За просроченный кредит каждый день идут проценты"
CUSTOM_TEXT1 = ["Приветствие", "Информация по вкладам", "Информация по кредитам", "Предупреждение"]
# Скорость текста (нижнего). Чем меньше, тем быстрее
TEXT_SPEED2 = 1
# Прокрутка текста снизу влево ? true/false. false - вправо
SCROLL_TEXT2 = true
# Настройка нижнего текста. "Дата" - отображает "Сегодня: /текущая дата/"
# "Вклады_%" отображает "Проценты по вкладам: до /проценты/"
# "Кредиты_% - "Проценты по кредитам: до /проценты/"
CUSTOM_TEXT2 = ["Дата", "Вклады_%", "Кредиты_%"]
#### КОНЕЦ НАСТРОЙКИ #### Ниже не трогать ! Аррррр ###########################
end
class Bank_System_Scene < Scene_Base
include Bank_Settings
def start
super
@exit = false
@last_confirm_window = false
@add_window = false
create_all_windows
end
def create_all_windows
create_help_window
create_remote_window
create_all_info_window
create_before_operation_info_window
create_additional_window
create_add_holding_or_add_credit
create_add_to_holding_or_close_credit_bank_window
create_confirm_window
end
def create_help_window
@create_help_window = Help_Bank_Window.new(0, 0, Graphics.width, 50, 1)
@create_help_window.ox = Graphics.width * (SCROLL_TEXT1 ? -1 : 1)
@create_help_window.arrows_visible = false
end
def create_remote_window
@create_remote_window = Remote_Bank_Window.new(0, 50)
@create_remote_window.set_handler(:holdings, method(:holdings))
@create_remote_window.set_handler(:credits, method(:credits))
@create_remote_window.set_handler(:exit, method(:exit))
@create_remote_window.set_handler(:add_holding, method(:add_holding))
@create_remote_window.set_handler(:add_credit, method(:add_credit))
@create_remote_window.set_handler(:add_to_holding, method(:add_to_holding))
@create_remote_window.set_handler(:close_holding, method(:close_holding))
@create_remote_window.set_handler(:close_credit, method(:close_credit))
end
def create_all_info_window
@create_money_info_window = Money_Info_Bank_Window.new(Graphics.width/2, 100, Graphics.width/2, 100)
@create_money_info_window.x = Graphics.width
@create_info_window = Info_Bank_Window.new(0, 100, Graphics.width/2, 100)
@create_info_window.x = -Graphics.width
@create_first_before_operation_info_bank_window = First_Before_Operation_Info_Bank_Window.new(0, 200, Graphics.width, Graphics.height - 250)
@create_first_before_operation_info_bank_window.opacity = 0
@create_first_before_operation_info_bank_window.contents_opacity = 0
@start_scene_animation_update = true
end
def create_before_operation_info_window
@create_before_operation_info_window = Before_Operation_Info_Bank_Window.new(0, 200, Graphics.width, Graphics.height - 250)
@create_before_operation_info_window.x = -Graphics.width
@create_before_operation_info_window.hide
end
### самое нижнее окно с бегущей строкой
def create_additional_window
@create_additional_window = Help_Bank_Window.new(0, Graphics.height - 50, Graphics.width, 50, 2)
@create_additional_window.ox = Graphics.width * (SCROLL_TEXT2 ? -1 : 1) ###
@create_additional_window.arrows_visible = false
end
### окно добавления к вкладу/погашения кредита
def create_add_to_holding_or_close_credit_bank_window
@create_add_to_holding_or_close_credit_bank_window = Add_to_Holding_Or_Close_Credit_Bank_Window.new(0, 200)
@create_add_to_holding_or_close_credit_bank_window.set_handler(:money, method(:add_to_holding_or_close_credit))
@create_add_to_holding_or_close_credit_bank_window.set_handler(:confirm_yes, method(:confirm_add_to_holding_or_close_credit))
@create_add_to_holding_or_close_credit_bank_window.set_handler(:confirm_no, method(:add_window_down_animation))
@create_add_to_holding_or_close_credit_bank_window.x = Graphics.width
@create_add_to_holding_or_close_credit_bank_window.deactivate
@create_add_to_holding_or_close_credit_bank_window.hide
end
### окно получения вклада/кредита
def create_add_holding_or_add_credit
@create_add_holding_or_add_credit = Add_Holding_Or_Add_Credit_Bank_Window.new(0, 200)
@create_add_holding_or_add_credit.set_handler(:month1, method(:month))
@create_add_holding_or_add_credit.set_handler(:month3, method(:month))
@create_add_holding_or_add_credit.set_handler(:month6, method(:month))
@create_add_holding_or_add_credit.set_handler(:month12, method(:month))
@create_add_holding_or_add_credit.set_handler(:money, method(:money))
@create_add_holding_or_add_credit.set_handler(:holding_credit_no, method(:layer_2_down))
@create_add_holding_or_add_credit.set_handler(:holding_credit_yes, method(:confirm_holding_credit))
@create_add_holding_or_add_credit.y = 50
@create_add_holding_or_add_credit.deactivate
@create_add_holding_or_add_credit.hide
end
### создание последнего окна
def create_confirm_window
@create_notification_bank_window = Notification_Bank_Window.new
@create_notification_bank_window.y = 200 + @create_add_holding_or_add_credit.height
@create_notification_bank_window.opacity = 0
@create_notification_bank_window.contents_opacity = 0
@create_notification_bank_window.hide
@create_notification_bank_window.deactivate
@create_notification_bank_window.set_handler(:last_confirm, method(:last_confirm))
@create_notification_bank_window.set_handler(:last_confirm_no, method(:last_window_confirm_no))
end
### обработка последнего окна, получение вклада/кредита
def last_confirm
case @create_notification_bank_window.mode
when 1
$Player_Holding[0] = @create_notification_bank_window.money
$Player_Holding[1] = @create_notification_bank_window.percent
$Player_Holding[2] = @create_notification_bank_window.final_sum
$Player_Holding[3] = @create_notification_bank_window.month
$game_party.gain_gold(-$Player_Holding[0])
when 2
$Player_Credit[0] = @create_notification_bank_window.credit_final * @create_notification_bank_window.month
$Player_Credit[1] = @create_notification_bank_window.percent
$Player_Credit[2] = @create_notification_bank_window.credit_final
$Player_Credit[3] = @create_notification_bank_window.month
$game_party.gain_gold(@create_notification_bank_window.money)
end
last_window_confirm_animation
end
def confirm_add_to_holding_or_close_credit
case @create_add_to_holding_or_close_credit_bank_window.mode
when 1
$Player_Holding[0] += @create_add_to_holding_or_close_credit_bank_window.money
$game_party.gain_gold(-@create_add_to_holding_or_close_credit_bank_window.money)
when 2
$Player_Credit[0] -= @create_add_to_holding_or_close_credit_bank_window.money
$game_party.gain_gold(-@create_add_to_holding_or_close_credit_bank_window.money)
$Bank_Reputation += 3 * $Player_Credit[3] if $Player_Credit[3] > 0
$Player_Credit = [] if $Player_Credit[0] == 0
@create_before_operation_info_window.mode = 1
@create_before_operation_info_window.text = "кредита"
end
$bank_remote_cursor = 0
@create_info_window.update(true)
@create_before_operation_info_window.update(true)
@create_add_to_holding_or_close_credit_bank_window.layer = 1
@create_add_to_holding_or_close_credit_bank_window.money = 0
@create_add_to_holding_or_close_credit_bank_window.deactivate
@create_before_operation_info_window.show
@add_window = false
@window_animation = 5
$bank_animation_update = true
update_remote_window
end
### обработка продолжения вклада/кредита
def confirm_holding_credit
@last_confirm_window = true
@create_add_holding_or_add_credit.deactivate
@create_notification_bank_window.activate
@create_notification_bank_window.show
@window_animation = 7
$bank_animation_update = true
@create_notification_bank_window.mode = @create_add_holding_or_add_credit.text == "вклада" ? 1 : 2
@create_notification_bank_window.no_money = false
@create_notification_bank_window.no_money = true if @create_add_holding_or_add_credit.money < MINIMUM_HOLDING && @create_notification_bank_window.mode == 1
@create_notification_bank_window.no_money = true if @create_add_holding_or_add_credit.money < MINIMUM_CREDIT && @create_notification_bank_window.mode == 2
if @create_notification_bank_window.no_money
@create_notification_bank_window.deactivate
@create_notification_bank_window.refresh
return
end
@create_notification_bank_window.money = @create_add_holding_or_add_credit.money
case @create_add_holding_or_add_credit.month
when :month1
@create_notification_bank_window.month = 1
when :month3
@create_notification_bank_window.month = 3
when :month6
@create_notification_bank_window.month = 6
when :month12
@create_notification_bank_window.month = 12
end
@create_notification_bank_window.refresh
@create_notification_bank_window.select(0)
end
### обработка выбора месяца
def month
@create_add_holding_or_add_credit.layer = 2
@create_add_holding_or_add_credit.activate
end
### обработка ввода денег
def money
@create_add_holding_or_add_credit.layer = 3
@create_add_holding_or_add_credit.select(5)
@create_add_holding_or_add_credit.activate
end
# отключаем 3 команды, включаем оформление вклада
def add_holding
@create_remote_window.deactivate
@create_add_holding_or_add_credit.text = "вклада"
@create_add_holding_or_add_credit.activate
@create_add_holding_or_add_credit.show
@create_add_holding_or_add_credit.opacity = 0
@create_add_holding_or_add_credit.contents_opacity = 0
@window_animation = 3
$bank_animation_update = true
@operation = true
end
# отключаем 3 команды, включаем добавление денег к вкладу
def add_to_holding
@create_remote_window.deactivate
@create_add_to_holding_or_close_credit_bank_window.mode = 1
@create_add_to_holding_or_close_credit_bank_window.refresh
@create_add_to_holding_or_close_credit_bank_window.select(0)
@create_add_to_holding_or_close_credit_bank_window.activate
@create_add_to_holding_or_close_credit_bank_window.show
@window_animation = 2
$bank_animation_update = true
@add_window = true
end
def add_to_holding_or_close_credit
@create_add_to_holding_or_close_credit_bank_window.layer = 2
@create_add_to_holding_or_close_credit_bank_window.refresh
@create_add_to_holding_or_close_credit_bank_window.select(1)
@create_add_to_holding_or_close_credit_bank_window.activate
end
def close_holding
$game_party.gain_gold($Player_Holding[0])
$bank_remote_cursor = 0
$Player_Holding = []
@create_info_window.update(true)
@create_before_operation_info_window.mode = 1
@create_before_operation_info_window.text = "открыть вклад"
@create_before_operation_info_window.update(true)
update_remote_window
end
# отключаем 3 команды, включаем оформление кредита
def add_credit
add_holding
@create_add_holding_or_add_credit.text = "кредита"
end
# отключаем 3 команды, включаем закрытие кредита
def close_credit
@create_remote_window.deactivate
@create_add_to_holding_or_close_credit_bank_window.mode = 2
@create_add_to_holding_or_close_credit_bank_window.refresh
@create_add_to_holding_or_close_credit_bank_window.select(0)
@create_add_to_holding_or_close_credit_bank_window.activate
@create_add_to_holding_or_close_credit_bank_window.show
@window_animation = 2
$bank_animation_update = true
@add_window = true
end
# активируем команды для вкладов, обновляем окно и переключаем окно
def holdings
@create_remote_window.remote_list = 2
update_remote_window
@create_before_operation_info_window.mode = 1
@create_before_operation_info_window.text = "открыть вклад"
@create_before_operation_info_window.mode = 2 if $Player_Holding != []
@window_animation = 1
holding_and_credits
$bank_animation_update = true
end
# активируем команды для кредитов, обновляем окно и переключаем окно
def credits
@create_remote_window.remote_list = 3
update_remote_window
@create_before_operation_info_window.mode = 1
@create_before_operation_info_window.text = "взять кредит"
@create_before_operation_info_window.mode = 2 if $Player_Credit != []
@window_animation = 1
holding_and_credits
$bank_animation_update = true
end
def holding_and_credits
@create_before_operation_info_window.x = -Graphics.width
@create_before_operation_info_window.update(true)
@create_before_operation_info_window.show
end
def layer_2_down
@create_add_holding_or_add_credit.money = 0 if @create_add_holding_or_add_credit.layer == 3
@create_add_holding_or_add_credit.layer = 1
@create_add_holding_or_add_credit.refresh
@create_add_holding_or_add_credit.select(0)
@create_add_holding_or_add_credit.activate
end
### обработка esc для окна подтверждения - последнего окна
def last_window_confirm_no
last_window_down
layer_2_down
end
### запуск анимации для последнего окна
def last_window_down
@window_animation = 8
$bank_animation_update = true
@last_confirm_window = false
@create_notification_bank_window.deactivate
@create_add_holding_or_add_credit.activate
@create_add_holding_or_add_credit.show
end
# обновляем окно с 3 командами
def update_remote_window
@create_remote_window.refresh
@create_remote_window.select(0)
@create_remote_window.activate
end
# обработка нажатия выход
def exit
return @exit = true
end
# обработка нажатия кнопки esc на всех этапах
def update_list_down
return exit if @create_remote_window.remote_list == 1
if !@operation && !@last_confirm_window && !@add_window
@create_remote_window.remote_list = 1
update_remote_window
@window_animation += 3
$bank_animation_update = true
@create_first_before_operation_info_bank_window.show
elsif @operation && @create_add_holding_or_add_credit.layer == 1 && !@last_confirm_window
operation_window_down
elsif @operation && @create_add_holding_or_add_credit.layer == 2 && !@last_confirm_window
layer_2_down
elsif @operation && @create_add_holding_or_add_credit.layer == 3 && !@last_confirm_window
month
elsif @last_confirm_window
last_window_down
elsif @add_window && @create_add_to_holding_or_close_credit_bank_window.layer == 1
update_remote_window
@window_animation = 5
$bank_animation_update = true
@create_before_operation_info_window.show
@add_window = false
elsif @add_window && @create_add_to_holding_or_close_credit_bank_window.layer == 2
add_window_down_animation
end
end
def add_window_down_animation
@create_add_to_holding_or_close_credit_bank_window.layer = 1
@create_add_to_holding_or_close_credit_bank_window.refresh
@create_add_to_holding_or_close_credit_bank_window.select(0)
end
def operation_window_down
@create_before_operation_info_window.show
@create_add_holding_or_add_credit.deactivate
@create_remote_window.activate
@window_animation = 6
$bank_animation_update = true
@operation = false
end
def last_window_confirm_animation
@create_notification_bank_window.deactivate
@create_add_holding_or_add_credit.select(0)
@create_add_holding_or_add_credit.deactivate
@create_add_holding_or_add_credit.layer = 1
@create_add_holding_or_add_credit.money = 0
@operation = false
@last_confirm_window = false
@create_remote_window.remote_list = 1
@create_first_before_operation_info_bank_window.show
update_remote_window
@create_before_operation_info_window.x = -Graphics.width
@create_before_operation_info_window.opacity = 255
@create_before_operation_info_window.contents_opacity = 255
@create_before_operation_info_window.y = 200
@create_notification_bank_window.y = 200 + @create_notification_bank_window.height
@window_animation = 9
$bank_animation_update = true
@create_info_window.update(true)
end
def update
super
if @start_scene_animation_update
@create_info_window.x += 15
@create_money_info_window.x -= 8
@create_first_before_operation_info_bank_window.opacity += 8
@create_first_before_operation_info_bank_window.contents_opacity += 8
@create_help_window.opacity += 10
@create_additional_window.opacity += 10
if @create_money_info_window.x <= Graphics.width/2
@create_info_window.x = 0
@create_money_info_window.x = Graphics.width/2
@create_first_before_operation_info_bank_window.opacity = 255
@create_first_before_operation_info_bank_window.contents_opacity = 255
@start_scene_animation_update = false
end
end
### обновление прокрутки текста
if Graphics.frame_count % Bank_Settings::TEXT_SPEED1 == 0
@create_help_window.ox -= 1 * (SCROLL_TEXT1 ? -1 : 1)
if @create_help_window.ox == -Graphics.width * (SCROLL_TEXT1 ? -1 : 1)
@create_help_window.ox = Graphics.width * (SCROLL_TEXT1 ? -1 : 1)
@create_help_window.number_text += 1
@create_help_window.number_text = 0 if @create_help_window.number_text >= CUSTOM_TEXT1.size
end
end
### обновление прокрутки текста
if Graphics.frame_count % Bank_Settings::TEXT_SPEED2 == 0
@create_additional_window.ox -= 1 * (SCROLL_TEXT2 ? -1 : 1)
if @create_additional_window.ox == -Graphics.width * (SCROLL_TEXT2 ? -1 : 1)
@create_additional_window.ox = Graphics.width * (SCROLL_TEXT2 ? -1 : 1)
@create_additional_window.number_text += 1
@create_additional_window.number_text = 0 if @create_additional_window.number_text >= CUSTOM_TEXT2.size
end
end
if $bank_animation_update
case @window_animation
when 1 ### включение 2-ого окна
@create_first_before_operation_info_bank_window.x += 15
@create_before_operation_info_window.x += 15
if @create_before_operation_info_window.x >= 0
@create_before_operation_info_window.x = 0
@create_first_before_operation_info_bank_window.x = Graphics.width
@create_first_before_operation_info_bank_window.hide
$bank_animation_update = false
end
when 2 ### включение 3-ого окна
@create_add_to_holding_or_close_credit_bank_window.x -= 15
@create_before_operation_info_window.x -= 15
if @create_add_to_holding_or_close_credit_bank_window.x < 0
@create_add_to_holding_or_close_credit_bank_window.x = 0
@create_before_operation_info_window.x = -Graphics.width
@create_before_operation_info_window.hide
$bank_animation_update = false
end
when 3 ### включение 4-ого окна
@create_add_holding_or_add_credit.y += 4
@create_before_operation_info_window.y += 4
@create_add_holding_or_add_credit.opacity += 17
@create_add_holding_or_add_credit.contents_opacity += 17
@create_before_operation_info_window.opacity -= 17
@create_before_operation_info_window.contents_opacity -= 17
if @create_add_holding_or_add_credit.y >= 200
@create_add_holding_or_add_credit.y = 200
@create_before_operation_info_window.y = 200 + @create_add_holding_or_add_credit.height
@create_before_operation_info_window.opacity = 0
@create_before_operation_info_window.contents_opacity = 0
@create_before_operation_info_window.hide
$bank_animation_update = false
end
when 4 ### выключение 2-ого окна
@create_before_operation_info_window.x -= 15
@create_first_before_operation_info_bank_window.x -= 15
if @create_first_before_operation_info_bank_window.x <= 0
@create_first_before_operation_info_bank_window.x = 0
@create_before_operation_info_window.x = -Graphics.width
@create_before_operation_info_window.hide
$bank_animation_update = false
end
when 5 ### выключение 3-ого окна
@create_add_to_holding_or_close_credit_bank_window.x += 15
@create_before_operation_info_window.x += 15
if @create_add_to_holding_or_close_credit_bank_window.x >= Graphics.width
@create_add_to_holding_or_close_credit_bank_window.x = Graphics.width
@create_before_operation_info_window.x = 0
@create_add_to_holding_or_close_credit_bank_window.deactivate
@create_add_to_holding_or_close_credit_bank_window.hide
@window_animation = 1
$bank_animation_update = false
end
when 6 ### выключение 4-ого окна
@create_add_holding_or_add_credit.y -= 4
@create_before_operation_info_window.y -= 4
@create_before_operation_info_window.opacity += 17
@create_before_operation_info_window.contents_opacity += 17
@create_add_holding_or_add_credit.opacity -= 17
@create_add_holding_or_add_credit.contents_opacity -= 17
if @create_before_operation_info_window.y <= 200
@create_before_operation_info_window.y = 200
@create_add_holding_or_add_credit.y = 50
@create_add_holding_or_add_credit.opacity = 0
@create_add_holding_or_add_credit.contents_opacity = 0
@create_add_holding_or_add_credit.hide
$bank_animation_update = false
@window_animation = 1
end
when 7 ### открытие 5-ого окна
@create_add_holding_or_add_credit.y -= 4
@create_notification_bank_window.y -= 4
@create_notification_bank_window.opacity += 17
@create_notification_bank_window.contents_opacity += 17
@create_add_holding_or_add_credit.opacity -= 17
@create_add_holding_or_add_credit.contents_opacity -= 17
if @create_notification_bank_window.y <= 200
@create_notification_bank_window.y = 200
@create_add_holding_or_add_credit.y = 50
@create_add_holding_or_add_credit.hide
$bank_animation_update = false
end
when 8 ### закрытие 5-ого окна
@create_add_holding_or_add_credit.y += 4
@create_notification_bank_window.y += 4
@create_add_holding_or_add_credit.opacity += 17
@create_add_holding_or_add_credit.contents_opacity += 17
@create_notification_bank_window.opacity -= 17
@create_notification_bank_window.contents_opacity -= 17
if @create_add_holding_or_add_credit.y >= 200
@create_add_holding_or_add_credit.y = 200
@create_notification_bank_window.y = 200 + @create_add_holding_or_add_credit.height
@create_notification_bank_window.opacity = 0
@create_notification_bank_window.contents_opacity = 0
@create_notification_bank_window.hide
$bank_animation_update = false
end
when 9 ### получен вклад/кредит
@create_notification_bank_window.opacity -= 7
@create_notification_bank_window.contents_opacity -= 7
@create_first_before_operation_info_bank_window.x -= 15
if @create_first_before_operation_info_bank_window.x <= 0
@create_first_before_operation_info_bank_window.x = 0
@create_notification_bank_window.opacity = 0
@create_notification_bank_window.contents_opacity = 0
@create_notification_bank_window.hide
$bank_animation_update = false
end
end
end
if @bank_cursor != $bank_remote_cursor &&
((@create_remote_window.remote_list == 2 && $Player_Holding == []) ||
(@create_remote_window.remote_list == 3 && $Player_Credit == []))
@bank_cursor = $bank_remote_cursor
@create_before_operation_info_window.update(true)
end
if Input.trigger?(:B) || @exit
return if $bank_animation_update
if !@exit
update_list_down
Sound.play_cancel
return
end
@exit = false
return_scene
end
end
end
#### ОКНА ######################################################################
class First_Before_Operation_Info_Bank_Window < Window_Base
def initialize(x, y, w, h)
super(x, y, w, h)
update(true)
end
def update(upd = false)
return if !upd
contents.clear
draw_text(0, 0, Graphics.width - 16, 30, "Приветсвуем Вас в нашем банке", 1)
draw_text(0, (Graphics.height - 250)/3 - 5, Graphics.width - 16, 30, "Вы можете открыть у нас свой вклад или", 1)
draw_text(0, (Graphics.height - 250)/3 + 15, Graphics.width - 16, 30, "оформить кредит на выгодных условиях", 1)
end
end
class Help_Bank_Window < Window_Base
include Bank_Settings
attr_accessor :number_text
def initialize(x, y, w, h, mode)
@number_text, @hello_world_text = 0, 0
@mode = mode
super(x, y, w, h)
update(true)
end
def text
case @mode
when 1
case CUSTOM_TEXT1[@number_text]
when "Приветствие"
return "Добро пожаловать в " + BANK_NAME
when "Информация по вкладам"
return "Проценты по вкладам начисляются в конце каждого месяца"
when "Информация по кредитам"
return "Сумма по кредиту списывается ежемесячно"
when "Предупреждение"
return "За просроченный кредит каждый день идут проценты"
else
return CUSTOM_TEXT1[@number_text]
end
when 2
case CUSTOM_TEXT2[@number_text]
when "Дата"
return "Сегодня: " + $Game_Time.day.to_s + " " + Calendar_Settings::CALENDAR_MONTHS[$Game_Time.month] +
" " + $Game_Time.year.to_s + " г."
when "Вклады_%"
return "Проценты по вкладам: до " + $Bank_Settings[0].to_s + " %"
when "Кредиты_%"
return "Проценты по кредитам: до " + $Bank_Settings[1].to_s + " %"
else
return CUSTOM_TEXT2[@number_text]
end
end
end
def create_contents
self.contents = Bitmap.new(Graphics.width*1.4, Graphics.height)
end
def update(upd = false)
if @hello_world_text != @number_text
@hello_world_text = @number_text
upd = true
end
return if !upd
contents.clear
contents.font.size = 26
draw_text(0, -2, Graphics.width*1.25, 30, text)
end
end
class Remote_Bank_Window < Window_HorzCommand
attr_accessor :remote_list
def initialize(x, y)
@remote_list = 1
super(x, y)
end
def process_handling
super if !$bank_animation_update
end
def col_max
return 3
end
def window_width
Graphics.width
end
def window_height
50
end
def make_command_list
$bank_remote_cursor = 0
case @remote_list
when 1
add_command("Вклады", :holdings)
add_command("Кредиты", :credits)
when 2
text = "Открыть вклад"
symbol = :add_holding
if $Player_Holding != []
text = "Добавить к вкладу"
symbol = :add_to_holding
end
add_command(text, symbol)
enable = true
enable = false if $Player_Holding == []
add_command("Закрыть вклад", :close_holding, enable)
when 3
enable = true
enable = false if $Player_Credit == []
add_command("Взять кредит", :add_credit, ($Bank_Reputation > Bank_Settings::REPUTATION_MINIMUM && !enable) ? true : false)
add_command("Погасить кредит", :close_credit, enable)
end
add_command("Выход", :exit)
end
def cursor_left(wrap = false)
$bank_remote_cursor -= 1
$bank_remote_cursor = 2 if $bank_remote_cursor == -1
select($bank_remote_cursor)
end
def cursor_right(wrap = false)
$bank_remote_cursor += 1
$bank_remote_cursor = 0 if $bank_remote_cursor == 3
select($bank_remote_cursor)
end
end # class Remote_Bank_Window < Window_HorzCommand
class Info_Bank_Window < Window_Base
def initialize(x, y, w, h)
super(x, y, w, h)
@provetka_holding = $Player_Holding.nil?
@proverka_credit = $Player_Credit.nil?
update(true)
end
def update(upd = false)
return if !upd
contents.clear
casing = 1 if $Player_Holding != [] && $Player_Credit == []
casing = 2 if $Player_Holding == [] && $Player_Credit != []
casing = 3 if $Player_Holding == [] && $Player_Credit == []
casing = 4 if $Player_Holding != [] && $Player_Credit != []
case casing
when 1
draw_text(0, 10, 240, 30, "Ваш вклад: ")
draw_text(0, 10, 240, 30, $Player_Holding[0].to_s + " " + Vocab::currency_unit, 2)
draw_text(0, 35, 240, 30, "У вас нет кредита", 1)
when 2
draw_text(0, 10, 240, 30, "Ваш кредит: ")
draw_text(0, 10, 240, 30, $Player_Credit[0].to_s + " " + Vocab::currency_unit, 2)
draw_text(0, 35, 240, 30, "У вас нет вклада", 1)
when 3
draw_text(-10, 20, 260, 30, "У вас нет вкладов/кредитов", 1)
when 4
draw_text(0, 10, 240, 30, "Ваш вклад: ")
draw_text(0, 10, 240, 30, $Player_Holding[0].to_s + " " + Vocab::currency_unit, 2)
draw_text(0, 35, 240, 30, "Ваш кредит: ")
draw_text(0, 35, 240, 30, $Player_Credit[0].to_s + " " + Vocab::currency_unit, 2)
end
@provetka_holding = false
@proverka_credit = false
end
end # class Info_Bank_Window < Window_Base
class Money_Info_Bank_Window < Window_Base
def initialize(x, y, w, h)
super(x, y, w, h)
@money = -1
@reputation = 0
end
def update
if @reputation != $Bank_Reputation || @money != $game_party.gold
@reputation = $Bank_Reputation
@money = $game_party.gold
contents.clear
draw_text(0, 5, Graphics.width/3, 30, "Ваша репутация: ")
$Bank_Reputation > 0 ? change_color(text_color(24)) : change_color(text_color(20))
change_color(normal_color) if $Bank_Reputation == 0
draw_text(-30, 5, Graphics.width/2, 30, $Bank_Reputation.to_s, 2)
change_color(normal_color)
draw_text(0, 35, Graphics.width/3, 30, "У Вас: ")
draw_text(-30, 35, Graphics.width/2, 30, $game_party.gold.to_s + " " + Vocab::currency_unit, 2)
end
end
end # class Money_Info_Bank_Window < Window_Base
class Before_Operation_Info_Bank_Window < Window_Base
include Bank_Settings
attr_accessor :text
attr_accessor :mode
def initialize(x, y, w, h)
super(x, y, w, h)
@text = "открыть вклад"
@mode = 1
update(true)
end
def width
return Graphics.width - standard_padding*1.5
end
def what?
return @text.include?("вклад") ? "вклады: до " + $Bank_Settings[0].to_s + " %" : "кредиты: до " + $Bank_Settings[1].to_s + " %"
end
def no_what?
return @text.include?("вклад") ? "вклада" : "кредита"
end
def month(month)
case month
when 1
" месяц "
when 2..4
" месяца "
when 5..12
" месяцев "
end
end
def update(upd = false)
return if !upd
contents.clear
case @mode
when 1
if $bank_remote_cursor == 0
draw_text(0, 8, width, 30, "На какой период Вы хотите #{text} ?", 1)
draw_text(0, 38, width, 30, "У нас выгодные условия на " + what?, 1)
draw_text(0, 68, width, 30, "Вы можете #{text} на следующее время:", 1)
draw_text(0, 98, width, 30, "1 месяц, 3 месяца, 6 месяцев, 12 месяцев", 1)
elsif $bank_remote_cursor == 1
draw_text(0, 38, width, 30, "У Вас еще нет " + no_what?, 1)
draw_text(0, 68, width, 30, "Мы предлагаем Вам #{text} у нас", 1)
elsif $bank_remote_cursor == 2
draw_text(0, 52, width, 30, "До свидания! Приходите к нам еще!", 1)
end
when 2
p $Player_Holding
p $Player_Credit
case @text
when "открыть вклад"
draw_text(0, 8, width, 30, "Текущая сумма вклада составляет: " + $Player_Holding[0].to_s + " " + Vocab::currency_unit, 1)
draw_text(0, 38, width, 30, "Ваша процентная ставка: " + $Player_Holding[1].to_s + " %", 1)
draw_text(0, 68, width, 30, "Сумма максимально возможного вклада: " + HOLDING_MAXIMUM.to_s + " " + Vocab::currency_unit, 1)
if $Player_Holding[3] != 0
draw_text(0, 98, width, 30, "Еще " + $Player_Holding[3].to_s + month($Player_Holding[3]) + "Вам будут поступать проценты", 1)
else
draw_text(0, 98, width, 30, "Срок начисления процентов по этому вкладу истек", 1)
end
else
draw_text(0, 8, width, 30, "Текущая сумма кредита составляет: " + $Player_Credit[0].to_s + " " + Vocab::currency_unit, 1)
draw_text(0, 38, width, 30, "Ваша процентная ставка: " + $Player_Credit[1].to_s + " %", 1)
draw_text(0, 68, width, 30, "Сумма максимально возможного кредита: " + CREDIT_MAXIMUM.to_s + " " + Vocab::currency_unit, 1)
draw_text(0, 98, width, 30, "Еще " + $Player_Credit[3].to_s + month($Player_Credit[3]) + "Вы должны выплачивать кредит", 1)
end
end
end
end # class Before_Operation_Info_Bank_Window < Window_Base
class Add_to_Holding_Or_Close_Credit_Bank_Window < Window_Command
include Bank_Settings
attr_accessor :layer
attr_accessor :money
attr_accessor :mode
def initialize(x, y)
@layer = 1
@money = 0
@mode = 1
super
end
def col_max
2
end
def alignment
2
end
def process_handling
super if @money != 0
end
def item_rect(index)
rect = Rect.new
rect.width = item_width
rect.height = item_height
if index == 0
rect.width /= 2
rect.x = Graphics.width - standard_padding*13
rect.y = 28
else
rect.width /= 5
if index == 1
rect.x = Graphics.width/2 - item_width/2 + spacing*8
else
rect.x = Graphics.width/2 + item_width/4 + spacing*4
end
rect.y = 78
end
rect
end
def cursor_pagedown(wrap = false)
return if @layer != 1
@money += 1000
case @mode
when 1
@money = HOLDING_MAXIMUM - $Player_Holding[0] if @money > HOLDING_MAXIMUM - $Player_Holding[0]
when 2
@money = $Player_Credit[0] if @money > $Player_Credit[0]
end
@money = $game_party.gold if @money > $game_party.gold
refresh
end
def cursor_pageup(wrap = false)
return if @layer != 1
@money -= 1000
@money = 0 if @money < 0
refresh
end
def cursor_up(wrap = false)
return if @layer != 1
@money += 100
case @mode
when 1
@money = HOLDING_MAXIMUM - $Player_Holding[0] if @money > HOLDING_MAXIMUM - $Player_Holding[0]
when 2
@money = $Player_Credit[0] if @money > $Player_Credit[0]
end
@money = $game_party.gold if @money > $game_party.gold
refresh
end
def cursor_down(wrap = false)
return if @layer != 1
@money -= 100
@money = 0 if @money < 0
refresh
end
def cursor_left(wrap = false)
if @layer == 1
@money -= 1
@money = 0 if @money < 0
else
select(1)
end
refresh
end
def cursor_right(wrap = false)
if @layer == 1
@money += 1
case @mode
when 1
@money = HOLDING_MAXIMUM - $Player_Holding[0] if @money > HOLDING_MAXIMUM - $Player_Holding[0]
when 2
@money = $Player_Credit[0] if @money > $Player_Credit[0]
end
@money = $game_party.gold if @money > $game_party.gold
else
select(2)
end
refresh
end
def window_width
Graphics.width
end
def window_height
Graphics.height - 250
end
def width
Graphics.width - standard_padding*1.5
end
def refresh
super
draw_text(10, 25, width, 30, "Введите нужную сумму:")
draw_text(10, 75, width, 30, "Внести " + @money.to_s + " " + Vocab::currency_unit + " ?") if @layer == 2
end
def make_command_list
add_command(@money.to_s, :money) if @layer >= 1
if @layer ==2
add_command("Да", :confirm_yes)
add_command("Нет", :confirm_no)
end
end
end
class Add_Holding_Or_Add_Credit_Bank_Window < Window_Command
include Bank_Settings
attr_accessor :text
attr_accessor :layer
attr_accessor :money
attr_reader :month
def initialize(x, y)
@layer = 1
@text = "вклада"
@money = 0
@month = :month1
super
end
def alignment
2
end
def col_max
4
end
def window_width
Graphics.width
end
def window_height
Graphics.height - 250
end
def item_rect(index)
rect = Rect.new
rect.width = item_width
rect.height = item_height
rect.x = index % col_max * (item_width + spacing)
rect.y = 30
if index == 4
rect.x = Graphics.width - (item_width + spacing) - standard_padding
rect.y = 60
elsif index > 4
rect.width /= 2
if index == 5
rect.x = Graphics.width - standard_padding*12
else
rect.x = Graphics.width - standard_padding*8
end
rect.y = 90
end
rect
end
def width
Graphics.width - standard_padding*1.5
end
def call_handler(symbol)
super
@month = symbol if @layer == 2
end
def refresh
super
draw_text(0, 0, width, 30, "Выберите период для #{text}", 1)
draw_text(0, 60, width, 30, "Введите нужную сумму:") if @layer >= 2
draw_text(0, 90, width, 30, "Продолжить оформление " + @text + " ?") if @layer == 3
end
def update
super
refresh
if @layer == 2
select(4)
end
end
def cursor_pagedown(wrap = false)
return if @layer != 2
@money += 1000
@money = HOLDING_MAXIMUM if @money > HOLDING_MAXIMUM && @text == "вклада"
@money = CREDIT_MAXIMUM if @money > CREDIT_MAXIMUM && @text == "кредита"
@money = $game_party.gold if @money > $game_party.gold && @text == "вклада"
refresh
end
def cursor_pageup(wrap = false)
return if @layer != 2
@money -= 1000
@money = 0 if @money < 0
refresh
end
def cursor_up(wrap = false)
if @layer == 1
super
elsif @layer == 2
@money += 100
@money = HOLDING_MAXIMUM if @money > HOLDING_MAXIMUM && @text == "вклада"
@money = CREDIT_MAXIMUM if @money > CREDIT_MAXIMUM && @text == "кредита"
@money = $game_party.gold if @money > $game_party.gold && @text == "вклада"
end
refresh
end
def cursor_down(wrap = false)
if @layer == 1
super
elsif @layer == 2
@money -= 100
@money = 0 if @money < 0
end
refresh
end
def cursor_left(wrap = false)
if @layer == 1
super
elsif @layer == 2
@money -= 1
@money = 0 if @money < 0
elsif @layer == 3
select(5)
end
refresh
end
def cursor_right(wrap = false)
if @layer == 1
super
elsif @layer == 2
@money += 1
@money = HOLDING_MAXIMUM if @money > HOLDING_MAXIMUM && @text == "вклада"
@money = CREDIT_MAXIMUM if @money > CREDIT_MAXIMUM && @text == "кредита"
@money = $game_party.gold if @money > $game_party.gold
elsif @layer == 3
select(6)
end
refresh
end
def make_command_list
add_command("1 мес.", :month1)
add_command("3 мес.", :month3)
add_command("6 мес.", :month6)
add_command("12 мес.", :month12)
add_command(@money.to_s, :money) if @layer >= 2
if @layer == 3
add_command("Да", :holding_credit_yes)
add_command("Нет", :holding_credit_no)
end
end
end
class Notification_Bank_Window < Window_Command
include Bank_Settings
attr_accessor :money
attr_accessor :mode
attr_accessor :no_money
attr_accessor :month
attr_reader :percent
def initialize(x = 0, y = 200)
@money = 0
@mode = 0
@no_money = true
@month = 1
super
end
def alignment
1
end
def process_handling
super if !$bank_animation_update
end
def col_max
2
end
def item_rect(index)
rect = Rect.new
rect.width = item_width/4
rect.height = item_height
rect.x = Graphics.width - standard_padding*16 + index * spacing/2 * standard_padding/2
rect.y = 90
rect
end
def window_width
Graphics.width
end
def window_height
Graphics.height - 250
end
def width
Graphics.width - standard_padding
end
def update_cursor
super
return cursor_rect.empty if @no_money
end
def month_sum
case @month
when 1
" месяц "
when 3
" месяца "
else
" месяцев "
end
end
def sum
case @mode
when 1
@percent = [[$Bank_Settings[0], $Bank_Settings[0] - (@money/200).to_f/100 + ($Bank_Reputation/@month).to_f/100].min, 0.01].max
when 2
@percent = [[$Bank_Settings[1], $Bank_Settings[1] - (@money/250).to_f/100 - ($Bank_Reputation/(2*@month)).to_f/100].min, 0.01].max
end
@percent = @percent.round 2
end
def final_sum
all = @money
for i in 1..@month
all += (((all*@percent*i*30)/100)/365)
end
@mode == 1 ? (all.to_i - @money)/@month : all.to_i - @money
end
def credit_final
(((@money + final_sum)/@month.to_f).round 0).to_i
end
def refresh
super
if @no_money
draw_text(0, 45, width, 30, "Вы ввели слишком маленькую сумму", 1)
draw_text(0, 65, width, 30, "Минимальная сумма " + (@mode == 1 ? "вклада: " + MINIMUM_HOLDING.to_s : "кредита: " + MINIMUM_CREDIT.to_s) + " " + Vocab::currency_unit, 1)
else
y = @mode == 1 ? 7 : 0
draw_text(0, y, width, 30, "Вы собираетесь оформить " + (@mode == 1 ? "вклад ": "кредит ") + "на " + @money.to_s + " " + Vocab::currency_unit, 1)
y += 23
draw_text(0, y, width, 30, "Мы предлагаем Вам " + sum.to_s + " % годовых", 1)
case @mode
when 1
draw_text(0, 52, width, 30, "За " + @month.to_s + month_sum + "Вы заработаете: " + (final_sum * @month).to_s + " " + Vocab::currency_unit, 1)
when 2
y += 22
draw_text(0, y, width, 30, "За " + @month.to_s + month_sum + "Вы должны заплатить: " + (credit_final * @month).to_s + " " + Vocab::currency_unit, 1)
y += 22
draw_text(0, y, width, 30, "Ежемесечная плата составит: " + credit_final.to_s + " " + Vocab::currency_unit, 1)
end
draw_text(5, 90, width, 30, "Вы согласны с нашими условиями ?")
end
end
def make_command_list
if !@no_money
add_command("Да", :last_confirm)
add_command("Нет", :last_confirm_no)
end
end
end
### ФУНКЦИИ ####################################################################
class Game_Interpreter
def call_bank(value1, value2)
$Bank_Settings[0] = value1
$Bank_Settings[1] = value2
SceneManager.call(Bank_System_Scene)
end
def add_bank_reputation(value)
$Bank_Reputation += value
end
end # class Game_Interpreter
class Game_Time
alias denis_kyznetsov_bank_system_game_time_add_day add_day
def add_day(n = 1)
if $Player_Credit != []
if $Player_Credit[3] < 0
$Player_Credit[0] += ((($Player_Credit[0]*$Player_Credit[1]*30)/100)/365).to_i
end
end
denis_kyznetsov_bank_system_game_time_add_day(1)
end
alias denis_kyznetsov_bank_system_game_time_add_month add_month
def add_month(n = 1)
if $Player_Holding != []
if $Player_Holding[3] != 0
$Player_Holding[0] += $Player_Holding[2]
$Player_Holding[3] -= 1
end
end
if $Player_Credit != []
if $Player_Credit[0] > 0
gold = $game_party.gold
if $Player_Credit[3] > 0
if gold >= $Player_Credit[2] && $Player_Credit[0] >= $Player_Credit[2]
$Player_Credit[0] -= $Player_Credit[2]
$game_party.gain_gold(-$Player_Credit[2])
elsif gold >= $Player_Credit[0] && $Player_Credit[0] < $Player_Credit[2]
$game_party.gain_gold(-$Player_Credit[0])
$Player_Credit[0] = 0
elsif gold < $Player_Credit[2] && gold > 0 && $Player_Credit[0] > $Player_Credit[2]
$Bank_Reputation -= 1
$Player_Credit[0] -= gold
$game_party.gain_gold(-gold)
end
if $Player_Credit[0] == 0
$Bank_Reputation += 10
$Player_Credit = []
end
else
$Bank_Reputation -= 1
if gold >= $Player_Credit[0]
$game_party.gain_gold(-$Player_Credit[0])
$Player_Credit[0] = 0
elsif gold < $Player_Credit[0] && gold > 0
$Player_Credit[0] -= gold
$game_party.gain_gold(-gold)
else
$Bank_Reputation -= 1
end
$Player_Credit = [] if $Player_Credit[0] == 0
end
$Player_Credit[3] -= 1 if $Player_Credit != []
end
end
denis_kyznetsov_bank_system_game_time_add_month(1)
end
end # class Game_Time
module DataManager
class << self
alias denis_kyznetsov_bank_system_dt_mngr_setup_new_game setup_new_game
def setup_new_game
denis_kyznetsov_bank_system_dt_mngr_setup_new_game
$Bank_Settings = []
$Player_Holding = []
$Player_Credit = []
$Bank_Reputation = 0
end
alias denis_kyznetsov_bank_system_dt_mngr_make_save_contents make_save_contents
def make_save_contents
contents = denis_kyznetsov_bank_system_dt_mngr_make_save_contents
contents[:Player_Holding] = $Player_Holding
contents[:Player_Credit] = $Player_Credit
contents[:Bank_Reputation] = $Bank_Reputation
contents
end
alias denis_kyznetsov_bank_system_dt_mngr_extract_save_contents extract_save_contents
def extract_save_contents(contents)
denis_kyznetsov_bank_system_dt_mngr_extract_save_contents(contents)
$Player_Holding = contents[:Player_Holding]
$Player_Credit = contents[:Player_Credit]
$Bank_Reputation = contents[:Bank_Reputation]
end
end
end # module DataManager
end
Социальные закладки