Skip to content
Open
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
1 change: 1 addition & 0 deletions lib/bcdice/game_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@
require "bcdice/game_system/Paradiso"
require "bcdice/game_system/Paranoia"
require "bcdice/game_system/ParanoiaRebooted"
require "bcdice/game_system/ParanoiaPerfect"
require "bcdice/game_system/ParasiteBlood"
require "bcdice/game_system/PastFutureParadox"
require "bcdice/game_system/Pathfinder"
Expand Down
74 changes: 74 additions & 0 deletions lib/bcdice/game_system/ParanoiaPerfect.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# frozen_string_literal: true

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

# ゲームシステム名
NAME = 'パラノイア・パーフェクト エディション'

# ゲームシステム名の読みがな
SORT_KEY = 'はらのいあはあふえくとえていしよん'

# ダイスボットの使い方
HELP_MESSAGE = <<~INFO_MESSAGE_TEXT
※コマンドは入力内容の前方一致で検出しています。
・通常の判定 NDx,y
 x:ノードダイスの数.マイナスも可.
 y: 反逆スターの数.省略可.省略時0
 ノードダイスの絶対値 + 1個(コンピュータダイス)のダイスがロールされる.
例)ND2 ND-3 ND2,1 ND-3,2
INFO_MESSAGE_TEXT

register_prefix('ND')

def eval_game_system_specific_command(command)
get_node_dice_roll(command)
end

private

def generate_roll_results(traitorous_star, dices)
computer_dice_message = ''
results = dices.dup
last_die = results[-1].to_i
if last_die >= (6 - traitorous_star)
results[-1] = "#{last_die}C"
computer_dice_message = '(Computer)'
end

return results, computer_dice_message
end

def get_node_dice_roll(command)
debug("eval_game_system_specific_command Begin")

m = /^ND((-)?\d+)(,(\d+))?$/i.match(command)
unless m
return nil
end

debug("command", command)

parameter_num = m[1].to_i
traitorous_star = m[4].to_i
dice_count = parameter_num.abs + 1

dices = @randomizer.roll_barabara(dice_count, 6)

success_rate = dices.count { |dice| dice >= 5 }
success_rate -= dices.count { |dice| dice < 5 } if parameter_num < 0

debug(dices)

results, computer_dice_message = generate_roll_results(traitorous_star, dices)

debug("eval_game_system_specific_command result")

return "(#{command}) > [#{results.join(', ')}] > 成功度#{success_rate}#{computer_dice_message}"
end
end
end
end
136 changes: 136 additions & 0 deletions test/data/ParanoiaPerfect.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
[[ test ]]
game_system = "ParanoiaPerfect"
input = "ND2"
output = "(ND2) > [1, 1, 1] > 成功度0"
rands = [
{ sides = 6, value = 1 },
{ sides = 6, value = 1 },
{ sides = 6, value = 1 },
]

[[ test ]]
game_system = "ParanoiaPerfect"
input = "ND-2"
output = "(ND-2) > [1, 1, 1] > 成功度-3"
rands = [
{ sides = 6, value = 1 },
{ sides = 6, value = 1 },
{ sides = 6, value = 1 },
]

[[ test ]]
game_system = "ParanoiaPerfect"
input = "nd3"
output = "(ND3) > [6, 2, 4, 5] > 成功度2"
rands = [
{ sides = 6, value = 6 },
{ sides = 6, value = 2 },
{ sides = 6, value = 4 },
{ sides = 6, value = 5 },
]

[[ test ]]
game_system = "ParanoiaPerfect"
input = "nd3"
output = "(ND3) > [6, 5, 5, 6C] > 成功度4(Computer)"
rands = [
{ sides = 6, value = 6 },
{ sides = 6, value = 5 },
{ sides = 6, value = 5 },
{ sides = 6, value = 6 },
]

[[ test ]]
game_system = "ParanoiaPerfect"
input = "ND-3"
output = "(ND-3) > [6, 2, 5, 6C] > 成功度2(Computer)"
rands = [
{ sides = 6, value = 6 },
{ sides = 6, value = 2 },
{ sides = 6, value = 5 },
{ sides = 6, value = 6 },
]

[[ test ]]
game_system = "ParanoiaPerfect"
input = "ND-3"
output = "(ND-3) > [6, 6, 5, 6C] > 成功度4(Computer)"
rands = [
{ sides = 6, value = 6 },
{ sides = 6, value = 6 },
{ sides = 6, value = 5 },
{ sides = 6, value = 6 },
]

[[ test ]]
game_system = "ParanoiaPerfect"
input = "ND0"
output = "(ND0) > [6C] > 成功度1(Computer)"
rands = [
{ sides = 6, value = 6 },
]

[[ test ]]
game_system = "ParanoiaPerfect"
input = "ND0"
output = "(ND0) > [5] > 成功度1"
rands = [
{ sides = 6, value = 5 },
]

[[ test ]]
game_system = "ParanoiaPerfect"
input = "ND0"
output = "(ND0) > [4] > 成功度0"
rands = [
{ sides = 6, value = 4 },
]


[[ test ]]
game_system = "ParanoiaPerfect"
input = "ND0,0 # 反逆スターの確認"
output = "(ND0,0) > [6C] > 成功度1(Computer)"
rands = [
{ sides = 6, value = 6 },
]

[[ test ]]
game_system = "ParanoiaPerfect"
input = "ND0,1"
output = "(ND0,1) > [5C] > 成功度1(Computer)"
rands = [
{ sides = 6, value = 5 },
]

[[ test ]]
game_system = "ParanoiaPerfect"
input = "ND0,2"
output = "(ND0,2) > [4C] > 成功度0(Computer)"
rands = [
{ sides = 6, value = 4 },
]

[[ test ]]
game_system = "ParanoiaPerfect"
input = "ND0,3"
output = "(ND0,3) > [3C] > 成功度0(Computer)"
rands = [
{ sides = 6, value = 3 },
]

[[ test ]]
game_system = "ParanoiaPerfect"
input = "ND0,4"
output = "(ND0,4) > [2C] > 成功度0(Computer)"
rands = [
{ sides = 6, value = 2 },
]

[[ test ]]
game_system = "ParanoiaPerfect"
input = "ND0,5"
output = "(ND0,5) > [1C] > 成功度0(Computer)"
rands = [
{ sides = 6, value = 1 },
]