ミニゲーム:こいこい風ポーカー



花札のこいこいとポーカーを組み合わせたゲームです。

$scene = Scene_F_card.new
にてゲーム開始。

※以下のモジュール/スクリプトが別途導入必要です。
 縁取り文字
 ミニゲーム用共通処理モジュール
 貪藻矢射妥←ダイヤモンドベースモジュール
 ボトムキーヘルプ
 VXA風SE
 Window VXA

変更点
2012:01:21
・エラーメッセージを共通処理モジュールへ移動

2012:03:03
・一部の共通モジュールのクラス化

2013:06:01
・カードの配列をひとまとめに
・一部の共通モジュールのクラス化 part2
・オーディオファイルの設定を変更

2015:10:01
・VXA風Sound対応

2020:09:03
・Window VXA対応

#==============================================================================
# ミニゲーム:こいこい風ポーカー By 貪藻矢射妥←
#------------------------------------------------------------------------------
# こいこい風ポーカー
# 
# $scene = Scene_F_card.new
# にてゲームを開始できます。
# 
# スーパーポーカーと違って何デッキも使用した場合、役がめちゃくちゃになるので
# 今回は1デッキのみを使用します。
# 
# ちなみに、以下は分かりやすいんだか分かりにくいんだかわからない花札カード一覧
# 
#     | 松| 梅| 桜| 藤| 殺| 釦| 萩| 芒| 菊| 椛| 柳| 桐|
# ----+---+---+---+---+---+---+---+---+---+---+---+---+
# 20点| 0 | - | 0 | - | - | - | - | 0 | - | - | 0 | 0 | <- 光
# ----+---+---+---+---+---+---+---+---+---+---+---+---+
# 10点| - | 0 | - | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | - | <- たね
# ----+---+---+---+---+---+---+---+---+---+---+---+---+
#  5点| 1 | 1 | 1 | 1 | 1 | 1 | 1 | - | 1 | 1 | 2 | - | <- 短冊
# ----+---+---+---+---+---+---+---+---+---+---+---+---+
#  1点|2,3|2,3|2,3|2,3|2,3|2,3|2,3|2,3|2,3|2,3| 3 |1-3| <- カス
# ----+---+---+---+---+---+---+---+---+---+---+---+---+
# ※菖蒲を殺(あや・め)、牡丹を釦(ぼたん)と表記しています。
# 
# ※役の追加はちょっと面倒なので、必要あれば連絡してください。
# 
# ※対戦形式にするのはコンピュータ側の戦略を考えるのが面倒なので、あくまで
#  しつz・・・じゃなかった一人遊び用です。
# 
#==============================================================================
# 変更履歴
# 
# 2012:01:21
# ・エラーメッセージを共通処理モジュールへ移動
# 
# 2012:03:03
# ・一部の共通モジュールのクラス化
# 
# 2013:06:02
# ・カードの配列をひとまとめに
# ・一部の共通モジュールのクラス化 part2
# ・オーディオファイルの設定を変更
# 
# 2015:10:01
# ・VXA風Sound対応
# 
# 2020:09:03
# ・Window VXA対応

module HANAFUDA
  # トランプの図柄セット
  CARD_ROOT="fc_set"
  # トランプ一枚のサイズ
  TR_WIDTH  = 64
  TR_HEIGHT = 100
  #--------------------------------------------------------------------------
  # 花札セッティング
  #--------------------------------------------------------------------------
  def set_hanafuda
    $card = [[], [], [], []]
    for i in 0...4
      for j in 0...13
        # 0の場合、カードの裏を設定(未使用)
        if j == 0
          $card[i][j] = Rect.new(12 * TR_WIDTH, 0, TR_WIDTH, TR_HEIGHT)
        # それ以外の場合
        else
          $card[i][j] = Rect.new((j - 1) * TR_WIDTH, i * TR_HEIGHT, 
                                 TR_WIDTH, TR_HEIGHT)
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # 重複しない乱数を造る。
  # ・・・実は今まで、乱数を無限に発生させ、それを配列に格納していって、
  # 次に作成する乱数が格納した配列に無い乱数だったら・・・ってのを繰り返して
  # 造ろうとして大挫折。
  # ・・・はじめに連続する数値の配列を作成して、ランダムにシャッフルすれば
  # よかったのね・・・orz・・・
  #--------------------------------------------------------------------------
  def change_make_rnd
    $rand_list = []
    cnt1 = 0
    cnt2 = 1
    for i in 0...48
      $rand_list[i] = [cnt1, cnt2]
      cnt2 += 1
      if cnt2 == 13
        cnt2 = 1
        cnt1 += 1
      end
    end
    
    for j in 0...50
      rnd1 = rand(48)
      rnd2 = rand(48)
      if rnd1 != rnd2
        tmp = $rand_list[rnd1]
        $rand_list[rnd1] = $rand_list[rnd2]
        $rand_list[rnd2] = tmp 
      end
    end
  end
  
  # 最大交換回数
  CHANGE_MAX = 15
end

module LL_SET
  # こいこい役設定集?
  # 四光
  FIL_LIST  = [[ 0,  1], [ 0,  3], [ 0,  8], [ 0, 12]]
  # 猪鹿蝶
  ISC_LIST  = [[ 0,  6], [ 0,  7], [ 0, 10]]
  # 赤短
  RED_LIST  = [[ 1,  1], [ 1,  2], [ 1,  3]]
  # 青短
  BLUE_LIST = [[ 1,  6], [ 1,  9], [ 1, 10]]
  # 草短
  WEED_LIST = [[ 1,  4], [ 1,  5], [ 1,  7]]
  # たね
  SEED_LIST = [[ 0,  2], [ 0,  4], [ 0,  5], [ 0,  6], [ 0,  7], [ 1,  8], 
               [ 0,  9], [ 0, 10], [ 1, 11]]
end

class Game_System
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :fc_set                   # ポーカーハンド変数セット
end

class Window_Flower_Card < Window_Selectable
  include LL_SET
  include TITLE_BM
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    super(0, 64, 480 - 10, 380 - 128)
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh(cards)
    clear
    
    @list = []
    for card in cards
      @list.push([card[0].to_i, card[1].to_i])
    end
    
    draw_fcard
  end
  include HANAFUDA
  #--------------------------------------------------------------------------
  # ● 花札の描画
  #--------------------------------------------------------------------------
  def draw_fcard
    self.contents.clear
    
    for i in 0..4
      draw_card($card[@list[i][0]][@list[i][1]], 15 + i * 80, 30)
    end
  end
  #--------------------------------------------------------------------------
  # ● グラフィックの描画
  #--------------------------------------------------------------------------
  def draw_card(card, x, y, opacity = MAX8BIT)
    @cw = card.width
    self.contents.stretch_blt(Rect.new(x, y, TR_WIDTH, TR_HEIGHT), 
                              RPG::Cache.picture(CARD_ROOT), 
                              card, opacity)
  end
  #--------------------------------------------------------------------------
  # ● 花札の交換
  #--------------------------------------------------------------------------
  def card_change(index)
    if @add == nil
      @add = 0
    end
    
    @list[index] = $rand_list[5 + @add]
    @add += 1
    if @add > CHANGE_MAX
      @add = 0
    end
    draw_fcard
  end
  #--------------------------------------------------------------------------
  # ● カーソルアップデート準備
  #--------------------------------------------------------------------------
  def cu_update(index)
    @index = index
    @cursor_width = @cw
    update_cursor_rect
  end
  #--------------------------------------------------------------------------
  # ● カーソルの矩形更新
  #--------------------------------------------------------------------------
  def update_cursor_rect
    # カーソル位置が 0 未満の場合
    if @index < 0
      self.cursor_rect.empty
      return
    end
    # カーソルの座標を計算
    x = 10 + @index * 80
    y = 30 - 8
    # カーソルの矩形を更新
    self.cursor_rect.set(x, y, @cursor_width + 16, 100 + 16)
  end
  #--------------------------------------------------------------------------
  # ● こいこい役判定
  #--------------------------------------------------------------------------
  def fcard_judg
    @tmp_set = {
      "pt_20"    => 0,
      "rain_20"  => 0,
      "alcl"     => 0,
      "red_sht"  => 0,
      "blue_sht" => 0,
      "weed_sht" => 0,
      "isc"      => 0,
      "seed"     => 0,
      "moon"     => 0,
      "flower"   => 0,
      "crane"    => 0,
      "plum"     => 0
    }
    
    for i in 0...@list.size
      if FIL_LIST.include?(@list[i])
        @tmp_set["pt_20"] += 1
      end
      if ISC_LIST.include?(@list[i])
        @tmp_set["isc"] += 1
      end
      if RED_LIST.include?(@list[i])
        @tmp_set["red_sht"] += 1
      end
      if BLUE_LIST.include?(@list[i])
        @tmp_set["blue_sht"] += 1
      end
      if WEED_LIST.include?(@list[i])
        @tmp_set["weed_sht"] += 1
      end
      if SEED_LIST.include?(@list[i])
        @tmp_set["seed"] += 1
      end
      
      if @list[i] == [ 0,  1]
        @tmp_set["crane"] += 1
      end
      if @list[i] == [ 0,  2]
        @tmp_set["plum"] += 1
      end
      if @list[i] == [ 0,  3]
        @tmp_set["flower"] += 1
      end
      if @list[i] == [ 0,  8]
        @tmp_set["moon"] += 1
      end
      if @list[i] == [ 0,  9]
        @tmp_set["alcl"] += 1
      end
      if @list[i] == [ 0, 11]
        @tmp_set["rain_20"] += 1
      end
    end
    
    $game_system.fc_set[1] = 0
    $game_system.fc_set[0] = "役無し"
    
    if @tmp_set["pt_20"] == 4
      if @tmp_set["rain_20"] == 1
        $game_system.fc_set = ["五光", 200]
      else
        $game_system.fc_set = ["四光", 150]
      end
    end
    if @tmp_set["pt_20"] == 3
      if @tmp_set["rain_20"] == 1
        $game_system.fc_set = ["雨四光", 125]
      else
        $game_system.fc_set = ["三光", 105]
      end
    end
    if @tmp_set["red_sht"] + @tmp_set["blue_sht"] + @tmp_set["weed_sht"] == 5
      $game_system.fc_set = ["五短", 60]
    end
    if @tmp_set["seed"] == 5
      $game_system.fc_set = ["たね", 0]
    end
    # 追加、組み合わせ役
    if @tmp_set["crane"] == 1 && @tmp_set["plum"] == 1 && @tmp_set["flower"] == 1
      $game_system.fc_set[1] += 80
      if $game_system.fc_set[0] == "役無し"
        $game_system.fc_set[0] = "表菅原"
      else
        $game_system.fc_set[0] += "・表菅原"
      end
    end
    if @tmp_set["flower"] == 1 && @tmp_set["moon"] == 1 && @tmp_set["alcl"] == 1
      $game_system.fc_set[1] += 80
      if $game_system.fc_set[0] == "役無し"
        $game_system.fc_set[0] = "月花酒"
      else
        $game_system.fc_set[0] += "・月花酒"
      end
    end
    if @tmp_set["isc"] == 3
      $game_system.fc_set[1] += 75
      if $game_system.fc_set[0] == "役無し"
        $game_system.fc_set[0] = "猪鹿蝶"
      else
        $game_system.fc_set[0] += "・猪鹿蝶"
      end
    end
    if @tmp_set["red_sht"] == 3
      $game_system.fc_set[1] += 70
      if $game_system.fc_set[0] == "役無し"
        $game_system.fc_set[0] = "赤短"
      else
        $game_system.fc_set[0] += "・赤短"
      end
    end
    if @tmp_set["blue_sht"] == 3
      $game_system.fc_set[1] += 70
      if $game_system.fc_set[0] == "役無し"
        $game_system.fc_set[0] = "青短"
      else
        $game_system.fc_set[0] += "・青短"
      end
    end
    if @tmp_set["weed_sht"] == 3
      $game_system.fc_set[1] += 55
      if $game_system.fc_set[0] == "役無し"
        $game_system.fc_set[0] = "草短"
      else
        $game_system.fc_set[0] += "・草短"
      end
    end
    if @tmp_set["flower"] == 1 && @tmp_set["alcl"] == 1 && @tmp_set["moon"] == 0
      $game_system.fc_set[1] += 55
      if $game_system.fc_set[0] == "役無し"
        $game_system.fc_set[0] = "花見酒"
      else
        $game_system.fc_set[0] += "・花見酒"
      end
    end
    if @tmp_set["moon"] == 1 && @tmp_set["alcl"] == 1 && @tmp_set["flower"] == 0
      $game_system.fc_set[1] += 55
      if $game_system.fc_set[0] == "役無し"
        $game_system.fc_set[0] = "月見酒"
      else
        $game_system.fc_set[0] += "・月見酒"
      end
    end
    if @tmp_set["plum"] == 1 && @tmp_set["alcl"] == 1
      $game_system.fc_set[1] += 50
      if $game_system.fc_set[0] == "役無し"
        $game_system.fc_set[0] = "梅見酒"
      else
        $game_system.fc_set[0] += "・梅見酒"
      end
    end
  end
end

class Scene_F_card
  include BM
  include HANAFUDA
  include MINI_GAME
  #--------------------------------------------------------------------------
  # ● スーパーポーカー初期化
  #--------------------------------------------------------------------------
  def fcard_init(flg = true)
    $game_system.fc_set = [0, 0]
    @start_flg = false
    @set_flg = false
    @bet_gold = 0
    @index = 0
    @change = 0
    @sp_cards = [[0, 0], [1, 0], [2, 0], [3, 0], [0, 0]]
    change_make_rnd
    set_hanafuda
    if flg == true
      @fcard_window.refresh(@sp_cards)
    end
  end
  #--------------------------------------------------------------------------
  # ● 花札 清算
  #--------------------------------------------------------------------------
  def get_gold
    get = Integer(@bet_gold * $game_system.fc_set[1])
    if get > MAX_GOLD
      get = MAX_GOLD
    end
    if get > 0
      $game_party.gain_gold(get)
      text = GET_GOLD + get.to_s
      @info_window.refresh(text)
    else
      $game_party.lose_gold(@bet_gold)
      text = LOST_GOLD + @bet_gold.to_s
      @info_window.refresh(text)
    end
    
    if $game_system.fc_set[1] >= 200
      se = JACK_POT_ME6
    elsif $game_system.fc_set[1] >= 150
      se = JACK_POT_ME4
    elsif $game_system.fc_set[1] >= 100
      se = JACK_POT_ME2
    elsif $game_system.fc_set[1] >= 50
      se = JACK_POT_ME1
    else
      se = LOOSE_ME
    end
    
    @change_info_window.refresh($game_system.fc_set[0], nil)
    
    if se == LOOSE_ME
      $game_system.se_play(se)
    else
      $game_system.me_play(se)
    end
    
  end
  
  #--------------------------------------------------------------------------
  # ○ キーヘルプを設定
  #--------------------------------------------------------------------------
  def set_keyhelp1
    @bottomkeyhelp_window.clear
    @bottomkeyhelp_window.set_bottom_help({"B"=>"キャンセル", 
                                           "A"=>"コインベット", 
                                           "C"=>"ゲーム開始"})
  end
  #--------------------------------------------------------------------------
  # ○ キーヘルプを設定 2
  #--------------------------------------------------------------------------
  def set_keyhelp2
    @bottomkeyhelp_window.clear
    @bottomkeyhelp_window.set_bottom_help({"←→"=>"交換選択", 
                                           "C"   =>"カード交換", 
                                           "X"   =>"勝負", 
                                           "B"   =>"キャンセル"})
  end
  #--------------------------------------------------------------------------
  # ○ キーヘルプを設定 3
  #--------------------------------------------------------------------------
  def set_keyhelp3
    @bottomkeyhelp_window.clear
    @bottomkeyhelp_window.set_bottom_help({"矢印"=>"ベット", 
                                           "C"   =>"決定", 
                                           "B"   =>"キャンセル"})
  end
  
  #--------------------------------------------------------------------------
  # ● メイン処理
  #--------------------------------------------------------------------------
  def initialize
    @bottomkeyhelp_window = Window_BottomKeyHelp.new
    set_keyhelp1
  end
  
  def main
    # ウィンドウを作成
    @title_window = Window_Title_Root.new
    
    @fcard_window = Window_Flower_Card.new
    
    @change_info_window = Window_Info_Space2.new
    
    @info_window = Window_Info_Space.new
    
    @gold_info_window = Window_Info_Gold.new
    
    @gold_window = Window_Gold.new
    @gold_window.x = 480 - 10
    @gold_window.y = 128
  
    @bet_info_window = Window_Info_Bet.new  
    
    @bet_window = Window_Bet_Gold.new
    
    @value_window2 = Window_Base.new(200, 200, 240, 64)
    @value_window2.z = 1000
    @value_window = Window_InputNumber.new(MAX_DIG)
    @value_window.x = 200
    @value_window.y = 200
    
    @value_window2.hide
    @value_window.hide
    @value_window.deactivate
    
    fcard_init
    
    @title_window.refresh("こいこい風ポーカー")
    @bet_window.refresh(@bet_gold)
    
    # トランジション実行
    Graphics.transition
    # メインループ
    loop do
      
      if @start_flg == true
        if @set_flg == false
          @sp_cards = [$rand_list[0], $rand_list[1], $rand_list[2], 
                       $rand_list[3], $rand_list[4]]
          @fcard_window.refresh(@sp_cards)
          @set_flg = true
        end
      end
      
      # ゲーム画面を更新
      Graphics.update
      # 入力情報を更新
      Input.update
      # フレーム更新
      update
      # 画面が切り替わったらループを中断
      if $scene != self
        break
      end
    end

    # トランジション準備
    Graphics.freeze
    # ウィンドウを解放
    @title_window.dispose
    @fcard_window.dispose
    @gold_window.dispose
    @bet_window.dispose
    @value_window.dispose
    @value_window2.dispose
    @info_window.dispose
    @gold_info_window.dispose
    @bet_info_window.dispose
    @change_info_window.dispose
    @bottomkeyhelp_window.dispose
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    if @fcard_window.active
      update_main
      return
    end
    if @value_window.active
      @value_window.number = @bet_gold
      update_value
      return
    end
  end
  
  #--------------------------------------------------------------------------
  # ● フレーム更新 (メインウィンドウがアクティブの場合)
  #--------------------------------------------------------------------------
  def update_main
    # B ボタンが押された場合
    if Input.trigger?(Input::B)
      # キャンセル SE を演奏
      Sound.play_cancel
      if @start_flg == true
        @fcard_window.cu_update(-1)
        set_keyhelp1
        @start_flg = false
      else
        $game_system.windowskin_name = WINDOW_SKIN_ROOT
        $scene = Scene_Map.new
      end
      return
    end
    if @start_flg == false
      # A ボタンが押された場合
      if Input.trigger?(Input::A)
        # 決定 SE を演奏
        Sound.play_ok
        # 念の為
        @fcard_window.refresh(@sp_cards)
        @value_window.show
        @value_window.activate
        @value_window2.show
        @fcard_window.deactivate
        set_keyhelp3
        return
      end
    end
    if @start_flg == true
      # X ボタンが押された場合
      if Input.trigger?(Input::X)
        # 決定 SE を演奏
        Sound.play_ok
        @fcard_window.fcard_judg
        get_gold        
        fcard_init(false)
        @bet_window.refresh(@bet_gold)
        @gold_window.refresh
        @fcard_window.cu_update(-1)
        set_keyhelp1
        return
      end
      # 方向ボタンの右が押された場合
      if Input.repeat?(Input::RIGHT)
        Sound.play_cursor
        if @index == 4
          @index = 0
        else
          @index += 1
        end
        @fcard_window.cu_update(@index)
      end
      # 方向ボタンの左が押された場合
      if Input.repeat?(Input::LEFT)
        Sound.play_cursor
        if @index == 0
          @index = 4
        else
          @index -= 1
        end
        @fcard_window.cu_update(@index)
      end
    end
    
    # C ボタンが押された場合
    if Input.trigger?(Input::C)
      if @bet_gold == 0
        # エラー SE を演奏
        $game_system.se_play(ERROR_SE)
        text =  "まずは" + MG_ERR_BET_ZERO
        @info_window.refresh(text)
      else
        # 決定 SE を演奏
        Sound.play_ok
        @info_window.refresh("")
        @change_info_window.refresh(@change, CHANGE_MAX)
        if @start_flg == false
          @start_flg = true
          @fcard_window.cu_update(@index)
          set_keyhelp2
        elsif @start_flg == true
          @change += 1
          @change_info_window.refresh(@change, CHANGE_MAX)
          @fcard_window.card_change(@index)
          @fcard_window.cu_update(@index)
        end
        if @change == CHANGE_MAX
          @fcard_window.fcard_judg
          get_gold
          fcard_init(false)
          @bet_window.refresh(@bet_gold)
          @gold_window.refresh
          @fcard_window.cu_update(-1)
          set_keyhelp1
        end
        return
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (バリューウィンドウがアクティブの場合)
  #--------------------------------------------------------------------------
  def update_value
    #refresh
    # C ボタンが押された場合
    if Input.trigger?(Input::C)
      if @bet_gold > $game_party.gold
        # エラー SE を演奏
        $game_system.se_play(ERROR_SE)
        @info_window.refresh(MG_ERR_BET_UPPER)
      elsif @bet_gold == 0
        # エラー SE を演奏
        $game_system.se_play(ERROR_SE)
        @info_window.refresh(MG_ERR_BET_ZERO)
      else
        # 決定 SE を演奏
        Sound.play_ok
        @info_window.refresh("")
        @value_window.hide
        @value_window.deactivate
        @value_window2.hide
        @fcard_window.activate
        @bet_window.refresh(@bet_gold)
        set_keyhelp1
      return
      end
    end
    # B ボタンが押された場合
    if Input.trigger?(Input::B)
      # キャンセル SE を演奏
      Sound.play_cancel
      @value_window.hide
      @value_window.deactivate
      @value_window2.hide
      @fcard_window.activate
      set_keyhelp1
      return
    end
    # Window_InputNumberに処理を移す
    @value_window.update
    @bet_gold = @value_window.number
  end
end
こぉんな感じになります。 使用画像はこちら 上記画像のどうでもいい一言解説
鷹屋さん
ハルヒちゃん
トリィ
ガンダムSEED
黒桜(どこが?)
Fate
クァバーゼ
クロボン
菖蒲と生八橋 月光蝶
∀ガンダム
ボニーちゃん
ブリーチ
ガンダムX
ガンダムX
菊一文字則宗 鹿キョン
ハルヒ
レイン
Gガンダム
-
- - - - - - - コルニグス
クロボン・鋼鉄の七人
- - セラと燕返し
これゾン
-
- - - - - - - - - - - -
- - - - - - - - - - - -
カスタマイズポイントの設定
変数 設定例 説明
CHANGE_MAX 15 カードを交換できる最大枚数
MAX_DIG 7 入力金額最高桁数

戻る