Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TRPG『慈悲なきアイオニア』のダイスボット #720

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
f4338f2
Aionia.rbを作成
hattarhaptag Jun 2, 2024
faf8b70
ダイスボット一覧にAioniaを追加
hattarhaptag Jun 2, 2024
c8ccff2
慈悲なきアイオニアのダイスボットのテスト作成
hattarhaptag Jun 3, 2024
72e413f
class名が誤ってOnseToolになっていたのでAioniaに修正
hattarhaptag Jun 3, 2024
810624c
Aionia.rbをテンプレートに沿った形に修正
hattarhaptag Jun 3, 2024
4e49a98
テストデータを修正
hattarhaptag Jun 3, 2024
8932393
Aioniaのコマンドの修正と正規表現の追加
hattarhaptag Jun 4, 2024
e118b0c
テストデータのコマンドを大文字に修正
hattarhaptag Jun 4, 2024
de48b64
テストデータのコマンドを大文字へと修正、その他微修正
hattarhaptag Jun 4, 2024
92cd0ea
慈悲なきアイオニアのダイスボット作成
hattarhaptag Jun 4, 2024
cf97567
コマンドを大文字にしたのでヘルプメッセージも同様に修正
hattarhaptag Jun 4, 2024
b810c17
ソートキーのルールに合わせて修正
hattarhaptag Jun 4, 2024
03b5d95
技能ロールのコマンドをS(ST)からAB(ABT)に変更
hattarhaptag Jun 25, 2024
c888fe0
Merge branch 'bcdice:master' into feature/AioniaTRPG
hattarhaptag Jul 1, 2024
041e0bc
Resultクラスを用いるため、テストにSuccess, Failure, Critical, Fumble情報を追加
hattarhaptag Jul 1, 2024
8e9bb68
Resultクラスを用いて結果を返すように修正
hattarhaptag Jul 1, 2024
126ff24
一部CriticalとFumble判定の処理が抜けていたので修正
hattarhaptag Jul 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/bcdice/game_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require "bcdice/game_system/AFF2e"
require "bcdice/game_system/AceKillerGene"
require "bcdice/game_system/Ainecadette"
require "bcdice/game_system/Aionia"
require "bcdice/game_system/Airgetlamh"
require "bcdice/game_system/AlchemiaStruggle"
require "bcdice/game_system/Alsetto"
Expand Down
112 changes: 112 additions & 0 deletions lib/bcdice/game_system/Aionia.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# frozen_string_literal: true

module BCDice
module GameSystem
class Aionia < Base
# ゲームシステムの識別子
ID = "Aionia"

# ゲームシステム名
NAME = "慈悲なきアイオニア"

# ゲームシステム名の読みがな
SORT_KEY = "しひなきあいおにあ"

HELP_MESSAGE = <<~INFO_MESSAGE_TEXT
- 技能判定(クリティカル・ファンブルなし)
AB{n}>={dif} n=10面ダイスの数、dif=難易度
- 技能判定(クリティカル・ファンブルあり)
ABT{n}>={dif} n=10面ダイスの数、dif=難易度

例:AB2>=5 (一般技能を活用して難易度5の技能判定。 クリファンなし。)
例:ABT3>=15 (専門技能を活用して難易度15の技能判定。クリファンあり。)
例:AB1+2>=8 (一般技能を活用せず難易度8の技能判定。 ボーナスとして+2点の補正あり。 クリファンなし。)
例:ABT3-3>=10 (専門技能を活用して難易度10の技能判定。ペナルティとして-3点の補正あり。クリファンあり。)
例:ABT2>=4/8/12 (一般技能を活用して難易度4/8/12の段階的な技能判定。クリファンあり。)
INFO_MESSAGE_TEXT

register_prefix('ABT?\d+([\+\-]\d+)?>=\d+(\/\d+)*')

def eval_game_system_specific_command(command)
return roll_skills(command)
end

def roll_skills(command)
m = %r{AB(T?)(\d+)([+-]\d+)?>=((\d+)((/\d+)*))}.match(command)
return nil unless m

# 値の取得
use_cf = m[1] != ''
times = m[2].to_i
bonus = m[3].to_i
targets = m[4].split('/').map(&:to_i)
target = targets[0]
min_target = targets.min
max_target = targets.max

# ダイスロール
dice_list = @randomizer.roll_barabara(times, 10)
dice_total = dice_list.sum
total = dice_total + bonus

# 結果判定
# 難易度が一つの場合
if targets.count == 1
if total >= target
if total >= target + 20 && use_cf
result = 'クリティカル'
elsif target <= times
result = '自動成功'
else
result = '成功'
end
else
if dice_list.count(1) == times && use_cf
result = 'ファンブル'
elsif target > 10 * times
result = '自動失敗'
else
result = '失敗'
end
end
# 段階的な難易度判定の場合
else
if total >= min_target
if total >= max_target + 20 && use_cf
result = 'クリティカル'
elsif max_target <= times
result = '自動成功'
elsif total >= max_target
result = '全成功'
else
times_suc = targets.count { |x| x <= total }
result = "#{times_suc}段階成功"
end
else
if dice_list.count(1) == times && use_cf
result = 'ファンブル'
elsif min_target > 10 * times
result = '自動失敗'
else
result = '失敗'
end
end
end

# ボーナスがある場合の処理
bonus_text = ''
bonus_result = ''
if bonus != 0
if bonus > 0
bonus_text = "+"
end
bonus_text += bonus.to_s
bonus_result = "#{total} > "
end

# 結果を返す
return "(#{command}) > #{dice_total}[#{dice_list.join(',')}]#{bonus_text} > #{bonus_result}#{result}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

成否やクリティカル・ファンブルの結果を伴う出力には BCDice::Result クラスのインスタンスを用いるようにしてください。

以下が使用例です。

Result.new.tap do |r|
r.text = "(#{dice_cnt}B6>=4)#{over_modify > 0 ? "+#{over_modify * 2}" : ''} > [#{dice_str}]#{over_modify > 0 ? "+#{over_modify * 2}" : ''} > 成功数#{success_cnt}#{result ? '成功' : '失敗'}#{has_critical ? '(クリティカル)' : ''}#{has_fumble ? '(ファンブル)' : ''}"
r.critical = has_critical
r.fumble = has_fumble
r.success = result
r.failure = !result
end

end
end
end
end
Loading
Loading