Skip to content

Commit

Permalink
detatoko-darkness: ラスボス立場表関連のメソッドをまとめた
Browse files Browse the repository at this point in the history
引数の説明をするコメントを増補
  • Loading branch information
koi-chan committed Jan 21, 2017
1 parent 9e31cc8 commit e36006b
Showing 1 changed file with 37 additions and 15 deletions.
52 changes: 37 additions & 15 deletions lib/rgrb/plugin/trpg/detatoko/irc_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ class IrcAdapter

match(/stance[\s ]+(#{STANCE_RE})/io, method: :stance)

match(/lbg/i, method: :lastboss_ground)
match(/dg/i, method: :darkboss_ground)
match(/(lb|d)g/i, method: :ground)

match(/c(?:[^s]|$)/i, method: :character_class)

Expand All @@ -45,8 +44,7 @@ class IrcAdapter
match(/(体|気)力烙印/i, method: :stigma, :prefix => prefix_ja)
match(/(体|気)力バッドエンド/i, method: :badend, :prefix => prefix_ja)
match(/スタンス[\s ]+(#{STANCE_RE})/io, method: :stance, :prefix => prefix_ja)
match(/ラスボス立場/i, method: :lastboss_ground, :prefix => prefix_ja)
match(/悪へのラスボス立場/i, method: :darkboss_ground, :prefix => prefix_ja)
match(/(|悪への)ラスボス立場/i, method: :ground, :prefix => prefix_ja)
match(/クラス/i, method: :character_class, :prefix => prefix_ja)
match(/(|敵|悪)ポジション/i, method: :position, :prefix => prefix_ja)

Expand All @@ -58,6 +56,11 @@ def initialize(*args)
end

# スキルランクから判定値を得る
# @param [Cinch::Message] m
# @param [String] skill_rank スキルランク
# @param [String] calc 判定値に四則演算を行なう場合の演算子
# @param [String] solid 四則演算を行なう場合の計算される数
# @param [String] flag 現在の PC のフラグ値
# @return [void]
def skill_decision(m, skill_rank, calc = '+', solid = 0, flag = 0)
header = "#{@header}[#{m.user.nick}]: "
Expand All @@ -69,12 +72,20 @@ def skill_decision(m, skill_rank, calc = '+', solid = 0, flag = 0)
end

# skill_decision のフラグ先行コマンド用ラッパー
# @param [Cinch::Message] m
# @param [String] skill_rank スキルランク
# @param [String] flag 現在の PC のフラグ値
# @param [String] calc 判定値に四則演算を行なう場合の演算子
# @param [String] solid 四則演算を行なう場合の計算される数
# @return [void]
def skill_decision_flag(m, skill_rank, flag = 0, calc = '+', solid = 0)
skill_decision(m, skill_rank, calc, solid, flag)
end

# skill_decision の日本語コマンド
# 日本語コマンドは四則演算はフラグ値を考慮しない
# @param [Cinch::Message] m
# @param [String] skill_rank_ja スキルランクの日本語形式
# @return [void]
def skill_decision_ja(m, skill_rank_ja)
header = "#{@header}[#{m.user.nick}]: "
Expand All @@ -86,6 +97,8 @@ def skill_decision_ja(m, skill_rank_ja)
end

# 烙印(p.63)を得る
# @param [Cinch::Message] m
# @param [String] tcode 何の烙印か
# @return [void]
def stigma(m, tcode)
tcode = type_tr(tcode)
Expand All @@ -95,6 +108,8 @@ def stigma(m, tcode)
end

# バッドエンド表(p.65)を振る
# @param [Cinch::Message] m
# @param [String] tcode 何のバッドエンド表か
# @return [void]
def badend(m, tcode)
tcode = type_tr(tcode)
Expand All @@ -104,6 +119,8 @@ def badend(m, tcode)
end

# スタンス表から引く
# @param [Cinch::Message] m
# @param [String] uses 選ぶ元となるスタンス
# @return [void]
def stance(m, uses)
header = "#{@header}[#{m.user.nick}]<スタンス表>: "
Expand All @@ -112,22 +129,23 @@ def stance(m, uses)
end

# ラスボス立場表を引く
# @param [Cinch::Message] m
# @param [String] type 何のラスボス立場表か
# @return [void]
def lastboss_ground(m)
header = "#{@header}[#{m.user.nick}]<ラスボス立場>: "
message = @generator.ground(:normal)
m.target.send(header + message, true)
end

# 悪へのラスボス立場表を引く
# @return [void]
def darkboss_ground(m)
header = "#{@header}[#{m.user.nick}]<敵へのラスボス立場>: "
message = @generator.ground(:dark)
def ground(m, type)
insert, type = case type
when 'lb', ''
['', :normal]
when 'd', '悪への'
['敵への', :dark]
end
header = "#{@header}[#{m.user.nick}]<#{insert}ラスボス立場>: "
message = @generator.ground(type)
m.target.send(header + message, true)
end

# クラスを1つ選ぶ
# @param [Cinch::Message] m
# @return [void]
def character_class(m)
header = "#{@header}[#{m.user.nick}]<クラス>: "
Expand All @@ -136,6 +154,8 @@ def character_class(m)
end

# ポジションを1つ選ぶ
# @param [Cinch::Message] m
# @param [String] type 何のポジションか
# @return [void]
def position(m, type)
insert, type = case type
Expand All @@ -152,6 +172,8 @@ def position(m, type)
end

# 1行のキャラクターシートを生成する
# @param [Cinch::Message] m
# @param [String] ids_str キャラクターシートの ID (String 型)
# @return [void]
def lcs(m, ids_str)
log_incoming(m)
Expand Down

0 comments on commit e36006b

Please sign in to comment.