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

SRSじゃない世界樹の迷宮TRPGに対応 #284

Merged
merged 9 commits into from
Nov 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

### 対応ゲームシステムの追加
- SRSじゃない世界樹の迷宮TRPG (NSSQ): TTさんありがとうっ! ([#284](https://github.com/bcdice/BCDice/pull/284))

### 追加機能
- ログ・ホライズンTRPG: LHZB1とLHZB2両方の財宝表をサポート、消耗表ロールを追加、財宝表ロールを追加、区切り文字を変更 ([#279](https://github.com/bcdice/BCDice/pull/279))

Expand Down
1 change: 1 addition & 0 deletions lib/bcdice/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
require "bcdice/dice_table"
require "bcdice/enum"
require "bcdice/translate"
require "bcdice/command_parser"

module BCDice
class Base
Expand Down
1 change: 1 addition & 0 deletions lib/bcdice/game_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
require "bcdice/game_system/NightmareHunterDeep"
require "bcdice/game_system/NinjaSlayer"
require "bcdice/game_system/NjslyrBattle"
require "bcdice/game_system/NSSQ"
require "bcdice/game_system/Nuekagami"
require "bcdice/game_system/OneWayHeroics"
require "bcdice/game_system/OracleEngine"
Expand Down
159 changes: 159 additions & 0 deletions lib/bcdice/game_system/NSSQ.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
# frozen_string_literal: true

module BCDice
module GameSystem
class NSSQ < Base
ID = "NSSQ"
NAME = "SRSじゃない世界樹の迷宮TRPG"
SORT_KEY = "えすああるえすしやないせかいしゆのめいきゆうTRPG"

HELP_MESSAGE = <<~MESSAGETEXT
■ 判定 (xSQ±y)
xD6の判定。3つ以上振ったとき、出目の高い2つを表示します。クリティカル、ファンブルも計算します。
±y: yに修正値を入力。±の計算に対応。省略可能。

■ ダメージロール (xDR(C)(+)y)
xD6のダメージロール。クリティカルの自動判定を行います。Cを付けるとクリティカルアップ状態で計算できます。+を付けるとクリティカル時のダイスが8個になります。
x: xに振るダイス数を入力。
y: yに耐性を入力。
例) 5DR3 5DRC4 5DRC+4

■ 回復ロール (xHRy)
xD6の回復ロール。クリティカルが発生しません。
x: xに振るダイス数を入力。
y: yに耐性を入力。省略した場合3。
例) 2HR 10HR2

■ 採取ロール (TC±z,SC±z,GC±z)
ちょっと(T)、そこそこ(S)、がっつり(G)採取採掘伐採を行う。
z: zに追加でロールする回数を入力。省略可能。
例) TC SC+1 GC-1
MESSAGETEXT

register_prefix('\d+SQ[\+\-\d]*', '\d+DR(C)?(\+)?\d+', '[TSG]C', '\d+HR\d*')

def eval_game_system_specific_command(command)
roll_sq(command) || damage_roll(command) || heal_roll(command) || collecting_roll(command)
end

private

# 判定
def roll_sq(command)
m = /(\d+)SQ([\+\-\d]+)?/i.match(command)
return nil unless m

dice_count = m[1].to_i
modifier = ArithmeticEvaluator.eval(m[2])

dice_list = @randomizer.roll_barabara(dice_count, 6)
largest_two = dice_list.sort.reverse.take(2)
total = largest_two.sum + modifier

additional_result =
if largest_two == [6, 6]
" クリティカル!"
elsif largest_two == [1, 1]
" ファンブル!"
end

sequence = [
"(#{command})",
"[#{dice_list.join(',')}]#{Format.modifier(modifier)}",
"#{total}[#{largest_two.join(',')}]#{additional_result}",
]

return sequence.join(" > ")
end

# ダメージロール
def damage_roll(command)
m = /(\d+)DR(C)?(\+)?(\d+)/i.match(command)
return nil unless m

dice_count = m[1].to_i
critical_up = !m[2].nil? # 強化効果 クリティカルアップ
increase_critical_dice = !m[3].nil?
resist = m[4].to_i

dice_list = @randomizer.roll_barabara(dice_count, 6)

result = "(#{command}) > [#{dice_list.join(',')}]#{resist} > #{damage(dice_list, resist)}ダメージ"

critical_target = critical_up ? 1 : 2

if dice_list.count(6) - dice_list.count(1) >= critical_target
result += " クリティカル!\n"
result += additional_damage_roll(increase_critical_dice, resist)
end

return result
end

def additional_damage_roll(increase_critical_dice, resist)
dice_count = increase_critical_dice ? 8 : 4

dice_list = @randomizer.roll_barabara(dice_count, 6)
"(#{dice_count}DR#{resist}) > [#{dice_list.join(',')}]#{resist} > #{damage(dice_list, resist)}ダメージ"
end

# 回復ロール
def heal_roll(command)
m = /^(\d+)HR(\d+)?$/i.match(command)
return nil unless m

dice_count = m[1].to_i
resist = m[2]&.to_i || 3

dice_list = @randomizer.roll_barabara(dice_count, 6)

return "(#{command}) > [#{dice_list.join(',')}]#{resist} > #{damage(dice_list, resist)}回復"
end

def damage(dice_list, resist)
dice_list.count { |x| x > resist }
end

# 採取ロール
def collecting_roll(command)
m = /([TSG])C([\+\-\d]+)?/i.match(command)
return nil unless m

type = m[1]
modifier = ArithmeticEvaluator.eval(m[2])

aatto_param =
case type
when "T"
3
when "S"
4
when "G"
5
end

roll_times = aatto_param - 2 + modifier
return nil if roll_times <= 0

results = Array.new(roll_times) do |i|
dice_list = @randomizer.roll_barabara(2, 6)
dice = dice_list.sum()

"(#{command}) > #{dice}[#{dice_list.join(',')}]: #{result_collecting(i, dice, aatto_param)}"
end

results.join("\n")
end

def result_collecting(i, dice, aatto)
if (dice <= aatto) && (aatto - 2 > i)
"!ああっと!"
elsif aatto - 2 <= i
"成功(追加分)"
else
"成功"
end
end
end
end
end
Loading