Skip to content

Commit

Permalink
Merge pull request #487 from bcdice/ToshiakiHolyGrailWar
Browse files Browse the repository at this point in the history
としあきの聖杯戦争TRPG を追加
  • Loading branch information
ysakasin authored Jul 28, 2021
2 parents 53c15a2 + a19bce8 commit ebbd965
Show file tree
Hide file tree
Showing 3 changed files with 557 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 @@ -192,6 +192,7 @@
require "bcdice/game_system/Torg"
require "bcdice/game_system/Torg1_5"
require "bcdice/game_system/TorgEternity"
require "bcdice/game_system/ToshiakiHolyGrailWar"
require "bcdice/game_system/TrinitySeven"
require "bcdice/game_system/TunnelsAndTrolls"
require "bcdice/game_system/TwilightGunsmoke"
Expand Down
92 changes: 92 additions & 0 deletions lib/bcdice/game_system/ToshiakiHolyGrailWar.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# frozen_string_literal: true

module BCDice
module GameSystem
class ToshiakiHolyGrailWar < Base
# ゲームシステムの識別子
ID = 'ToshiakiHolyGrailWar'
# ゲームシステム名
NAME = 'としあきの聖杯戦争TRPG'
# ゲームシステム名の読みがな
SORT_KEY = 'としあきのせいはいせんそうTRPG'
# ダイスボットの使い方
HELP_MESSAGE = <<~INFO_MESSAGE_TEXT
■ 判定 (Fx+y-z@a>=t)
補正値ペナルティを自動計算してダイスの面数を決定しダイスロールを実行します。
ダイス面数は2以上、10以下の範囲に制限されます。
x: ステータス
y: 補正値 (任意)
z: マイナス補正値 (任意)
a: ダイス面数の増量 (任意)
t: 目標値 (任意)
例)
F8+11, F8+11-5, F8+11-5@1, F8+11+9-3-2@-1, F8+11-5>=50, F8
INFO_MESSAGE_TEXT

register_prefix('F')

def eval_game_system_specific_command(command)
roll_f(command)
end

private

def roll_f(command)
parser = Command::Parser.new(/F(\d+)(\+\d+)*(-\d+)*/, round_type: RoundType::CEIL)
.disable_modifier
.enable_critical
cmd = parser.parse(command)
unless cmd
return nil
end

m = cmd.command.match(/^F(\d+)((?:\+\d+)+)?((?:-\d+)+)?$/)
unless m
return nil
end

status = m[1].to_i
positive_modifier = m[2] ? Arithmetic.eval(m[2], RoundType::CEIL) : 0
negative_modifier = m[3] ? Arithmetic.eval(m[3], RoundType::CEIL) : 0
side_bonus = cmd.critical || 0

times = [status + positive_modifier + negative_modifier, 0].max
sides = (6 - positive_modifier_penalty(positive_modifier) + negative_modifier_bonus(negative_modifier) + side_bonus).clamp(2, 10)

list = @randomizer.roll_barabara(times, sides)
total = list.sum()
result =
if cmd.cmp_op.nil?
Result.new
elsif total.send(cmd.cmp_op, cmd.target_number)
Result.success("成功")
else
Result.failure("失敗")
end

sequence = [
cmd,
"(#{times}D#{sides}#{cmd.cmp_op}#{cmd.target_number})",
"#{total}[#{list.join(',')}]",
total,
result.text,
].compact

result.text = sequence.join(" > ")
return result
end

def positive_modifier_penalty(modifier)
if modifier <= 10
0
else
modifier / 10
end
end

def negative_modifier_bonus(modifier)
modifier <= -5 ? 1 : 0
end
end
end
end
Loading

0 comments on commit ebbd965

Please sign in to comment.