Skip to content

Commit

Permalink
Merge pull request #663 from spore0814/Siren_Add
Browse files Browse the repository at this point in the history
「終末アイドル育成TRPGセイレーン」の追加
  • Loading branch information
ysakasin authored Dec 27, 2023
2 parents c8f3ed0 + aeb5040 commit 51bd98a
Show file tree
Hide file tree
Showing 3 changed files with 268 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 @@ -201,6 +201,7 @@
require "bcdice/game_system/Shiranui"
require "bcdice/game_system/ShoujoTenrankai"
require "bcdice/game_system/ShuumatsuKikou"
require "bcdice/game_system/Siren"
require "bcdice/game_system/Skynauts"
require "bcdice/game_system/SkynautsBouken"
require "bcdice/game_system/StarryDolls"
Expand Down
97 changes: 97 additions & 0 deletions lib/bcdice/game_system/Siren.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# frozen_string_literal: true

require 'bcdice/command/parser'

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

# ゲームシステム名
NAME = "終末アイドル育成TRPG セイレーン"

# ゲームシステム名の読みがな
SORT_KEY = "せいれえん"

HELP_MESSAGE = <<~TEXT
・判定: SL+a<=b±c
a=達成値への修正(0の場合は省略)
b=能力値
c=判定への修正(0の場合は省略、複数可)
例)判定修正-10の装備を装着しながら【技術:60】〈兵器:2〉で判定する場合。
SL+2<=60+40-10
・育成: TR$a<=b
a=育成した回数
b=ヘルス
例)ヘルスの現在値が60で2回目の【身体】の育成を行う場合。
TR$2<=60
TEXT

def eval_game_system_specific_command(command)
case command
when /^SL/ then check_action(command)
when /^TR/ then check_training(command)
else return nil
end
end

def check_action(command)
parser = Command::Parser.new('SL', round_type: @round_type).restrict_cmp_op_to(:<=)
parsed = parser.parse(command)
return nil if parsed.nil?

target = parsed.target_number

dice = @randomizer.roll_once(100)

if dice > target
return Result.failure("(1D100<=#{target}) > #{dice} > 失敗")
end

dig10 = dice / 10
dig1 = dice % 10
if dig10 == 0
dig10 = 10
end
if dig1 == 0
dig1 = 10
end
achievement_value = dig10 + dig1 + parsed.modify_number
return Result.success("(1D100<=#{target}) > #{dice} > 成功(達成値:#{achievement_value})")
end

def check_training(command)
parser = Command::Parser.new('TR', round_type: @round_type).restrict_cmp_op_to(:<=).enable_dollar.disable_modifier
parsed = parser.parse(command)
return nil if parsed.nil?

count = parsed.dollar
return nil if count.nil?

target = parsed.target_number

dice = @randomizer.roll_once(100)

dig10 = dice / 10
dig1 = dice % 10
if dig10 == 0
dig10 = 10
end
if dig1 == 0
dig1 = 10
end
achievement_value = dig10 + dig1

if dice > target
return Result.failure("(1D100<=#{target}) > #{dice} > 失敗(能力値減少:10 / ヘルス減少:#{achievement_value})")
end

return Result.success("(1D100<=#{target}) > #{dice} > 成功(能力値上昇:#{count * 5 + achievement_value} / ヘルス減少:#{achievement_value})")
end

register_prefix('SL', 'TR')
end
end
end
170 changes: 170 additions & 0 deletions test/data/Siren.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
[[ test ]]
game_system = "Siren"
input = "SL+2<=80"
output = "(1D100<=80) > 25 > 成功(達成値:9)"
success = true
rands = [
{ sides = 100, value = 25 },
]

[[ test ]]
game_system = "Siren"
input = "SL+2<=80"
output = "(1D100<=80) > 91 > 失敗"
failure = true
rands = [
{ sides = 100, value = 91 },
]

[[ test ]]
game_system = "Siren"
input = "TR$2<=60"
output = "(1D100<=60) > 27 > 成功(能力値上昇:19 / ヘルス減少:9)"
success = true
rands = [
{ sides = 100, value = 27 },
]

[[ test ]]
game_system = "Siren"
input = "TR$2<=60"
output = "(1D100<=60) > 74 > 失敗(能力値減少:10 / ヘルス減少:11)"
failure = true
rands = [
{ sides = 100, value = 74 },
]

[[ test ]]
game_system = "Siren"
input = "SL+2<=80"
output = "(1D100<=80) > 80 > 成功(達成値:20)"
success = true
rands = [
{ sides = 100, value = 80 },
]

[[ test ]]
game_system = "Siren"
input = "SL+2<=80"
output = "(1D100<=80) > 81 > 失敗"
failure = true
rands = [
{ sides = 100, value = 81 },
]

[[ test ]]
game_system = "Siren"
input = "SL<=80"
output = "(1D100<=80) > 25 > 成功(達成値:7)"
success = true
rands = [
{ sides = 100, value = 25 },
]

[[ test ]]
game_system = "Siren"
input = "SL+2<=80+10"
output = "(1D100<=90) > 90 > 成功(達成値:21)"
success = true
rands = [
{ sides = 100, value = 90 },
]

[[ test ]]
game_system = "Siren"
input = "SL+2<=80+10"
output = "(1D100<=90) > 91 > 失敗"
failure = true
rands = [
{ sides = 100, value = 91 },
]

[[ test ]]
game_system = "Siren"
input = "SL+2<=80"
output = "(1D100<=80) > 8 > 成功(達成値:20)"
success = true
rands = [
{ sides = 100, value = 8 },
]

[[ test ]]
game_system = "Siren"
input = "SL+2<=80"
output = "(1D100<=80) > 100 > 失敗"
failure = true
rands = [
{ sides = 100, value = 100 },
]

[[ test ]]
game_system = "Siren"
input = "SL<=120"
output = "(1D100<=120) > 100 > 成功(達成値:20)"
success = true
rands = [
{ sides = 100, value = 100 },
]

[[ test ]]
game_system = "Siren"
input = "TR$1<=80"
output = "(1D100<=80) > 16 > 成功(能力値上昇:12 / ヘルス減少:7)"
success = true
rands = [
{ sides = 100, value = 16 },
]

[[ test ]]
game_system = "Siren"
input = "TR$1<=80"
output = "(1D100<=80) > 84 > 失敗(能力値減少:10 / ヘルス減少:12)"
failure = true
rands = [
{ sides = 100, value = 84 },
]

[[ test ]]
game_system = "Siren"
input = "TR$2<=60"
output = "(1D100<=60) > 60 > 成功(能力値上昇:26 / ヘルス減少:16)"
success = true
rands = [
{ sides = 100, value = 60 },
]

[[ test ]]
game_system = "Siren"
input = "TR$2<=60"
output = "(1D100<=60) > 61 > 失敗(能力値減少:10 / ヘルス減少:7)"
failure = true
rands = [
{ sides = 100, value = 61 },
]

[[ test ]]
game_system = "Siren"
input = "TR$2<=60"
output = "(1D100<=60) > 4 > 成功(能力値上昇:24 / ヘルス減少:14)"
success = true
rands = [
{ sides = 100, value = 4 },
]

[[ test ]]
game_system = "Siren"
input = "TR$2<=60"
output = "(1D100<=60) > 70 > 失敗(能力値減少:10 / ヘルス減少:17)"
failure = true
rands = [
{ sides = 100, value = 70 },
]

[[ test ]]
game_system = "Siren"
input = "TR$2<=60"
output = "(1D100<=60) > 100 > 失敗(能力値減少:10 / ヘルス減少:20)"
failure = true
rands = [
{ sides = 100, value = 100 },
]

0 comments on commit 51bd98a

Please sign in to comment.