-
Notifications
You must be signed in to change notification settings - Fork 180
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
hattarhaptag
wants to merge
17
commits into
bcdice:master
Choose a base branch
from
hattarhaptag:feature/AioniaTRPG
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 13 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
f4338f2
Aionia.rbを作成
hattarhaptag faf8b70
ダイスボット一覧にAioniaを追加
hattarhaptag c8ccff2
慈悲なきアイオニアのダイスボットのテスト作成
hattarhaptag 72e413f
class名が誤ってOnseToolになっていたのでAioniaに修正
hattarhaptag 810624c
Aionia.rbをテンプレートに沿った形に修正
hattarhaptag 4e49a98
テストデータを修正
hattarhaptag 8932393
Aioniaのコマンドの修正と正規表現の追加
hattarhaptag e118b0c
テストデータのコマンドを大文字に修正
hattarhaptag de48b64
テストデータのコマンドを大文字へと修正、その他微修正
hattarhaptag 92cd0ea
慈悲なきアイオニアのダイスボット作成
hattarhaptag cf97567
コマンドを大文字にしたのでヘルプメッセージも同様に修正
hattarhaptag b810c17
ソートキーのルールに合わせて修正
hattarhaptag 03b5d95
技能ロールのコマンドをS(ST)からAB(ABT)に変更
hattarhaptag c888fe0
Merge branch 'bcdice:master' into feature/AioniaTRPG
hattarhaptag 041e0bc
Resultクラスを用いるため、テストにSuccess, Failure, Critical, Fumble情報を追加
hattarhaptag 8e9bb68
Resultクラスを用いて結果を返すように修正
hattarhaptag 126ff24
一部CriticalとFumble判定の処理が抜けていたので修正
hattarhaptag File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,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}" | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
成否やクリティカル・ファンブルの結果を伴う出力には
BCDice::Result
クラスのインスタンスを用いるようにしてください。以下が使用例です。
BCDice/lib/bcdice/game_system/Ayabito.rb
Lines 84 to 90 in 48a94e0