#============================================================================== # RGSS2_シンプルカードゲーム2拡張 敵デッキ作成サポート # 2011/12/21公開 # 2011/12/24いろいろと修正 # C Winter (http://ccwinter.blog.fc2.com/) #============================================================================== #============================================================================== # ■ Game_Party #============================================================================== class Game_Party < Game_Unit #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :snatched_card_list end #============================================================================== # ■ Scene_Title #============================================================================== class Scene_Title < Scene_Base #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- alias card_snatch_command_new_game command_new_game def command_new_game $game_party.snatched_card_list = [] card_snatch_command_new_game end end #============================================================================== # ■ Game_Party #============================================================================== class Game_Party < Game_Unit #-------------------------------------------------------------------------- # ● アクティブデッキを設定する #-------------------------------------------------------------------------- def set_active_deck(index) @active_deck = index $use_deck = index end #-------------------------------------------------------------------------- # ● 装備カードの消去 # index : デッキ番号 # equip_type : カードスロット番号 #-------------------------------------------------------------------------- def lose_card(index, equip_type) @deck[index][equip_type] = 0 end #-------------------------------------------------------------------------- # ● アイテムの増加 (減少) # id : アイテムID # n : 個数 #-------------------------------------------------------------------------- def gain_card(id, n) number = item_number($data_items[id]) @items[id] = [[number + n, 0].max, 99].min end end #============================================================================== # ■ Game_Duel #============================================================================== class Game_Duel #-------------------------------------------------------------------------- # ● セットアップ #-------------------------------------------------------------------------- alias card_snatch_setup setup def setup(enemy, name) card_snatch_setup(enemy, name) $enemy_deck = enemy end end #============================================================================== # ■ スクリプトコマンド #============================================================================== module CARD module Commands module_function def lose_snatch_card n = rand(3) item_id = $game_party.deck($use_deck)[n] p "勝負したデッキの番号",$use_deck + 1, "デッキのカードのID",$game_party.deck($use_deck), "奪われたカードのデッキ中での順番",n + 1, "奪われたカードのアイテムID",item_id, "奪われたカードの名前",$data_items[item_id].name if $TEST $game_variables[100] = $data_items[item_id].name $game_party.lose_card($use_deck, n) $game_party.snatched_card_list.push(item_id) $game_party.snatched_card_list = list_sort($game_party.snatched_card_list) end def win_snatch_card n = rand(3) item_id = $enemy_deck[n] p "デッキのカードのID",$enemy_deck, "奪ったカードのデッキ中での順番",n + 1, "奪ったカードのアイテムID",item_id, "奪ったカードの名前",$data_items[item_id].name if $TEST $game_variables[100] = $data_items[item_id].name $game_party.gain_card(item_id, 1) end def having_card_list #所持及び装備中のカードを返す list = [] for item in $game_party.items next if item == nil or not item.card? list.push(item.id) end for i in 0...CARD::DECK_MAX list += $game_party.deck(i) end return list_sort(list) end def list_sort(list) #重複しているカード、nilを取り除く new_list = list.compact return new_list.uniq end def rarity_pick_up(list, rarity) #指定したレアリティのカードだけを返す new_list = [] list = list.compact #nilを取り除く for id in list card = $data_items[id] new_list.push(id) if rarity.include?(card.speed) end return new_list end def pick_up_rundom(list, n) #与えられた配列からランダムでn枚返す new_list = [] random_list = list.sort_by{rand} #順番を並べ替える random_list = random_list.compact #nilを取り除く for i in 0...n #nが3なら0,1,2の3回 new_list.push(random_list[i]) new_list[i] = random_list[0] if new_list[i] == nil #listが足りない場合 end return new_list end end end class Game_Interpreter include CARD::Commands end #============================================================================== # ■ Scene_Card #============================================================================== class Scene_Card < Scene_Base #-------------------------------------------------------------------------- # ● メッセージ表示が終わるまでウェイト #-------------------------------------------------------------------------- def wait_for_message while(1) update_basic break if Input.trigger?(Input::C) break if Input.press?(Input::X) if $TEST end end end