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

[CastleInGray] 『灰色城綺譚』 CASTLE IN GRAY The Haunted Palace #495

Merged
merged 4 commits into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -27,6 +27,7 @@
require "bcdice/game_system/BloodCrusade"
require "bcdice/game_system/BloodMoon"
require "bcdice/game_system/CardRanker"
require "bcdice/game_system/CastleInGray"
require "bcdice/game_system/ChaosFlare"
require "bcdice/game_system/Chill"
require "bcdice/game_system/Chill3"
Expand Down
129 changes: 129 additions & 0 deletions lib/bcdice/game_system/CastleInGray.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
module BCDice
module GameSystem
class CastleInGray < Base
# ゲームシステムの識別子
ID = "CastleInGray".freeze

# ゲームシステム名
NAME = "灰色城綺譚".freeze

# ゲームシステム名の読みがな
SORT_KEY = "はいいろしようきたん".freeze

HELP_MESSAGE = <<~TEXT.freeze
■ 色占い (BnWm)
n: 黒
m: 白
n, m は1~12の異なる整数

例) B12W7
例) B5W12

■ 悪意の渦による占い (MALn)
n: 悪意の渦
n は1~12の整数

■ その他
・感情表 ET
・暗示表(黒) BIT
・暗示表(白) WIT
TEXT
TABLES = {
"ET" => DiceTable::Table.new(
"感情表",
"1D12",
[
"友情(白)/敵視(黒)",
"恋慕(白)/嫌悪(黒)",
"信頼(白)/不信(黒)",
"同情(白)/憐憫(黒)",
"憧憬(白)/劣等感(黒)",
"尊敬(白)/蔑視(黒)",
"忠誠(白)/執着(黒)",
"有用(白)/邪魔(黒)",
"許容(白)/罪悪感(黒)",
"羨望(白)/嫉妬(黒)",
"共感(白)/拒絶(黒)",
"愛情(白)/狂信(黒)"
]
),
"BIT" => DiceTable::Table.new(
"暗示表(黒)",
"1D12",
[
"終わりなき夜に生まれつく者もあり",
"悪意もて真実を語らば",
"笑えども笑みはなし",
"影より抜け出ることあたわじ",
"心の赴くままに手をとれ",
"時ならぬ嵐の過ぎ去るを待つ",
"赦されぬと知るがゆえに",
"見張りは持ち場を離れる",
"誰もが盲いたる彷徨い人なり",
"落ちる日を眺めるがごとく",
"冷たく雨ぞ降りしきる",
"今日は笑む花も明日には枯れゆく"
]
),
"WIT" => DiceTable::Table.new(
"暗示表(白)",
"1D12",
[
"無垢なる者のみが真実を得る",
"げに慈悲深きは沈黙なり",
"懐かしき日々は去りぬ",
"束の間に光さす",
"迷える者に手を差し伸べよ",
"嵐の前には静けさがある",
"どうか責めないで",
"灯した明かりを絶やさぬように",
"目を開けて見よ",
"淑やかに訪れる",
"今こそ泣け、さもなくば二度と泣くな",
"時が許す間に薔薇を摘め"
]
),
}.freeze

register_prefix('B(1|2|3|4|5|6|7|8|9|10|11|12)W(1|2|3|4|5|6|7|8|9|10|11|12)', 'MAL(1|2|3|4|5|6|7|8|9|10|11|12)', TABLES.keys)

def eval_game_system_specific_command(command)
return roll_color(command) || roll_mal(command) || roll_tables(command, TABLES)
end

def roll_color(command)
m = /^B(1|2|3|4|5|6|7|8|9|10|11|12)W(1|2|3|4|5|6|7|8|9|10|11|12)$/.match(command)
return nil unless m

black = m[1].to_i
white = m[2].to_i

value = @randomizer.roll_once(12)

if black == white
return color_text(black, white, value, '白と黒は重ねられません')
end

if white > black
return color_text(black, white, value, value < black || value >= white ? '白' : '黒')
else
return color_text(black, white, value, value >= white && value < black ? '白' : '黒')
end
end

def color_text(black, white, value, result)
return "色占い(黒#{black}白#{white}) > [#{value}] > #{result}"
end

def roll_mal(command)
m = /^MAL(1|2|3|4|5|6|7|8|9|10|11|12)$/i.match(command)
return nil unless m

mal = m[1].to_i
value = @randomizer.roll_once(12)
result = value <= mal ? '黒' : '白'
return "悪意の渦(#{mal}) > [#{value}] > #{result}"
end
end
end
end
129 changes: 129 additions & 0 deletions test/data/CastleInGray.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
[[ test ]]
game_system = "CastleInGray"
input = "B10W10"
output = "色占い(黒10白10) > [10] > 白と黒は重ねられません"
rands = [
{ sides = 12, value = 10 },
]

[[ test ]]
game_system = "CastleInGray"
input = "B10W5"
output = "色占い(黒10白5) > [11] > 黒"
rands = [
{ sides = 12, value = 11 },
]

[[ test ]]
game_system = "CastleInGray"
input = "B10W5"
output = "色占い(黒10白5) > [7] > 白"
rands = [
{ sides = 12, value = 7 },
]

[[ test ]]
game_system = "CastleInGray"
input = "B10W5"
output = "色占い(黒10白5) > [5] > 白"
rands = [
{ sides = 12, value = 5 },
]

[[ test ]]
game_system = "CastleInGray"
input = "B10W5"
output = "色占い(黒10白5) > [10] > 黒"
rands = [
{ sides = 12, value = 10 },
]

[[ test ]]
game_system = "CastleInGray"
input = "B9W12"
output = "色占い(黒9白12) > [11] > 黒"
rands = [
{ sides = 12, value = 11 },
]

[[ test ]]
game_system = "CastleInGray"
input = "B9W12"
output = "色占い(黒9白12) > [4] > 白"
rands = [
{ sides = 12, value = 4 },
]

[[ test ]]
game_system = "CastleInGray"
input = "MAL1"
output = "悪意の渦(1) > [1] > 黒"
rands = [
{ sides = 12, value = 1 },
]


[[ test ]]
game_system = "CastleInGray"
input = "MAL1"
output = "悪意の渦(1) > [2] > 白"
rands = [
{ sides = 12, value = 2 },
]


[[ test ]]
game_system = "CastleInGray"
input = "MAL5"
output = "悪意の渦(5) > [11] > 白"
rands = [
{ sides = 12, value = 11 },
]

[[ test ]]
game_system = "CastleInGray"
input = "MAL5"
output = "悪意の渦(5) > [3] > 黒"
rands = [
{ sides = 12, value = 3 },
]

[[ test ]]
game_system = "CastleInGray"
input = "MAL5"
output = "悪意の渦(5) > [5] > 黒"
rands = [
{ sides = 12, value = 5 },
]

[[ test ]]
game_system = "CastleInGray"
input = "MAL5"
output = "悪意の渦(5) > [6] > 白"
rands = [
{ sides = 12, value = 6 },
]

[[ test ]]
game_system = "CastleInGray"
input = "MAL12"
output = "悪意の渦(12) > [12] > 黒"
rands = [
{ sides = 12, value = 12 },
]

[[ test ]]
game_system = "CastleInGray"
input = "MAL12"
output = "悪意の渦(12) > [3] > 黒"
rands = [
{ sides = 12, value = 3 },
]

[[ test ]]
game_system = "CastleInGray"
input = "MAL12"
output = "悪意の渦(12) > [3] > 黒"
rands = [
{ sides = 12, value = 3 },
]