-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* サンサーラ・バラッドのダイスボット追加 * レビュー反映: C値、F値の表記を他システムに合わせる * メッセージ変更忘れ * ソートキー修正 * F値のコーナーケース修正 * 通常ロールの処理にミスがあったので修正 * C値とF値のコマンド順序入れ替え、スワップロール時に1d10を2回使うように変更 * メッセージ修正 * メッセージの記述を1d100 -> D100としてルールブックに合わせる * F値、C値、Swapフラグはインスタンス変数ではなくメソッドの引数に * 正規表現によるパースを一度で全部処理する * 等号を含まない不等号の対応 * 受動判定(同値が失敗)についてのヘルプメッセージを追記 * 失敗とファンブルでは失敗が優先となるテストケースを追加
- Loading branch information
1 parent
20aec91
commit 5b3355b
Showing
4 changed files
with
449 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,6 +159,7 @@ | |
Ryutama | ||
SMTKakuseihen | ||
SRS | ||
SamsaraBallad | ||
Satasupe | ||
SevenFortressMobius | ||
ScreamHighSchool | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# -*- coding: utf-8 -*- | ||
# frozen_string_literal: true | ||
|
||
class SamsaraBallad < DiceBot | ||
# ゲームシステムの識別子 | ||
ID = 'SamsaraBallad' | ||
|
||
# ゲームシステム名 | ||
NAME = 'サンサーラ・バラッド' | ||
|
||
# ゲームシステム名の読みがな | ||
# | ||
# 「ゲームシステム名の読みがなの設定方法」(docs/dicebot_sort_key.md)を参考にして | ||
# 設定してください | ||
SORT_KEY = 'さんさあらはらつと' | ||
|
||
# ダイスボットの使い方 | ||
HELP_MESSAGE = <<MESSAGETEXT | ||
SB 通常のD100ロールを行う | ||
SBS スワップロールでD100ロールを行う | ||
SB#x@y F値をx、C値をyとして通常のD100ロールを行う | ||
SBS#x@y F値をx、C値をyとしてスワップロールでD100ロールを行う | ||
例: | ||
SB<=85 通常の技能で成功率85%の判定 | ||
SBS<=70 習熟を得た技能で成功率70%の判定 | ||
SBS#3@7<=80 習熟を得た技能で、F値3、C値7で成功率80%の攻撃判定 | ||
SB<57 通常の技能で、能動側の達成値が57の受動判定 | ||
SBS<70 習熟を得た技能で、能動側の達成値が70の受動判定 | ||
MESSAGETEXT | ||
|
||
# ダイスボットで使用するコマンドを配列で列挙する | ||
setPrefixes(['SBS?(#\d@\d)?(<=?[+-/*\d]+)?']) | ||
|
||
def rollDiceCommand(command) | ||
debug("rollDiceCommand Begin") | ||
|
||
is_swap = false | ||
f_value = -1 | ||
c_value = 10 | ||
diff = 0 | ||
is_diff_eq_allowable = true | ||
|
||
if (m = %r{SB(S?)(#(\d)@(\d))?(<(=?)([+-/*\d]+))?}i.match(command)) | ||
is_swap = true if m[1] != "" | ||
unless m[2].nil? | ||
f_value = m[3].to_i | ||
c_value = m[4].to_i | ||
end | ||
unless m[5].nil? | ||
diff = ArithmeticEvaluator.new.eval(m[7]) | ||
is_diff_eq_allowable = false if m[6] == "" | ||
end | ||
else | ||
debug("command parse failed") | ||
return nil | ||
end | ||
|
||
debug("SamsaraBallad Roll Param:", is_swap, f_value, c_value, diff, is_diff_eq_allowable) | ||
return getCheckResult(is_swap, f_value, c_value, diff, is_diff_eq_allowable) | ||
end | ||
|
||
def getCheckResult(is_swap, f_value, c_value, diff, is_diff_eq_allowable) | ||
if is_swap | ||
d100_n1, = roll(1, 10) | ||
d100_n2, = roll(1, 10) | ||
d100_dice = [d100_n1, d100_n2] | ||
min_n = d100_dice.min | ||
max_n = d100_dice.max | ||
debug(min_n, max_n) | ||
if min_n == 10 | ||
total_n = 100 | ||
elsif max_n == 10 | ||
total_n = min_n | ||
else | ||
total_n = 10 * min_n + max_n | ||
end | ||
dice_label = "#{d100_n1},#{d100_n2} > #{total_n}" | ||
else | ||
total_n, = roll(1, 100) | ||
dice_label = total_n.to_s | ||
end | ||
|
||
is_fumble = f_value >= 0 && total_n % 10 <= f_value | ||
is_critical = !is_fumble && c_value < 10 && total_n % 10 >= c_value | ||
|
||
if diff > 0 | ||
if is_diff_eq_allowable | ||
output = "(D100<=#{diff})" | ||
cmp = (total_n <= diff) && (total_n < 100) | ||
else | ||
output = "(D100<#{diff})" | ||
cmp = (total_n < diff) && (total_n < 100) | ||
end | ||
output += " > #{dice_label}" | ||
if cmp | ||
if is_fumble | ||
output += " > ファンブル" | ||
elsif is_critical | ||
output += " > クリティカル" | ||
else | ||
output += " > 成功" | ||
end | ||
else | ||
output += " > 失敗" | ||
end | ||
else | ||
output = "D100 > #{dice_label}" | ||
if is_fumble | ||
output += " > ファンブル" | ||
elsif is_critical | ||
output += " > クリティカル" | ||
end | ||
end | ||
|
||
return output | ||
end | ||
end |
Oops, something went wrong.