Skip to content

Commit

Permalink
マモノスクランブル を追加
Browse files Browse the repository at this point in the history
  • Loading branch information
ysakasin committed Aug 4, 2023
1 parent 1b1565b commit 275fcd8
Show file tree
Hide file tree
Showing 3 changed files with 232 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 @@ -134,6 +134,7 @@
require "bcdice/game_system/MagicaLogia"
require "bcdice/game_system/MagicaLogia_Korean"
require "bcdice/game_system/MagicaLogia_SimplifiedChinese"
require "bcdice/game_system/MamonoScramble"
require "bcdice/game_system/MeikyuDays"
require "bcdice/game_system/MeikyuKingdom"
require "bcdice/game_system/MeikyuKingdomBasic"
Expand Down
95 changes: 95 additions & 0 deletions lib/bcdice/game_system/MamonoScramble.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# frozen_string_literal: true

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

# ゲームシステム名
NAME = 'マモノスクランブル'

# ゲームシステム名の読みがな
SORT_KEY = 'まものすくらんふる'

# ダイスボットの使い方
HELP_MESSAGE = <<~INFO_MESSAGE_TEXT
・判定 xMS<=t
 [判定]を行う。成否と[マリョク]の上昇量を表示する。
 x: ダイス数
 t: 能力値(目標値)
INFO_MESSAGE_TEXT

def initialize(command)
super(command)

@sides_implicit_d = 12
end

def eval_game_system_specific_command(command)
roll_ability(command) || roll_tables(command, TABLES)
end

private

def roll_ability(command)
parser = Command::Parser.new("MS", round_type: @round_type)
.has_prefix_number
.disable_modifier
.restrict_cmp_op_to(:<=)
parsed = parser.parse(command)
unless parsed
return nil
end

dice_list = @randomizer.roll_barabara(parsed.prefix_number, 12).sort
count_success = dice_list.count { |value| value <= parsed.target_number }
count_one = dice_list.count(1)
is_critical = count_one > 0
has_twelve = dice_list.include?(12)

maryoku =
if has_twelve && !is_critical
0
else
count_success + count_one
end

sequence = [
"(#{parsed})",
"[#{dice_list.join(',')}]",
count_success > 0 ? "成功, [マリョク]が#{maryoku}上がる" : "失敗"
]

return Result.new.tap do |r|
r.text = sequence.join(" > ")
r.condition = count_success > 0
r.critical = r.success? && is_critical
end
end

TABLES = {
"ACC" => DiceTable::Table.new(
"アクシデント表",
"1D12",
[
"思わぬ対立:[判定]で10〜12の出目を1個でも出した場合、【耐久値】を2点減らす。",
"都市の迷宮化:[判定]に【社会】を使用できない。",
"不穏な天気:特別な効果は発生しない。",
"突然の雷雨:エリアの[特性]に[雨]や[水たまり]などを足してもいい。",
"関係ない危機:[判定]に失敗したPCの【耐久値】を2点減らす。",
"からりと晴天:エリアの[特性]に[強い日光]や[日だまり]などを足してもいい。",
"謎のお祭り:[判定]で1〜3の出目を1個でも出した場合、【耐久値】を2点回復する。",
"すごい人ごみ:エリアの[特性]に[野次馬]や[観光客]などを足してもいい。",
"マリョク乱気流:[判定]に【異質】を使用できない。",
"魔術テロ事件:GMが1Dをロールする。出目が1〜3なら【身体】、出目が4〜6なら【異質】、出目が7〜9なら【社会】が[判定]で使えない。10〜12は何も起きない。",
"マリョク低気圧:[判定]に【身体】を使用できない。",
"平穏な時間:特別な効果は発生しない。",
]
)
}.freeze

register_prefix('\d+MS', TABLES.keys)
end
end
end
136 changes: 136 additions & 0 deletions test/data/MamonoScramble.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
[[ test ]]
game_system = "MamonoScramble"
input = "1MS<=6"
output = "(1MS<=6) > [6] > 成功, [マリョク]が1上がる"
success = true
rands = [
{ sides = 12, value = 6 },
]

[[ test ]]
game_system = "MamonoScramble"
input = "1MS<=6"
output = "(1MS<=6) > [1] > 成功, [マリョク]が2上がる"
success = true
critical = true
rands = [
{ sides = 12, value = 1 },
]

[[ test ]]
game_system = "MamonoScramble"
input = "1MS<=6"
output = "(1MS<=6) > [7] > 失敗"
failure = true
rands = [
{ sides = 12, value = 7 },
]

[[ test ]]
game_system = "MamonoScramble"
input = "2MS<=6"
output = "(2MS<=6) > [6,7] > 成功, [マリョク]が1上がる"
success = true
rands = [
{ sides = 12, value = 7 },
{ sides = 12, value = 6 },
]

[[ test ]]
game_system = "MamonoScramble"
input = "2MS<=6"
output = "(2MS<=6) > [4,5] > 成功, [マリョク]が2上がる"
success = true
rands = [
{ sides = 12, value = 4 },
{ sides = 12, value = 5 },
]

[[ test ]]
game_system = "MamonoScramble"
input = "2MS<=6"
output = "(2MS<=6) > [4,12] > 成功, [マリョク]が0上がる"
success = true
rands = [
{ sides = 12, value = 4 },
{ sides = 12, value = 12 },
]

[[ test ]]
game_system = "MamonoScramble"
input = "2MS<=6"
output = "(2MS<=6) > [1,12] > 成功, [マリョク]が2上がる"
success = true
critical = true
rands = [
{ sides = 12, value = 1 },
{ sides = 12, value = 12 },
]

[[ test ]]
game_system = "MamonoScramble"
input = "2MS<=6"
output = "(2MS<=6) > [1,7] > 成功, [マリョク]が2上がる"
success = true
critical = true
rands = [
{ sides = 12, value = 1 },
{ sides = 12, value = 7 },
]

[[ test ]]
game_system = "MamonoScramble"
input = "2MS<=6"
output = "(2MS<=6) > [1,1] > 成功, [マリョク]が4上がる"
success = true
critical = true
rands = [
{ sides = 12, value = 1 },
{ sides = 12, value = 1 },
]

[[ test ]]
game_system = "MamonoScramble"
input = "2MS<=6"
output = "(2MS<=6) > [7,12] > 失敗"
failure = true
rands = [
{ sides = 12, value = 7 },
{ sides = 12, value = 12 },
]

[[ test ]]
game_system = "MamonoScramble"
input = "3MS<=10"
output = "(3MS<=10) > [1,5,12] > 成功, [マリョク]が3上がる"
success = true
critical = true
rands = [
{ sides = 12, value = 1 },
{ sides = 12, value = 5 },
{ sides = 12, value = 12 },
]

[[ test ]]
game_system = "MamonoScramble"
input = "ACC"
output = "アクシデント表(1) > 思わぬ対立:[判定]で10〜12の出目を1個でも出した場合、【耐久値】を2点減らす。"
rands = [
{ sides = 12, value = 1 },
]

[[ test ]]
game_system = "MamonoScramble"
input = "ACC"
output = "アクシデント表(6) > からりと晴天:エリアの[特性]に[強い日光]や[日だまり]などを足してもいい。"
rands = [
{ sides = 12, value = 6 },
]

[[ test ]]
game_system = "MamonoScramble"
input = "ACC"
output = "アクシデント表(12) > 平穏な時間:特別な効果は発生しない。"
rands = [
{ sides = 12, value = 12 },
]

0 comments on commit 275fcd8

Please sign in to comment.