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

[フルフェイス]専用ダイスを作成しました #668

Merged
merged 4 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -83,6 +83,7 @@
require "bcdice/game_system/Fiasco_Korean"
require "bcdice/game_system/FilledWith"
require "bcdice/game_system/FullMetalPanic"
require "bcdice/game_system/FullFace"
require "bcdice/game_system/FutariSousa"
require "bcdice/game_system/FutariSousa_Korean"
require "bcdice/game_system/Garako"
Expand Down
92 changes: 92 additions & 0 deletions lib/bcdice/game_system/FullFace.rb
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
113 changes: 113 additions & 0 deletions test/data/FullFace.toml
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 },
]

Loading