#!/usr/bin/env ruby # -*- coding: utf-8 -*- require 'csv' require './Class_HERO' require './Module_DICE' require './Module_QUESTION' require './Class_DANGEON' require './Class_MONSTER' require './Class_ITEM' require './Class_OBJECT' require './Class_SKILL' require './Module_RPG_Tool' class MAIN include DICE include QUESTION include RPG_TOOL def initialize story = CSV.read("Story_Data.csv") @@story={} for i in story i[1..].length.times do |n| if i[n+1].include?("\\e") i[n+1].gsub!("\\e","\e") end end @@story[i[0]]=i[1..] end @@choices = {"プレイetc" => ["はじめから","つづきから","ゲーム説明"], "ロード" => ["ロードする","タイトルに戻る"] } @map = {"area" =>["ポルタ平原"], "city" => ["ポルタ村"], "ポルタ村" => ["リゲルの家"], "都市プライト"=>["宿屋","薬屋","教会"] } end def frist while true print"\e[2J\e[0;0H" puts"RPG.rb" @select = question(@@choices["プレイetc"],"moji") if @select == "はじめから" @hero=HERO.new(text_get("名前")) puts if @hero.status["name"]=="j2114" play_mold("tester") else talk(@@story["ポルタ村"]) puts"\"リゲルの家\"が行動可能範囲に追加されました" gets end @here=@map["city"][0] game_start end end end def play_mold(mold)#便利なモード if mold=="tester" @hero.status["G"]=5000 items_data=ITEM.new.items_data_getter for i in items_data.keys if items_data[i]["型"]=="武器" @hero.status["武器"] << i end end for i in items_data.keys if items_data[i]["型"]=="防具" @hero.status["防具"] << i end end elsif mold=="TESTER" else p "PRG.rbのplay_moldで設定されていないモードを検出" end end def game_start while true print"\e[2J\e[0;0H" puts"現在地:#{@here}" select=question(["メニュー"]+@map[@here]+["探索"]+["他の町に行く"]+["Exit"],"moji") if select=="メニュー" @hero.status=display(@hero.status) elsif select == "Exit" if last_confirmation(["\e[91m終了しますか\e[m","\e[91m本当に終了しますか\e[m"],["終了する","戻る"]) exit end elsif select == "探索" print"\e[2J\e[0;0H" puts"探索可能エリア" select=question(@map["area"]+["Back"],"moji") if select=="Back" redo else dangeon=DANGEON.new(select) dangeon_result=dangeon.dangeon_start(@hero) @hero=dangeon_result[0] if not dangeon_result[1].nil? for i in dangeon_result[1] if @map[i[0]].index(i[1]).nil? puts i.join(":")+"が行動可能場所に追加されました" @map[i[0]] << i[1] gets end end end end elsif select == "他の町に行く" city_list=[] for i in @map["city"] if i!=@here city_list << i end end if city_list==[] puts"移動可能な場所はありません" gets redo end select=question(city_list+["Back"],"moji") if select=="Back" redo end puts"#{select}に移動した" @here=select gets else object=OBJECT.new(select) @hero= object.building_activate(@hero,@here) end end end def text_get(name) while true print"\e[2J\e[0;0H" puts"初期設定"+"="*42 puts"#{name}を設定してください(15文字以内)" print("#{name}:") x = gets.chomp if x == "" || x.length>15 redo else print"\e[2J\e[0;0H" puts"初期設定"+"="*42 puts"#{name}を設定してください(15文字以内)" puts("#{x}で良いですか?") @select = question(["YES","NO"],"moji") puts if @select == "YES" return x elsif @select == "NO" redo end end end end def last_confirmation(text,choices) for i in text puts puts i if question(choices,"moji")==choices[-1] return false end end return true end end x=MAIN.new x.frist