Skip to content

Commit

Permalink
Merge pull request #549 from h-mikisato/feature/add_sengensyou
Browse files Browse the repository at this point in the history
同人システムの千幻抄を追加
  • Loading branch information
ysakasin authored Aug 20, 2022
2 parents 6055466 + 23da11f commit d052631
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/bcdice/game_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
require "bcdice/game_system/SamsaraBallad"
require "bcdice/game_system/Satasupe"
require "bcdice/game_system/ScreamHighSchool"
require "bcdice/game_system/Sengensyou"
require "bcdice/game_system/SevenFortressMobius"
require "bcdice/game_system/ShadowRun"
require "bcdice/game_system/ShadowRun4"
Expand Down
59 changes: 59 additions & 0 deletions lib/bcdice/game_system/Sengensyou.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# frozen_string_literal: true

module BCDice
module GameSystem
class Sengensyou < Base
# ゲームシステムの識別子
ID = 'Sengensyou'

# ゲームシステム名
NAME = '千幻抄'

# ゲームシステム名の読みがな
SORT_KEY = 'せんけんしよう'

# ダイスボットの使い方
HELP_MESSAGE = <<~INFO_MESSAGE_TEXT
・SGS 命中判定・回避判定
INFO_MESSAGE_TEXT

register_prefix('SGS')

def eval_game_system_specific_command(command)
# 命中判定・回避判定
parser = Command::Parser.new('SGS', round_type: @round_type).restrict_cmp_op_to(nil)
command = parser.parse(command)

unless command
return nil
end

dice_list = @randomizer.roll_barabara(3, 6)
dice_total = dice_list.sum()
is_critical = dice_total >= 16
is_fumble = dice_total <= 5
additional_text =
if is_critical
"クリティカル"
elsif is_fumble
"ファンブル"
end
modify_text = "#{dice_total}#{Format.modifier(command.modify_number)}" if command.modify_number != 0
sequence = [
"(3D6#{Format.modifier(command.modify_number)})",
"#{dice_total}[#{dice_list.join(',')}]",
modify_text,
(dice_total + command.modify_number).to_s,
additional_text,
].compact

result = Result.new.tap do |r|
r.text = sequence.join(" > ")
r.critical = is_critical
r.fumble = is_fumble
end
return result
end
end
end
end
69 changes: 69 additions & 0 deletions test/data/Sengensyou.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
[[ test ]]
game_system = "Sengensyou"
input = "SGS"
output = "(3D6) > 8[4,1,3] > 8"
rands = [
{ sides = 6, value = 4 },
{ sides = 6, value = 1 },
{ sides = 6, value = 3 },
]

[[ test ]]
game_system = "Sengensyou"
input = "SGS"
output = "(3D6) > 16[5,5,6] > 16 > クリティカル"
critical = true
rands = [
{ sides = 6, value = 5 },
{ sides = 6, value = 5 },
{ sides = 6, value = 6 },
]

[[ test ]]
game_system = "Sengensyou"
input = "SGS"
output = "(3D6) > 5[1,2,2] > 5 > ファンブル"
fumble = true
rands = [
{ sides = 6, value = 1 },
{ sides = 6, value = 2 },
{ sides = 6, value = 2 },
]

[[ test ]]
game_system = "Sengensyou"
input = "SGS+4+6"
output = "(3D6+10) > 8[4,1,3] > 8+10 > 18"
rands = [
{ sides = 6, value = 4 },
{ sides = 6, value = 1 },
{ sides = 6, value = 3 },
]

[[ test ]]
game_system = "Sengensyou"
input = "SGS+4+6"
output = "(3D6+10) > 16[5,5,6] > 16+10 > 26 > クリティカル"
critical = true
rands = [
{ sides = 6, value = 5 },
{ sides = 6, value = 5 },
{ sides = 6, value = 6 },
]

[[ test ]]
game_system = "Sengensyou"
input = "SGS+4+6"
output = "(3D6+10) > 5[1,2,2] > 5+10 > 15 > ファンブル"
fumble = true
rands = [
{ sides = 6, value = 1 },
{ sides = 6, value = 2 },
{ sides = 6, value = 2 },
]

[[ test ]]
game_system = "Sengensyou"
input = "SGS>=5"
output = ""
rands = []

0 comments on commit d052631

Please sign in to comment.