#!/usr/bin/env ruby # -*- coding: utf-8 -*- ability = [20,3,8,5,5,20,15,1] #能力値最大 #HP(0体力)MP(1魔力)ATS(2攻撃力)MAT(3魔法攻撃力)DEF(4防御力)DEX(5素早さ)AGI(6器用さ)LUK(7運) current = [20,3] #現在の能力値 lv = [1,0] #レベル関連 #Lv(レベル)EXP(経験値) g = 0 select = 0 advance = 0 gamedescription = ["ゲーム説明","このゲームはメニューで行動を選択して遊びます", "ステータスを見る・宿屋へ行く・武器屋へ行く・教会へ行く・探索へ行くの中から好きなのを選びます", "ステータスを見るは今の自分のステータスを見ることができます", "HP=体力 MP=魔力・魔法防御力 ATS=攻撃力 MAT=魔法攻撃力 DEF=防御力 DEX=素早さ AGI=器用さ LUK=運", "宿屋はGを支払うとHP・MPが回復します", "武器屋は武器・防具を購入することができます", "教会はセーブをすることができます", "探索は魔物の生息地に行き 戦いをします", "戦いは行動を選択して魔物を倒します", "死んでしまったら'GAMEOVER'でGを失い村・街からやり直しです", "目標は魔王を倒すこと!", "じゃぁクリア目指して頑張ってね", "※このゲームは共同制作作品です"] prorogu = ["\e[96m_me_:う、うっ", "\e[96;2m(強い頭痛を感じ_jibun_は意識を失った)", "\e[96;2m(目覚めると そこは見知らぬ村だった)", "\e[96m_me_:こ、ここは どこ?", "\e[96;2m(その瞬間すべてを思い出した)", "\e[96;2m(剣術や魔法 世界のことわり)", "\e[96;2m(そして魔王を倒さなければ ならないという強い使命感を覚えた)", "\e[96m_me_:魔王を倒さなければ", "\e[96m_me_:なぜだか わからないけど そんな気がする", "\e[96m_me_:あっ そして ここは どこなんだろう", "\e[96m_me_:そこの お方 ここが どこか わかりますか", "\e[2m村人:何いってるんだい?", "\e[2m村人:ここは「パクス村」ディーヴァス川のほとりにある小さな農村さ", "\e[2m村人:ここが初めてなら注意しておくけど「ポルタ平原」には魔物が出るから用意なしには行くなよ", "\e[2m村人:じゃぁな", "\e[96m_me_:とりあえずポルタ平原を探索しようかな"] #最初の会話シーン credit = ["スタッフロール(クレジットタイトル)","システム","村井侑平 澤田羽衣", "システムアドバイザー","佐藤隆之助 阿部光峻", "広瀬雄二様 東北公益文科大学の皆様", "シナリオ","村井侑平 高橋真翔 佐藤風斗 佐藤然", "シナリオアドバイザー","佐藤隆之助 澤田羽衣 疋田琉莉 阿部光峻", "グラフィック","澤田羽衣", "この作品に関わった すべての方に感謝の意を申し上げます", "制作","「#みんなでゲームを作ろう」の会"] battleselect = ["攻撃","アイテム","逃げる"] attack = ["剣技","魔法"] sword = [""] #攻撃名 sworddetail = [[]] #攻撃の詳細 magic = [""] #魔法名 magicdetail = [[]] #魔法の詳細 monster = ["スライム","デーモンビースト","黒い影","\e[93mゴールデンスライム"] enemy = [[12,12,8,8,4,0,3,10,8,0,3,3,4], [15,15,5,5,10,0,5,25,15,0,7,4,2], [8,8,15,15,0,8,20,35,25,3,13,2], [12,12,20,20,6,0,30,8,8,0,30,23]] status = [] #[名前、性別、一人称etc.] item = [] area = [] sentaku = ["プレイ","ゲーム説明","クレジットタイトル"] q1 = ["男","女"] #変数名の最初は大文字NG q2 = ["俺","僕","私"] yadoya = ["泊まる(10G)","泊まらない"] kyokai = ["祈りを捧げる(セーブ)","聖水を買う(20G)"] def status(status,ability,current,nani,lv,g) x = 0 puts" ステータス" for i in nani[0] #i = ["名前","性別","一人称"] printf("%s:%s ",i,status[x]) #名前性別一人称 x += 1 end x = 0 printf("Lv%s ",lv[0]) printf("EXP:%d ",lv[1]) printf("所持金:%dG",g) print("\n") for i in nani[2] printf("%s:%d/%d ",i,ability[x],current[x]) x += 1 end x = 2 for i in nani[3] printf("%s:%d ",i,ability[x]) x += 1 end print("\n\n") end def question(situmon,list) #質問を出すメソッド kaisu = 0 select = -1 while kaisu < list.length printf("%s(%d)\n",list[kaisu],kaisu) print("\e[m") kaisu += 1 end while select < 0 || select >= list.length #回答の仕分け print(situmon+":") select = gets if select == "\n" redo end select = select.to_i end return list[select] #ただ見やすくしてる end def query(situmon,list) #質問を出すメソッド kaisu = 0 select = -1 while kaisu < list.length printf("%s(%d)\n",list[kaisu],kaisu) print("\e[m") kaisu += 1 end while select < 0 || select >= list.length #回答の仕分け print(situmon+":") select = gets if select == "\n" redo end select = select.to_i end return select #数字版 end def dot1(time,kaisu) #「.」のためにいろいろ打ちたくなかったのメソッド for i in 1..kaisu sleep(time) print(".") end end def dot2(time,kaisu) #「.」のためにいろいろ打ちたくなかったのメソッド for i in 1..kaisu sleep(time) print("=") end end def description(hanasi) for i in hanasi puts(i) print("\e[m") gets end end def story(hanasi,status) #物語のgetsをサボりたいのメソッド for i in hanasi puts(i.sub("_me_", status[0]) #subがiのキーワードを .sub("_jibun_", status[2]) #特定の文字に .sub("_seibetu_", status[1])) #置き換えてくれる print("\e[m") gets end end def encounter(probability) encounter = probability[rand(probability.length)] end def enemyturn(monster,enemy,ability,current) data = [] if rand(((enemy[4]*1.5).round) + 1) < rand(enemy[5] + 1) data << enemymagic(monster,enemy,ability,current) if rand(enemy[8]*2 + enemy[7] + (enemy[9]/2).round) > rand(((ability[7]*2 + ability[8] + (ability[9]/2).round)/2).round) return data end else data << enemyattack(monster,enemy,ability,current) if rand(enemy[8]*2 + enemy[7] + (enemy[9]/2).round) > rand(((ability[7]*2 + ability[8] + (ability[9]/2).round)/2).round) return data end end return 0 end def process1(data) if data[0] == 0 puts("攻撃失敗") elsif data[0] == "他" return data else printf("%dダメージ",data) end return data end def battle(monster,enemy,ability,current,item,status,nani,lv,g,sword,sworddetail,magic,magicdetail,battleselect) printf("%s\e[mが現れた\n",monster) print("戦闘") dot2(0.01,28) print("\n") while true if current[0] <= 0 return 0 #負け elsif enemy[0] <= 0 return 1 #勝ち end if ability[5] < enemy[7] data = enemyturn(monster,enemy,ability,current) process1(data) current[0] -= data[0] enemy[2] -= data[1] enemy[0] -= data[2] damage = myturn(monster,enemy,ability,current,item,status,nani,lv,g,sword,sworddetail,magic,magicdetail,battleselect) process1(data) enemy[0] -= data[0] current[2] -= data[1] current[0] -= data[2] elsif ability[5] = enemy[7] if 0 == rand(2) damage = myturn(monster,enemy,ability,current,item,status,nani,lv,g,sword,sworddetail,magic,magicdetail,battleselect) process1(data) enemy[0] -= data[0] current[2] -= data[1] current[0] -= data[2] data = enemyturn(monster,enemy,ability,current) process1(data) current[0] -= data[0] enemy[2] -= data[1] enemy[0] -= data[2] else data = enemyturn(monster,enemy,ability,current) process1(data) current[0] -= data[0] enemy[2] -= data[1] enemy[0] -= data[2] damage = myturn(monster,enemy,ability,current,item,status,nani,lv,g,sword,sworddetail,magic,magicdetail,battleselect) process1(data) enemy[0] -= data[0] current[2] -= data[1] current[0] -= data[2] end elsif ability[5] > enemy[5] damage = myturn(monster,enemy,ability,current,item,status,nani,lv,g,sword,sworddetail,magic,magicdetail,battleselect) process1(data) enemy[0] -= data[0] current[2] -= data[1] current[0] -= data[2] data = enemyturn(monster,enemy,ability,current) process1(data) current[0] -= data[0] enemy[2] -= data[1] enemy[0] -= data[2] end end end def enemymagic(monster,enemy,ability,current) data = [] if not enemy[2] == 0 printf("%sの攻撃\n",monster) mp = enemy[3]/10.round + rand(3) if mp > enemy[2] mp = enemy[2] elsif mp > 1000 mp = 1000 end data << (enemy[5] * (mp / 2) - current[2] / 2).round printf("%s!",enemy[12]) data << 0 return data else return [0,0,0] end end def enemyattack(monster,enemy,ability,current) data = [] printf("%sの攻撃\n",monster) data << enemy[4] - ability[4]/2.round printf("%s!",enemy[11]) data << 0 data << 0 return data end def myturn(monster,enemy,ability,current,item,status,nani,lv,g,sword,sworddetail,magic,magicdetail,battleselect) data = [] status(status,ability,current,nani,lv,g) select = question("行動…",battleselect) if select == "攻撃" if question("攻撃…",attack) == "剣技" select = puery("剣技…",sword) damage = ability[4] * swoeddetail[0][0] - ((enemy[6] / 2).round) if rand(enemy[8]*2 + enemy[7] + (enemy[9]/2).round) > rand(((ability[7]*2 + ability[8] + (ability[9]/2).round)/2).round) printf("%s!",sword) data << damage else data << 0 end end end end nani = [["名前","性別","一人称"],["Lv","EXP"],["HP","MP"],["ATS","MAT","DEF","DEX","AGI","LUK"], ["ステータスを見る","宿屋に行く","武器屋に行く","教会に行く","探索に行く"]] puts("RPG") select = question("選択",sentaku) if select == "ゲーム説明" print("\n") description(gamedescription) select = question("選択",sentaku) end if select == "クレジットタイトル" print("\n") description(credit) select = question("選択",sentaku) end if select == "プレイ" name = "\n" while name == "\n" #この辺少し変だから真似はよく見てやって puts("PL名を決めてください") print("name…") name = gets end name = name.chomp status << name status << question("性別を決めてください",q1) status << question("一人称を決めてください",q2) end puts("ゲームを起動します") sleep(1) print"Loading" dot1(0.5,3) sleep(1) print("\n\n") story(prorogu,status) advance += 1 area << "ポルタ平原" while true #今のところ見るだけ。選択肢の中身ができたらいじる puts(" メニュー") x = 0 y = question("行動…",nani[4]) #yはPLの回答を拾ってくる print("\n") if y == "ステータスを見る" status(status,ability,current,nani,lv,g) elsif y == "宿屋に行く" puts("村人:一泊10Gだよ") select = question("どうする",yadoya) if select == "泊まる(10G)" if g >= 10 g - 10 print"Sleeing" dot(0.5,3,) sleep(1) current[0] = ability[0] current[1] = ability[1] puts("また 来いよ") else puts("村人:ひやかしは帰れ!!") end else puts("村人:なんだ泊まんねーのかよ") end print("\n") elsif y == "探索に行く" select = question("どこに探索に行きますか",area) if select == "ポルタ平原" sleep(rand(3)) probability = encounter([0]*75 + [1]*15 + [2]*5 + [3]*5) game = battle(monster[probability],enemy[probability],ability,current,item,status,nani,lv,g,sword,sworddetail,magic,magicdetail,battleselect) if 0 == game #GAMEOVREのメソッド elsif 1 == game lv[1] += enemy[probability][10] + ((enemy[probability][10]/10).round * (rand(3) + 1) + (rand(3) + 1)) end end end end