Skip to content

Commit

Permalink
プラグイン Detatoko 修正
Browse files Browse the repository at this point in the history
generator.rb 内において、RGRB::Plugin::DiceRoll を部品のように使うようにした。
よって Detatoko の中で改めて dice_roll() を定義する必要がなくなる。
  • Loading branch information
koi-chan committed Mar 16, 2015
1 parent 06dccd5 commit 2b2f0d2
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions lib/rgrb/plugin/detatoko/generator.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# vim: fileencoding=utf-8

require 'rgrb/plugin/dice_roll/dice_roll_result.rb'
require 'rgrb/plugin/dice_roll/generator.rb'

module RGRB
module Plugin
# システム別専用プラグイン「でたとこサーガ」
module Detatoko
# Detatoko の出力テキスト生成器
class Generator
include DiceRoll

def initialize
@random = Random.new
@stances = [ '敵視', '宿命', '憎悪', '雲上', '従属', '不明' ]
@dice_roll_generator = DiceRoll::Generator.new
end

# スキルランクから判定値を算出します
Expand All @@ -24,13 +24,13 @@ def initialize
def skill_decision(skill_rank, calc, solid, flag)
case skill_rank
when 0
result = dice_roll(3, 6)
result = @dice_roll_generator.dice_roll(3, 6)
values = result.values.sort.shift(2)
when 1
result = dice_roll(2, 6)
result = @dice_roll_generator.dice_roll(2, 6)
values = result.values
when 2..30
result = dice_roll(skill_rank + 1 , 6)
result = @dice_roll_generator.dice_roll(skill_rank + 1 , 6)
values = result.values.sort.pop(2)
else
return header + "ダイスが机から落ちてしまいましたの☆"
Expand Down Expand Up @@ -62,7 +62,7 @@ def stigma(type)
response = {:dice => '', :stigma => [] }

stigma.each { |values|
d = DiceRollResult.new(0, 0, values)
d = DiceRoll::DiceRollResult.new(0, 0, values)
response[:dice] << d.sw2_dll_format
response[:stigma] << stigma_text(type, d.sum)
}
Expand All @@ -75,7 +75,7 @@ def stigma(type)
# バッドエンド表を振る
# @param [String] type 体力・気力のどちらか
def badend(type)
result = dice_roll(2, 6)
result = @dice_roll_generator.dice_roll(2, 6)
"#{result.sw2_dll_format} -> #{badend_text(type, result.sum)}"
end

Expand All @@ -97,7 +97,7 @@ def get_stigma()

while time > 0
time -= 1
dice = dice_roll(2, 6)
dice = @dice_roll_generator.dice_roll(2, 6)
stigma_number << dice.values
if dice.sum == 2 and !second
second = true
Expand Down Expand Up @@ -184,16 +184,6 @@ def stance_select(type)
"#{rand + 1}:【#{stance[rand]}】"
end
private :stance_select

# ダイスロールの結果を返す
# @param [Fixnum] rolls ダイスの個数
# @param [Fixnum] sides ダイスの最大値
# @return [DiceRollResult]
def dice_roll(rolls, sides)
values = Array.new(rolls) { @random.rand(1..sides) }
DiceRollResult.new(rolls, sides, values)
end
private :dice_roll
end
end
end
Expand Down

0 comments on commit 2b2f0d2

Please sign in to comment.