-
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.
Merge pull request #599 from bcdice/bloodorium
ブラドリウムに対応
- Loading branch information
Showing
3 changed files
with
161 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
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,68 @@ | ||
# frozen_string_literal: true | ||
|
||
module BCDice | ||
module GameSystem | ||
class Bloodorium < Base | ||
# ゲームシステムの識別子 | ||
ID = 'Bloodorium' | ||
|
||
# ゲームシステム名 | ||
NAME = 'ブラドリウム' | ||
|
||
# ゲームシステム名の読みがな | ||
SORT_KEY = 'ふらとりうむ' | ||
|
||
# ダイスボットの使い方 | ||
HELP_MESSAGE = <<~INFO_MESSAGE_TEXT | ||
・ダイスチェック xDC+y | ||
【ダイスチェック】を行う。《トライアンフ》を結果に自動反映する。 | ||
x: ダイス数 | ||
y: 結果への修正値 (省略可) | ||
INFO_MESSAGE_TEXT | ||
|
||
register_prefix('\dDC') | ||
|
||
def eval_game_system_specific_command(command) | ||
dicecheck(command) | ||
end | ||
|
||
private | ||
|
||
def dicecheck(command) | ||
parser = Command::Parser.new("DC", round_type: @round_type).has_prefix_number.restrict_cmp_op_to(nil) | ||
parsed = parser.parse(command) | ||
unless parsed | ||
return nil | ||
end | ||
|
||
dice_list = @randomizer.roll_barabara(parsed.prefix_number, 6).sort | ||
dice_value = dice_list.max | ||
values_count = dice_list | ||
.group_by(&:itself) | ||
.transform_values(&:length) | ||
triumph = values_count.values.max | ||
|
||
total = dice_value * triumph + parsed.modify_number | ||
|
||
sequence = [ | ||
"(#{parsed})", | ||
"[#{dice_list.join(',')}]#{Format.modifier(parsed.modify_number)}", | ||
("《トライアンフ》(*#{triumph})" if triumph > 1), | ||
(total_expr(dice_value, triumph, parsed.modify_number) if total != dice_value), | ||
total, | ||
].compact | ||
|
||
return Result.new.tap do |r| | ||
r.critical = triumph > 1 | ||
r.text = sequence.join(" > ") | ||
end | ||
end | ||
|
||
def total_expr(dice_value, triumph, modify_number) | ||
formated_triumph = triumph > 1 ? "*#{triumph}" : nil | ||
|
||
return "#{dice_value}#{formated_triumph}#{Format.modifier(modify_number)}" | ||
end | ||
end | ||
end | ||
end |
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,92 @@ | ||
[[ test ]] | ||
game_system = "Bloodorium" | ||
input = "4DC" | ||
output = "(4DC) > [1,2,3,4] > 4" | ||
rands = [ | ||
{ sides = 6, value = 1 }, | ||
{ sides = 6, value = 2 }, | ||
{ sides = 6, value = 3 }, | ||
{ sides = 6, value = 4 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "Bloodorium" | ||
input = "3DC" | ||
output = "(3DC) > [3,4,5] > 5" | ||
rands = [ | ||
{ sides = 6, value = 3 }, | ||
{ sides = 6, value = 4 }, | ||
{ sides = 6, value = 5 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "Bloodorium" | ||
input = "4DC" | ||
output = "(4DC) > [1,2,2,4] > 《トライアンフ》(*2) > 4*2 > 8" | ||
critical = true | ||
rands = [ | ||
{ sides = 6, value = 1 }, | ||
{ sides = 6, value = 2 }, | ||
{ sides = 6, value = 2 }, | ||
{ sides = 6, value = 4 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "Bloodorium" | ||
input = "5DC" | ||
output = "(5DC) > [2,2,5,5,5] > 《トライアンフ》(*3) > 5*3 > 15" | ||
critical = true | ||
rands = [ | ||
{ sides = 6, value = 2 }, | ||
{ sides = 6, value = 2 }, | ||
{ sides = 6, value = 5 }, | ||
{ sides = 6, value = 5 }, | ||
{ sides = 6, value = 5 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "Bloodorium" | ||
input = "4DC+1" | ||
output = "(4DC+1) > [1,2,3,4]+1 > 4+1 > 5" | ||
rands = [ | ||
{ sides = 6, value = 1 }, | ||
{ sides = 6, value = 2 }, | ||
{ sides = 6, value = 3 }, | ||
{ sides = 6, value = 4 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "Bloodorium" | ||
input = "4DC+1+2" | ||
output = "(4DC+3) > [1,2,3,4]+3 > 4+3 > 7" | ||
rands = [ | ||
{ sides = 6, value = 1 }, | ||
{ sides = 6, value = 2 }, | ||
{ sides = 6, value = 3 }, | ||
{ sides = 6, value = 4 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "Bloodorium" | ||
input = "5DC+1" | ||
output = "(5DC+1) > [2,2,5,5,5]+1 > 《トライアンフ》(*3) > 5*3+1 > 16" | ||
critical = true | ||
rands = [ | ||
{ sides = 6, value = 2 }, | ||
{ sides = 6, value = 5 }, | ||
{ sides = 6, value = 2 }, | ||
{ sides = 6, value = 5 }, | ||
{ sides = 6, value = 5 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "Bloodorium" | ||
input = "DC" | ||
output = "" | ||
rands = [] | ||
|
||
[[ test ]] | ||
game_system = "Bloodorium" | ||
input = "DC+1" | ||
output = "" | ||
rands = [] |