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

[フルフェイス] (UPDATE) 一般判定の成否と戦闘判定のダメージ計算を実装しました #679

Merged
merged 5 commits into from
Feb 25, 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
49 changes: 39 additions & 10 deletions lib/bcdice/game_system/FullFace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,58 +14,70 @@ class FullFace < Base

# ダイスボットの使い方
HELP_MESSAGE = <<~INFO_MESSAGETEXT
■判定 x+bFF<=t x:ヒート(省略時は3) b:判定修正 t:能力値
■判定 x+bFF<=a[,t][&d] x:ヒート(省略時は3) b:判定修正 a:能力値 t:難易度(省略可) d:基本ダメージ(省略可)

例)FF<=2: 能力値2で判定し、その結果(成功数,1の目の数,6の目の数,バースト)を表示。
6FF<=3: ヒート6,能力値3で戦闘判定し、その結果( 〃 )を表示。
8+2FF<=3: ヒート8,判定修正+2,能力値3で戦闘判定し、その結果( 〃 )を表示。
FF<=2,1: 能力値2,難易度1で判定し、その結果(成功数,1の目の数,6の目の数,成功・失敗,バースト)を表示。
6FF<=3,2&1:ヒート6,能力値3,難易度2,基本ダメージ1で戦闘判定し、その結果(成功数,1の目の数,6の目の数,ダメージ,バースト)を表示。

例)FF<=2: 能力値2で判定し、その結果(成功数,1の目の数,バースト)を表示。
6FF<=3: ヒート6,能力値3で戦闘判定し、その結果( 〃 )を表示。
8+2FF<=3:ヒート8,判定修正+2,能力値3で戦闘判定し、その結果( 〃 )を表示。
INFO_MESSAGETEXT

register_prefix('([+\d]+)*FF')

def initialize(command)
super(command)

@sort_barabara_dice = true # バラバラロール(Bコマンド)でソート有
end

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)
m = /^(\d*)([+\d]+)*FF<=(\d)(,(\d))?(&(\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
target_no = m[5].to_i
damage_no = m[7].to_i

dice_array = []

dice = @randomizer.roll_barabara(heat_level, 6)
dice = @randomizer.roll_barabara(heat_level, 6).sort
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)
dice = @randomizer.roll_barabara(modify, 6).sort
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)
dice = @randomizer.roll_barabara(ones, 6).sort
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|
command_out = "(#{heat_level}#{Format.modifier(modify)}FF<=#{status_no}"
if sixs >= 2
result.fumble = true
result.condition = false
Expand All @@ -76,10 +88,27 @@ def resolute_action(command)
result_txt = []
result_txt.push("成功度(#{success_num})")
result_txt.push("1の目(#{ones_total})") if ones_total > 0
result_txt.push("6の目(#{sixs})") if sixs > 0
if target_no > 0
command_out += ",#{target_no}"
if success_num >= target_no
result_txt.push("成功")
result.condition = true
else
result_txt.push("失敗")
result.condition = false
end
end
if damage_no > 0
command_out += "&#{damage_no}"
damage = damage_no + ones_total
result_txt.push("ダメージ(#{damage})")
end
result_txt.push("バースト") if result.fumble?
command_out += ")"

sequence = [
"(#{heat_level}#{Format.modifier(modify)}FF<=#{status_no})",
command_out,
dice_array.join('+').to_s,
result_txt.join(',').to_s,
].compact
Expand Down
96 changes: 86 additions & 10 deletions test/data/FullFace.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[[ test ]]
game_system = "FullFace"
input = "8FF<=3 成功度"
output = "(8FF<=3) > 6,5,4,3,2,2,5,4 > 成功度(3)"
output = "(8FF<=3) > 2,2,3,4,4,4,5,5 > 成功度(3)"
success = true
rands = [
{ sides = 6, value = 6 },
{ sides = 6, value = 4 },
{ sides = 6, value = 5 },
{ sides = 6, value = 4 },
{ sides = 6, value = 3 },
Expand All @@ -17,11 +17,11 @@ rands = [
[[ test ]]
game_system = "FullFace"
input = "8FF<=3 成功度及び1の目"
output = "(8FF<=3) > 6,5,4,3,2,1,5,4+3 > 成功度(4),1の目(1)"
output = "(8FF<=3) > 1,2,3,4,4,4,5,5+3 > 成功度(4),1の目(1)"
success = true
critical = true
rands = [
{ sides = 6, value = 6 },
{ sides = 6, value = 4 },
{ sides = 6, value = 5 },
{ sides = 6, value = 4 },
{ sides = 6, value = 3 },
Expand All @@ -34,8 +34,24 @@ rands = [

[[ test ]]
game_system = "FullFace"
input = "8FF<=3 成功度及び1の目及びバースト"
output = "(8FF<=3) > 6,5,4,3,2,1,6,5+4 > 成功度(3),1の目(1),バースト"
input = "8FF<=3 成功度及び6の目"
output = "(8FF<=3) > 2,2,3,4,4,5,5,6 > 成功度(3),6の目(1)"
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の目及び6の目及びバースト"
output = "(8FF<=3) > 1,2,3,4,5,5,6,6+4 > 成功度(3),1の目(1),6の目(2),バースト"
fumble = true
failure = true
rands = [
Expand All @@ -53,7 +69,7 @@ rands = [
[[ test ]]
game_system = "FullFace"
input = "8FF<=3 成功度及び1の目及びバーストせず"
output = "(8FF<=3) > 6,5,4,3,2,1,5,4+6 > 成功度(3),1の目(1)"
output = "(8FF<=3) > 1,2,3,4,4,5,5,6+6 > 成功度(3),1の目(1),6の目(1)"
success = true
critical = true
rands = [
Expand All @@ -71,7 +87,7 @@ rands = [
[[ test ]]
game_system = "FullFace"
input = "8FF<=3 多重1の目"
output = "(8FF<=3) > 6,5,4,3,2,1,5,4+1+3 > 成功度(5),1の目(2)"
output = "(8FF<=3) > 1,2,3,4,4,5,5,6+1+3 > 成功度(5),1の目(2),6の目(1)"
success = true
critical = true
rands = [
Expand All @@ -90,7 +106,7 @@ rands = [
[[ test ]]
game_system = "FullFace"
input = "FF<=3 一般判定"
output = "(3FF<=3) > 6,5,4 > 成功度(0)"
output = "(3FF<=3) > 4,5,6 > 成功度(0),6の目(1)"
failure = true
rands = [
{ sides = 6, value = 6 },
Expand All @@ -101,13 +117,73 @@ rands = [
[[ test ]]
game_system = "FullFace"
input = "+2FF<=3 一般判定"
output = "(3+2FF<=3) > 6,5,4+3,2 > 成功度(2)"
output = "(3+2FF<=3) > 4,5,6+2,3 > 成功度(2),6の目(1)"
success = true
rands = [
{ sides = 6, value = 6 },
{ sides = 6, value = 5 },
{ sides = 6, value = 4 },
{ sides = 6, value = 3 },
{ sides = 6, value = 2 },
]

[[ test ]]
game_system = "FullFace"
input = "FF<=3,1 能力判定、失敗"
output = "(3FF<=3,1) > 4,5,6 > 成功度(0),6の目(1),失敗"
failure = true
rands = [
{ sides = 6, value = 6 },
{ sides = 6, value = 5 },
{ sides = 6, value = 4 },
]

[[ test ]]
game_system = "FullFace"
input = "FF<=3,1 能力判定、成功"
output = "(3FF<=3,1) > 3,4,5 > 成功度(1),成功"
success = true
rands = [
{ sides = 6, value = 5 },
{ sides = 6, value = 4 },
{ sides = 6, value = 3 },
]

[[ test ]]
game_system = "FullFace"
input = "8FF<=3&1 ダメージ計算"
output = "(8FF<=3&1) > 1,2,3,4,4,5,5,6+1+3 > 成功度(5),1の目(2),6の目(1),ダメージ(3)"
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 = "8FF<=3,2&1 ダメージ計算"
output = "(8FF<=3,2&1) > 1,2,3,4,4,5,5,6+1+3 > 成功度(5),1の目(2),6の目(1),成功,ダメージ(3)"
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 },
]

Loading