#==============================================================================
# ミニゲーム用共通処理モジュール in VX Ace By 貪藻矢射妥←
#------------------------------------------------------------------------------
#
# ミニゲームなどで使用する共通処理関数をモジュール化したもの。
# これで、スクリプトの行数削減ができるんるん♪
#
# ※・・・ちなみに、これだけ導入しても意味がないので気をつけてください。
#
#==============================================================================
# 変更履歴
# 2013:06:16
# ・所持金ベット方式と変数ベット方式を選択可能に
#
# 2025:03:01
# ・ミニゲーム中で使用する文字定義の修正
module MINI_GAME
# 入力金額最高桁数
MAX_DIG = 7
# 所持金
HAVE_GOLD = ["所持金", "所持コイン"]
# 賭け金
BET_GOLD = ["賭け金", "賭けコイン"]
# コインの単位
COIN_UNIT = "£"
# 警告時のSE
ERROR_SE = RPG::SE.new("WWL 警告3")
# ファンファーレ1
JACK_POT_ME1 = RPG::ME.new("Victory2")
# ファンファーレ2
JACK_POT_ME2 = RPG::ME.new("Fanfare3")
# ファンファーレ3
JACK_POT_ME3 = RPG::ME.new("Fanfare2")
# ファンファーレ4
JACK_POT_ME4 = RPG::ME.new("Fanfare1")
# ファンファーレ5
JACK_POT_ME5 = RPG::ME.new("Item")
# ファンファーレ6
JACK_POT_ME6 = RPG::ME.new("Item")
# ハズレのME
LOOSE_ME = RPG::SE.new("WWL あかん!")
POS_MINI = Rect.new(4, 0, 160 - 32, 24)
POS_MINI_W = Rect.new(4, 0, 340, 24)
# 獲得時の文章
MG_NML_GET_GOLD = ["Get Gold!! %d", "Get Coin!! %d"]
# 消失時の文章
MG_NML_LOST_GOLD = ["Lost Gold! %d", "Lost Coin! %d"]
# 賭け金が所持金を上回る場合のエラーメッセージ
MG_ERR_BET_UPPER_ROOT = "%sが%sを上回ってます!!"
MG_ERR_BET_UPPER = [sprintf(MG_ERR_BET_UPPER_ROOT, BET_GOLD[0], HAVE_GOLD[0]),
sprintf(MG_ERR_BET_UPPER_ROOT, BET_GOLD[1], HAVE_GOLD[1])]
# 賭け金未設定のエラーメッセージ
MG_ERR_BET_ZERO_ROOT = "%sを設定してください!!"
MG_ERR_BET_ZERO = [sprintf(MG_ERR_BET_ZERO_ROOT, BET_GOLD[0]),
sprintf(MG_ERR_BET_ZERO_ROOT, BET_GOLD[1])]
# ベット方式定数
# 0:所持金 1:変数
MG_BET_TYPE_GOLD = 0
MG_BET_TYPE_COIN = 1
# コイン変数用変数インデックス
MG_COIN_INDEX = 21
# 獲得種別
# 0:獲得 1:消失
MG_GOLDCOIN_GET = 0
MG_GOLDCOIN_LOST = 1
#--------------------------------------------------------------------------
# ● 清算処理
# gold_coin : 獲得/消失金額、コイン
# get_type : 獲得種別 0:獲得 1:消失
# bet_type : ベット種別 0:所持金 1:コイン
#--------------------------------------------------------------------------
def get_lost_gold_coin(gold_coin, get_type, bet_type=0)
if !gold_coin.is_a?(Numeric) || gold_coin.to_i.to_s != gold_coin.to_s
msgbox("金額不正")
else
# ベット種別で分岐
case bet_type
when MG_BET_TYPE_GOLD
# 獲得種別で分岐
case get_type
when MG_GOLDCOIN_GET
$game_party.gain_gold(gold_coin)
when MG_GOLDCOIN_LOST
$game_party.lose_gold(gold_coin)
else
msgbox("不明な種別" + get_type.to_s)
end
when MG_BET_TYPE_COIN
# 獲得種別で分岐
case get_type
when MG_GOLDCOIN_GET
$game_variables[MG_COIN_INDEX] += gold_coin
when MG_GOLDCOIN_LOST
$game_variables[MG_COIN_INDEX] -= gold_coin
else
msgbox("不明な種別" + get_type.to_s)
end
else
msgbox("不明な種別" + bet_type.to_s)
end
end
end
end
module TITLE_BM
DRAW_COLOR = Color.new(200, 200, 220, 255)
end
#==============================================================================
# ■ Window_Coin
#------------------------------------------------------------------------------
# 所持金を表示するウィンドウです。
#==============================================================================
class Window_Coin < Window_Gold
include MINI_GAME
#--------------------------------------------------------------------------
# ● 所持コインの取得
#--------------------------------------------------------------------------
def value
$game_variables[MG_COIN_INDEX]
end
#--------------------------------------------------------------------------
# ● コイン単位の取得
#--------------------------------------------------------------------------
def currency_unit
COIN_UNIT
end
end
class Window_Title_Root < Window_Base
include TITLE_BM
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super(0, 0, 544, 48)
self.windowskin = Cache.system("Window")
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh(text)
contents.clear
root_color = contents.font.color
contents.font.color = DRAW_COLOR
draw_text(4, 0, 544 - 32, 24, text, 1)
contents.font.color = root_color
end
end
class Window_Info_Gold < Window_Base
include MINI_GAME
include TITLE_BM
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(type=0)
super(384, 48, 160, 48)
self.windowskin = Cache.system("Window")
refresh(type)
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh(type)
contents.clear
contents.font.color = system_color
draw_text(POS_MINI, HAVE_GOLD[type], 1)
end
end
class Window_Info_Bet < Window_Base
include MINI_GAME
include TITLE_BM
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(type=0)
super(384, 144, 160, 48)
refresh(type)
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh(type)
contents.clear
contents.font.color = system_color
draw_text(POS_MINI, BET_GOLD[type], 1)
end
end
class Window_Bet_Gold < Window_Base
include MINI_GAME
include TITLE_BM
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super(384, 192, 160, 48)
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh(bet)
contents.clear
draw_text(POS_MINI, bet.to_s, 2)
end
end
class Window_Info_Space < Window_Base
include MINI_GAME
include TITLE_BM
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super(0, 320 + 8, 384, 48)
self.windowskin = Cache.system("Window")
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh(text)
contents.clear
draw_text(POS_MINI_W, text)
end
end
class Window_Info_Space2 < Window_Base
include MINI_GAME
include TITLE_BM
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super(0, 320 + 8 - 48, 384, 48)
refresh(@cnt, @max)
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh(cnt, max)
contents.clear
if max != nil
curr = max.to_i - cnt.to_i
if curr != 0
text = "あと " + curr.to_s + " 枚交換可能です。"
else
text = " "
end
else
text = cnt
end
draw_text(POS_MINI_W, text)
end
end
class Scene_Minigame_Base < Scene_Base
include MINI_GAME
#--------------------------------------------------------------------------
# ● メインウィンドウ作成
#--------------------------------------------------------------------------
def create_main_window
@title_window = Window_Title_Root.new
end
#--------------------------------------------------------------------------
# ● ボトムキーヘルプウィンドウ作成
#--------------------------------------------------------------------------
def create_bkh_window
@bottomkeyhelp_window = Window_BottomKeyHelp.new
end
#--------------------------------------------------------------------------
# ● インフォウィンドウ作成
#--------------------------------------------------------------------------
def create_info_window
@info_window = Window_Info_Space.new
end
#--------------------------------------------------------------------------
# ● ゴールドウィンドウ作成
#--------------------------------------------------------------------------
def create_gold_window(type=0)
@gold_info_window = Window_Info_Gold.new(type)
if type == MG_BET_TYPE_GOLD
@gold_window = Window_Gold.new
else
@gold_window = Window_Coin.new
end
@gold_window.x = 384
@gold_window.y = 96
end
#--------------------------------------------------------------------------
# ● ベットウィンドウ作成
#--------------------------------------------------------------------------
def create_bet_window(type=0)
@bet_info_window = Window_Info_Bet.new(type)
@bet_window = Window_Bet_Gold.new
end
#--------------------------------------------------------------------------
# ● 数値入力ウィンドウ作成
#--------------------------------------------------------------------------
def create_value_window
@value_window_r = Window_Base.new(544 / 2 - 240 / 2, 200, 240, 64)
$game_message.num_input_digits_max = MAX_DIG
@value_window = Window_NumberInput_XP.new(@value_window_r)
@value_window.start
@value_window.z = 1000
@value_window_r.windowskin = nil
@value_window.x = 200
@value_window.y = 200
value_window_deactivate
end
#--------------------------------------------------------------------------
# ● ミニゲーム用ウィンドウ作成
#--------------------------------------------------------------------------
def create_minigame_window(type=0)
create_main_window
create_bkh_window
create_info_window
create_gold_window(type)
create_bet_window(type)
create_value_window
end
#--------------------------------------------------------------------------
# ● 数値入力ウィンドウ非表示
#--------------------------------------------------------------------------
def value_window_deactivate
@value_window.hide
@value_window_r.hide
@value_window.deactivate
end
#--------------------------------------------------------------------------
# ● 数値入力ウィンドウ表示
#--------------------------------------------------------------------------
def value_window_activate
@value_window.show
@value_window_r.show
@value_window.activate
end
end
|