-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 判定を実装。Rubocop通過済み * バースト時の表示を変更した * [FullFace] コマンドを完全一致にする * [FullFace] Array#count の使い方を変更 --------- Co-authored-by: SAKATA Sinji <[email protected]>
- Loading branch information
1 parent
6e646c7
commit 266e3a9
Showing
3 changed files
with
206 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,92 @@ | ||
# frozen_string_literal: true | ||
|
||
module BCDice | ||
module GameSystem | ||
class FullFace < Base | ||
# ゲームシステムの識別子 | ||
ID = 'FullFace' | ||
|
||
# ゲームシステム名 | ||
NAME = 'フルフェイス' | ||
|
||
# ゲームシステム名の読みがな | ||
SORT_KEY = 'ふるふえいす' | ||
|
||
# ダイスボットの使い方 | ||
HELP_MESSAGE = <<~INFO_MESSAGETEXT | ||
■判定 x+bFF<=t x:ヒート(省略時は3) b:判定修正 t:能力値 | ||
例)FF<=2: 能力値2で判定し、その結果(成功数,1の目の数,バースト)を表示。 | ||
6FF<=3: ヒート6,能力値3で戦闘判定し、その結果( 〃 )を表示。 | ||
8+2FF<=3:ヒート8,判定修正+2,能力値3で戦闘判定し、その結果( 〃 )を表示。 | ||
INFO_MESSAGETEXT | ||
|
||
register_prefix('([+\d]+)*FF') | ||
|
||
def eval_game_system_specific_command(command) | ||
resolute_action(command) | ||
end | ||
|
||
private | ||
|
||
# 技能判定 | ||
# @param [String] command | ||
# @return [Result] | ||
def resolute_action(command) | ||
m = /^(\d*)([+\d]+)*FF<=(\d)$/.match(command) | ||
return nil unless m | ||
|
||
heat_level = m[1].to_i | ||
heat_level = 3 if heat_level == 0 | ||
modify = Arithmetic.eval("0#{m[2]}", @round_type) | ||
status_no = m[3].to_i | ||
|
||
dice_array = [] | ||
|
||
dice = @randomizer.roll_barabara(heat_level, 6) | ||
ones = dice.count(1) | ||
sixs = dice.count(6) | ||
success_num = dice.count { |val| val <= status_no } | ||
dice_array.push(dice.join(",")) | ||
|
||
if modify > 0 | ||
dice = @randomizer.roll_barabara(modify, 6) | ||
ones += dice.count(1) | ||
success_num += dice.count { |val| val <= status_no } | ||
dice_array.push(dice.join(",")) | ||
end | ||
ones_total = ones | ||
|
||
while ones > 0 | ||
dice = @randomizer.roll_barabara(ones, 6) | ||
ones = dice.count(1) | ||
ones_total += ones | ||
success_num += dice.count { |val| val <= status_no } | ||
dice_array.push(dice.join(",")) | ||
end | ||
|
||
return Result.new.tap do |result| | ||
if sixs >= 2 | ||
result.fumble = true | ||
result.condition = false | ||
else | ||
result.condition = (success_num > 0) | ||
result.critical = (ones_total > 0) | ||
end | ||
result_txt = [] | ||
result_txt.push("成功度(#{success_num})") | ||
result_txt.push("1の目(#{ones_total})") if ones_total > 0 | ||
result_txt.push("バースト") if result.fumble? | ||
|
||
sequence = [ | ||
"(#{heat_level}#{Format.modifier(modify)}FF<=#{status_no})", | ||
dice_array.join('+').to_s, | ||
result_txt.join(',').to_s, | ||
].compact | ||
|
||
result.text = sequence.join(" > ") | ||
end | ||
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,113 @@ | ||
[[ test ]] | ||
game_system = "FullFace" | ||
input = "8FF<=3 成功度" | ||
output = "(8FF<=3) > 6,5,4,3,2,2,5,4 > 成功度(3)" | ||
success = true | ||
rands = [ | ||
{ sides = 6, value = 6 }, | ||
{ sides = 6, value = 5 }, | ||
{ sides = 6, value = 4 }, | ||
{ sides = 6, value = 3 }, | ||
{ sides = 6, value = 2 }, | ||
{ sides = 6, value = 2 }, | ||
{ sides = 6, value = 5 }, | ||
{ sides = 6, value = 4 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "FullFace" | ||
input = "8FF<=3 成功度及び1の目" | ||
output = "(8FF<=3) > 6,5,4,3,2,1,5,4+3 > 成功度(4),1の目(1)" | ||
success = true | ||
critical = true | ||
rands = [ | ||
{ sides = 6, value = 6 }, | ||
{ sides = 6, value = 5 }, | ||
{ sides = 6, value = 4 }, | ||
{ sides = 6, value = 3 }, | ||
{ sides = 6, value = 2 }, | ||
{ sides = 6, value = 1 }, | ||
{ sides = 6, value = 5 }, | ||
{ sides = 6, value = 4 }, | ||
{ sides = 6, value = 3 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "FullFace" | ||
input = "8FF<=3 成功度及び1の目及びバースト" | ||
output = "(8FF<=3) > 6,5,4,3,2,1,6,5+4 > 成功度(3),1の目(1),バースト" | ||
fumble = true | ||
failure = true | ||
rands = [ | ||
{ sides = 6, value = 6 }, | ||
{ sides = 6, value = 5 }, | ||
{ sides = 6, value = 4 }, | ||
{ sides = 6, value = 3 }, | ||
{ sides = 6, value = 2 }, | ||
{ sides = 6, value = 1 }, | ||
{ sides = 6, value = 6 }, | ||
{ sides = 6, value = 5 }, | ||
{ sides = 6, value = 4 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "FullFace" | ||
input = "8FF<=3 成功度及び1の目及びバーストせず" | ||
output = "(8FF<=3) > 6,5,4,3,2,1,5,4+6 > 成功度(3),1の目(1)" | ||
success = true | ||
critical = true | ||
rands = [ | ||
{ sides = 6, value = 6 }, | ||
{ sides = 6, value = 5 }, | ||
{ sides = 6, value = 4 }, | ||
{ sides = 6, value = 3 }, | ||
{ sides = 6, value = 2 }, | ||
{ sides = 6, value = 1 }, | ||
{ sides = 6, value = 5 }, | ||
{ sides = 6, value = 4 }, | ||
{ sides = 6, value = 6 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "FullFace" | ||
input = "8FF<=3 多重1の目" | ||
output = "(8FF<=3) > 6,5,4,3,2,1,5,4+1+3 > 成功度(5),1の目(2)" | ||
success = true | ||
critical = true | ||
rands = [ | ||
{ sides = 6, value = 6 }, | ||
{ sides = 6, value = 5 }, | ||
{ sides = 6, value = 4 }, | ||
{ sides = 6, value = 3 }, | ||
{ sides = 6, value = 2 }, | ||
{ sides = 6, value = 1 }, | ||
{ sides = 6, value = 5 }, | ||
{ sides = 6, value = 4 }, | ||
{ sides = 6, value = 1 }, | ||
{ sides = 6, value = 3 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "FullFace" | ||
input = "FF<=3 一般判定" | ||
output = "(3FF<=3) > 6,5,4 > 成功度(0)" | ||
failure = true | ||
rands = [ | ||
{ sides = 6, value = 6 }, | ||
{ sides = 6, value = 5 }, | ||
{ sides = 6, value = 4 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "FullFace" | ||
input = "+2FF<=3 一般判定" | ||
output = "(3+2FF<=3) > 6,5,4+3,2 > 成功度(2)" | ||
success = true | ||
rands = [ | ||
{ sides = 6, value = 6 }, | ||
{ sides = 6, value = 5 }, | ||
{ sides = 6, value = 4 }, | ||
{ sides = 6, value = 3 }, | ||
{ sides = 6, value = 2 }, | ||
] | ||
|