-
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 #636 from bcdice/add_DemonSpike
『デモンスパイク』を追加
- Loading branch information
Showing
3 changed files
with
231 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,89 @@ | ||
# frozen_string_literal: true | ||
|
||
module BCDice | ||
module GameSystem | ||
class DemonSpike < Base | ||
# ゲームシステムの識別子 | ||
ID = 'DemonSpike' | ||
|
||
# ゲームシステム名 | ||
NAME = 'デモンスパイク' | ||
|
||
# ゲームシステム名の読みがな | ||
SORT_KEY = 'てもんすはいく' | ||
|
||
# ダイスボットの使い方 | ||
HELP_MESSAGE = <<~INFO_MESSAGE_TEXT | ||
・行為判定 xDS+y | ||
行為判定を行い、達成値、成否、成功度を出力する。 | ||
x: ダイス数(省略:2) | ||
y: 能力値やスパイク能力による達成値の修正(省略可) | ||
INFO_MESSAGE_TEXT | ||
|
||
register_prefix('\d*DS') | ||
|
||
def eval_game_system_specific_command(command) | ||
roll_action(command) | ||
end | ||
|
||
private | ||
|
||
def roll_action(command) | ||
parser = Command::Parser.new("DS", round_type: @round_type) | ||
.enable_prefix_number | ||
.restrict_cmp_op_to(nil) | ||
parsed = parser.parse(command) | ||
unless parsed | ||
return nil | ||
end | ||
|
||
parsed.prefix_number ||= 2 | ||
if parsed.prefix_number < 2 | ||
return nil | ||
end | ||
|
||
step = roll_step(parsed.prefix_number) | ||
step_list = [step] | ||
while step[:dice_sum] == 10 | ||
step = roll_step(parsed.prefix_number) | ||
step_list.push(step) | ||
end | ||
|
||
is_fumble = step_list[0][:dice_sum] == 2 | ||
total = is_fumble ? 0 : step_list.sum { |s| s[:dice_sum] } + parsed.modify_number | ||
success_level = total / 10 | ||
is_success = total >= 10 | ||
|
||
res = | ||
if is_success | ||
"成功, 成功度#{success_level}" | ||
elsif is_fumble | ||
"自動的失敗" | ||
else | ||
"失敗" | ||
end | ||
|
||
sequence = [ | ||
"(#{parsed})", | ||
step_list.map { |s| "#{s[:dice_sum]}[#{s[:dice_list].join(',')}]" }, | ||
total, | ||
res, | ||
].flatten | ||
|
||
return Result.new.tap do |r| | ||
r.condition = is_success | ||
r.critical = step_list.length > 1 | ||
r.fumble = is_fumble | ||
r.text = sequence.join(" > ") | ||
end | ||
end | ||
|
||
def roll_step(times) | ||
dice_list = @randomizer.roll_barabara(times, 6).sort.reverse | ||
dice_sum = (dice_list[0] + dice_list[1]).clamp(2, 10) | ||
|
||
return {dice_list: dice_list, dice_sum: dice_sum} | ||
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,141 @@ | ||
[[ test ]] | ||
game_system = "DemonSpike" | ||
input = "DS+7" | ||
output = "(2DS+7) > 9[5,4] > 16 > 成功, 成功度1" | ||
success = true | ||
rands = [ | ||
{ sides = 6, value = 4 }, | ||
{ sides = 6, value = 5 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "DemonSpike" | ||
input = "DS+7" | ||
output = "(2DS+7) > 10[6,5] > 10[6,6] > 2[1,1] > 29 > 成功, 成功度2" | ||
success = true | ||
critical = true | ||
rands = [ | ||
{ sides = 6, value = 6 }, | ||
{ sides = 6, value = 5 }, | ||
{ sides = 6, value = 6 }, | ||
{ sides = 6, value = 6 }, | ||
{ sides = 6, value = 1 }, | ||
{ sides = 6, value = 1 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "DemonSpike" | ||
input = "DS+8" | ||
output = "(2DS+8) > 10[6,5] > 10[6,6] > 2[1,1] > 30 > 成功, 成功度3" | ||
success = true | ||
critical = true | ||
rands = [ | ||
{ sides = 6, value = 6 }, | ||
{ sides = 6, value = 5 }, | ||
{ sides = 6, value = 6 }, | ||
{ sides = 6, value = 6 }, | ||
{ sides = 6, value = 1 }, | ||
{ sides = 6, value = 1 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "DemonSpike" | ||
input = "DS+6" | ||
output = "(2DS+6) > 3[2,1] > 9 > 失敗" | ||
failure = true | ||
rands = [ | ||
{ sides = 6, value = 2 }, | ||
{ sides = 6, value = 1 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "DemonSpike" | ||
input = "DS+7" | ||
output = "(2DS+7) > 2[1,1] > 0 > 自動的失敗" | ||
failure = true | ||
fumble = true | ||
rands = [ | ||
{ sides = 6, value = 1 }, | ||
{ sides = 6, value = 1 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "DemonSpike" | ||
input = "DS" | ||
output = "(2DS) > 10[5,5] > 7[5,2] > 17 > 成功, 成功度1" | ||
success = true | ||
critical = true | ||
rands = [ | ||
{ sides = 6, value = 5 }, | ||
{ sides = 6, value = 5 }, | ||
{ sides = 6, value = 5 }, | ||
{ sides = 6, value = 2 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "DemonSpike" | ||
input = "DS" | ||
output = "(2DS) > 9[5,4] > 9 > 失敗" | ||
failure = true | ||
rands = [ | ||
{ sides = 6, value = 4 }, | ||
{ sides = 6, value = 5 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "DemonSpike" | ||
input = "3DS+7" | ||
output = "(3DS+7) > 9[5,4,3] > 16 > 成功, 成功度1" | ||
success = true | ||
rands = [ | ||
{ sides = 6, value = 4 }, | ||
{ sides = 6, value = 5 }, | ||
{ sides = 6, value = 3 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "DemonSpike" | ||
input = "3DS+7" | ||
output = "(3DS+7) > 3[2,1,1] > 10 > 成功, 成功度1" | ||
success = true | ||
rands = [ | ||
{ sides = 6, value = 1 }, | ||
{ sides = 6, value = 1 }, | ||
{ sides = 6, value = 2 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "DemonSpike" | ||
input = "3DS+7" | ||
output = "(3DS+7) > 2[1,1,1] > 0 > 自動的失敗" | ||
failure = true | ||
fumble = true | ||
rands = [ | ||
{ sides = 6, value = 1 }, | ||
{ sides = 6, value = 1 }, | ||
{ sides = 6, value = 1 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "DemonSpike" | ||
input = "3DS+7" | ||
output = "(3DS+7) > 10[6,5,1] > 10[6,6,1] > 2[1,1,1] > 29 > 成功, 成功度2" | ||
success = true | ||
critical = true | ||
rands = [ | ||
{ sides = 6, value = 6 }, | ||
{ sides = 6, value = 5 }, | ||
{ sides = 6, value = 1 }, | ||
{ sides = 6, value = 6 }, | ||
{ sides = 6, value = 6 }, | ||
{ sides = 6, value = 1 }, | ||
{ sides = 6, value = 1 }, | ||
{ sides = 6, value = 1 }, | ||
{ sides = 6, value = 1 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "DemonSpike" | ||
input = "1DS" | ||
output = "" | ||
rands = [] |