Skip to content

Commit

Permalink
[Irisbane] シルエットライン(p37)のダイスロールを実装
Browse files Browse the repository at this point in the history
  • Loading branch information
ViVi committed Jun 25, 2021
1 parent c0022bb commit ae2c15f
Show file tree
Hide file tree
Showing 2 changed files with 235 additions and 1 deletion.
71 changes: 70 additions & 1 deletion lib/bcdice/game_system/Irisbane.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ class Irisbane < Base
■シチュエーション(p115)
SceneSituation, SSi
■シルエットライン(p37)
SilhouetteLineEye, SilhouetteLEye, SLineEye, SLEye 瞳の印象
SilhouetteLineHair, SilhouetteLHair, SLineHair, SLHair 髪の長さ
SilhouetteLineHeight, SilhouetteLHeight, SLineHeight, SLHeight 身長
SilhouetteLineCon, SilhouetteLCon, SLineCon, SLCon 体型
SilhouetteLineDress, SilhouetteLDress, SLineDress, SLDress 服飾
SilhouetteLineTint, SilhouetteLTint, SLineTint, SLTint 色彩
□シルエットライン一括
SilhouetteLine, SilhouetteL, SLine
■そのほかの表
CAge 年齢(p27)
CGender 性別(p27)
Expand All @@ -50,6 +61,9 @@ class Irisbane < Base
ATTACK_ROLL_REG = %r{^AT(TACK|K)?([+\-*/()\d]+),([+\-*/()\d]+),([+\-*/()\d]+)(\[([+\-])([+\-*/()\d]+)\])?}i.freeze
register_prefix('AT(TACK|K)?')

SILHOUETTE_LINE_REG = /^(S(ilhouette)?L(ine)?(Eye|Hair|Height|Constitution|Dress|Tint)|S(ilhouette)?Line|SilhouetteL)/i.freeze
register_prefix('S(ilhouette)?L(ine)?')

def initialize(command)
super(command)

Expand All @@ -58,10 +72,18 @@ def initialize(command)
end

def eval_game_system_specific_command(command)
command = ALIAS[command] || command

if (m = ATTACK_ROLL_REG.match(command))
roll_attack(m[2], m[3], m[4], m[6], m[7])
elsif (m = SILHOUETTE_LINE_REG.match(command))
if m[4].nil?
roll_silhouette_line_all
else
roll_silhouette_line(m[4])
end
else
roll_tables(ALIAS[command] || command, TABLES)
roll_tables(command, TABLES)
end
end

Expand Down Expand Up @@ -127,6 +149,49 @@ def parse_operator(operator)
end
end

def roll_silhouette_line_all
"シルエットライン:\n" + (SILHOUETTE_LINES.values.map do |sl|
r = sl.roll(@randomizer)
"#{r[:simple]} #{r[:name]}"
end).join("\n")
end

def roll_silhouette_line(kind)
SILHOUETTE_LINES[kind].roll(@randomizer)[:full]
end

class SilhouetteLine
def initialize(name, left, right)
@name = name.freeze
@left = left.freeze
@right = right.freeze
end

def roll(randomizer)
dice = randomizer.roll_once(6)
line = self.class.make_line(dice)

{
name: @name,
full: "シルエットライン:#{@name}(#{dice}) > 【#{@left}#{line}#{@right}】",
simple: "【#{@left[0...2]}#{line}#{@right[0...2]}】",
}
end

def self.make_line(dice)
("-" * (dice - 1)) + "○" + ("-" * (6 - dice))
end
end

SILHOUETTE_LINES = {
"Eye" => SilhouetteLine.new("瞳の印象", "鋭利", "柔和"),
"Hair" => SilhouetteLine.new("髪の長さ", "短い", "長い"),
"Height" => SilhouetteLine.new("身長", "低い", "高い"),
"Constitution" => SilhouetteLine.new("体型", "小柄", "大柄"),
"Dress" => SilhouetteLine.new("服飾", "簡素 / シンプル", "派手 / ゴージャス"),
"Tint" => SilhouetteLine.new("色彩", "単色 / シンプル", "多色 / カラフル"),
}.transform_keys(&:upcase).freeze

TABLES = {
"CAGE" => DiceTable::Table.new(
"年齢",
Expand Down Expand Up @@ -302,6 +367,10 @@ def parse_operator(operator)
"CEmbStyle" => "CEmblaceStyle",
"EEx" => "ExpectExecution",
"SSi" => "SceneSituation",
"SilhouetteLineCon" => "SilhouetteLineConstitution",
"SLineCon" => "SLineConstitution",
"SilhouetteLCon" => "SilhouetteLConstitution",
"SLCon" => "SLConstitution",
}.transform_keys(&:upcase).transform_values(&:upcase).freeze

register_prefix(TABLES.keys, ALIAS.keys)
Expand Down
165 changes: 165 additions & 0 deletions test/data/Irisbane.toml
Original file line number Diff line number Diff line change
Expand Up @@ -652,3 +652,168 @@ rands = [
{ sides = 6, value = 5 },
{ sides = 6, value = 4 },
]

[[ test ]]
game_system = "Irisbane"
input = "SilhouetteLineEye"
output = "シルエットライン:瞳の印象(1) > 【鋭利】 ○----- 【柔和】"
rands = [
{ sides = 6, value = 1 },
]

[[ test ]]
game_system = "Irisbane"
input = "SLineEye"
output = "シルエットライン:瞳の印象(2) > 【鋭利】 -○---- 【柔和】"
rands = [
{ sides = 6, value = 2 },
]

[[ test ]]
game_system = "Irisbane"
input = "SilhouetteLEye"
output = "シルエットライン:瞳の印象(3) > 【鋭利】 --○--- 【柔和】"
rands = [
{ sides = 6, value = 3 },
]

[[ test ]]
game_system = "Irisbane"
input = "SLEye"
output = "シルエットライン:瞳の印象(4) > 【鋭利】 ---○-- 【柔和】"
rands = [
{ sides = 6, value = 4 },
]

[[ test ]]
game_system = "Irisbane"
input = "SLEye"
output = "シルエットライン:瞳の印象(5) > 【鋭利】 ----○- 【柔和】"
rands = [
{ sides = 6, value = 5 },
]

[[ test ]]
game_system = "Irisbane"
input = "SLEye"
output = "シルエットライン:瞳の印象(6) > 【鋭利】 -----○ 【柔和】"
rands = [
{ sides = 6, value = 6 },
]

[[ test ]]
game_system = "Irisbane"
input = "SLHair"
output = "シルエットライン:髪の長さ(4) > 【短い】 ---○-- 【長い】"
rands = [
{ sides = 6, value = 4 },
]

[[ test ]]
game_system = "Irisbane"
input = "SLHeight"
output = "シルエットライン:身長(4) > 【低い】 ---○-- 【高い】"
rands = [
{ sides = 6, value = 4 },
]

[[ test ]]
game_system = "Irisbane"
input = "SLConstitution"
output = "シルエットライン:体型(4) > 【小柄】 ---○-- 【大柄】"
rands = [
{ sides = 6, value = 4 },
]

[[ test ]]
game_system = "Irisbane"
input = "SilhouetteLineCon"
output = "シルエットライン:体型(1) > 【小柄】 ○----- 【大柄】"
rands = [
{ sides = 6, value = 1 },
]

[[ test ]]
game_system = "Irisbane"
input = "SLineCon"
output = "シルエットライン:体型(2) > 【小柄】 -○---- 【大柄】"
rands = [
{ sides = 6, value = 2 },
]

[[ test ]]
game_system = "Irisbane"
input = "SilhouetteLCon"
output = "シルエットライン:体型(3) > 【小柄】 --○--- 【大柄】"
rands = [
{ sides = 6, value = 3 },
]

[[ test ]]
game_system = "Irisbane"
input = "SLCon"
output = "シルエットライン:体型(4) > 【小柄】 ---○-- 【大柄】"
rands = [
{ sides = 6, value = 4 },
]

[[ test ]]
game_system = "Irisbane"
input = "SLDress"
output = "シルエットライン:服飾(4) > 【簡素 / シンプル】 ---○-- 【派手 / ゴージャス】"
rands = [
{ sides = 6, value = 4 },
]

[[ test ]]
game_system = "Irisbane"
input = "SLTint"
output = "シルエットライン:色彩(4) > 【単色 / シンプル】 ---○-- 【多色 / カラフル】"
rands = [
{ sides = 6, value = 4 },
]

[[ test ]]
game_system = "Irisbane"
input = "SilhouetteLine"
output = "シルエットライン:\n【鋭利】 ---○-- 【柔和】 瞳の印象\n【短い】 -○---- 【長い】 髪の長さ\n【低い】 ○----- 【高い】 身長\n【小柄】 ----○- 【大柄】 体型\n【簡素】 ---○-- 【派手】 服飾\n【単色】 -----○ 【多色】 色彩"
rands = [
{ sides = 6, value = 4 },
{ sides = 6, value = 2 },
{ sides = 6, value = 1 },
{ sides = 6, value = 5 },
{ sides = 6, value = 4 },
{ sides = 6, value = 6 },
]

[[ test ]]
game_system = "Irisbane"
input = "SilhouetteL"
output = "シルエットライン:\n【鋭利】 ---○-- 【柔和】 瞳の印象\n【短い】 -○---- 【長い】 髪の長さ\n【低い】 ○----- 【高い】 身長\n【小柄】 ----○- 【大柄】 体型\n【簡素】 ---○-- 【派手】 服飾\n【単色】 -----○ 【多色】 色彩"
rands = [
{ sides = 6, value = 4 },
{ sides = 6, value = 2 },
{ sides = 6, value = 1 },
{ sides = 6, value = 5 },
{ sides = 6, value = 4 },
{ sides = 6, value = 6 },
]

[[ test ]]
game_system = "Irisbane"
input = "SLine"
output = "シルエットライン:\n【鋭利】 ---○-- 【柔和】 瞳の印象\n【短い】 -○---- 【長い】 髪の長さ\n【低い】 ○----- 【高い】 身長\n【小柄】 ----○- 【大柄】 体型\n【簡素】 ---○-- 【派手】 服飾\n【単色】 -----○ 【多色】 色彩"
rands = [
{ sides = 6, value = 4 },
{ sides = 6, value = 2 },
{ sides = 6, value = 1 },
{ sides = 6, value = 5 },
{ sides = 6, value = 4 },
{ sides = 6, value = 6 },
]

[[ test ]]
game_system = "Irisbane"
input = "SL"
output = ""
rands = []

0 comments on commit ae2c15f

Please sign in to comment.