From a9e040e7675498e5eb3307aac010d68dd97ee144 Mon Sep 17 00:00:00 2001 From: ViVi-shark <44130782+ViVi-shark@users.noreply.github.com> Date: Wed, 14 Jul 2021 22:54:47 +0900 Subject: [PATCH] =?UTF-8?q?[Irisbane]=20=E3=80=8E=E7=9E=B3=E9=80=B8?= =?UTF-8?q?=E3=82=89=E3=81=95=E3=81=AC=E3=82=A4=E3=83=AA=E3=82=B9=E3=83=99?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=80=8F=E3=81=AE=E3=83=80=E3=82=A4=E3=82=B9?= =?UTF-8?q?=E3=83=9C=E3=83=83=E3=83=88=E3=82=92=E4=BD=9C=E6=88=90=20(#482)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [Irisbane] 「攻撃判定」(ルールブックp148)の基本的な挙動を実装 * [Irisbane] 攻撃判定の各パラメータに式を指定できるように ゲームルール上、しばしば計算が発生するので。 * [Irisbane] バラバラダイスのソート、端数切り上げを設定 * [Irisbane] 攻撃判定にダメージの増減を指定できるように ルールブックp67 《私が守る》や《連鎖の起点》など * [Irisbane] ヘルプメッセージ内の例をカンマで区切らないように コマンドでカンマを使う以上、まぎらわしいので。 * [Irisbane] Ruby2.6で動かなかったのを修正 * [Irisbane] 年齢チャート(p27)を実装 * ダイス目の偶奇のみを見るテーブルを実装 * [Irisbane] 性別チャート(p27)を実装 * 左側ダイスを範囲で表現するD66テーブルを実装 * [Irisbane] 欠落チャート(p30)を実装 * [Irisbane] 願望チャート(p31)を実装 * [Irisbane] 問い掛けチャート(p34-35)を実装 * [Irisbane] 復讐者のスタイルチャート(p40)を実装 * [Irisbane] 掌握者のスタイルチャート(p41)を実装 * [Irisbane] 望む執行の方向性チャート(p48)を実装 * [Irisbane] シチュエーションチャート(p115)を実装 * [Irisbane] シルエットライン(p37)のダイスロールを実装 * [Irisbane] 「攻撃判定」のコマンド形式を変更 before: x,y,z after: x@y<=z * [Irisbane] いくつかの表を削除 - 年齢 - 性別 - 欠落 - 願望 - 問い掛け - 復讐者のスタイル - 掌握者のスタイル - 望む執行の方向性 - シルエットライン * Revert "ダイス目の偶奇のみを見るテーブルを実装" This reverts commit 4506747b4e44ac512589516eedca6d5e142d123d. Co-authored-by: ViVi --- lib/bcdice/dice_table.rb | 1 + lib/bcdice/dice_table/d66_left_range_table.rb | 29 ++ lib/bcdice/game_system.rb | 1 + lib/bcdice/game_system/Irisbane.rb | 154 ++++++ test/data/Irisbane.toml | 450 ++++++++++++++++++ test/test_d66_left_range_table.rb | 59 +++ 6 files changed, 694 insertions(+) create mode 100644 lib/bcdice/dice_table/d66_left_range_table.rb create mode 100644 lib/bcdice/game_system/Irisbane.rb create mode 100644 test/data/Irisbane.toml create mode 100644 test/test_d66_left_range_table.rb diff --git a/lib/bcdice/dice_table.rb b/lib/bcdice/dice_table.rb index 29b7840a9..94243cba9 100644 --- a/lib/bcdice/dice_table.rb +++ b/lib/bcdice/dice_table.rb @@ -5,6 +5,7 @@ require "bcdice/dice_table/d66_grid_table" require "bcdice/dice_table/d66_half_grid_table" require "bcdice/dice_table/d66_one_third_table" +require "bcdice/dice_table/d66_left_range_table" require "bcdice/dice_table/d66_parity_table" require "bcdice/dice_table/d66_range_table" require "bcdice/dice_table/d66_table" diff --git a/lib/bcdice/dice_table/d66_left_range_table.rb b/lib/bcdice/dice_table/d66_left_range_table.rb new file mode 100644 index 000000000..c97f2cbdf --- /dev/null +++ b/lib/bcdice/dice_table/d66_left_range_table.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +require "bcdice/dice_table/d66_table" + +module BCDice + module DiceTable + # 左側(十の位)のみ Range を用いる D66 表 + class D66LeftRangeTable < D66Table + # @param name [String] 表の名前 + # @param sort_type [Symbol] 出目入れ替えの方式 BCDice::D66SortType + # @param items [Array<(Range, Array)>] 表の項目の配列 + def initialize(name, sort_type, items) + expanded_items = {} + items.each do |item| + range, right_items = item + + range.each do |left_value| + right_items.each_with_index do |right_item, right_value| + key = left_value * 10 + (right_value + 1) + expanded_items[key] = right_item + end + end + end + + super(name, sort_type, expanded_items) + end + end + end +end diff --git a/lib/bcdice/game_system.rb b/lib/bcdice/game_system.rb index 87f8dcba7..aa487b63b 100644 --- a/lib/bcdice/game_system.rb +++ b/lib/bcdice/game_system.rb @@ -96,6 +96,7 @@ require "bcdice/game_system/InfiniteFantasia" require "bcdice/game_system/Insane" require "bcdice/game_system/Insane_Korean" +require "bcdice/game_system/Irisbane" require "bcdice/game_system/IthaWenUa" require "bcdice/game_system/JamesBond" require "bcdice/game_system/JekyllAndHyde" diff --git a/lib/bcdice/game_system/Irisbane.rb b/lib/bcdice/game_system/Irisbane.rb new file mode 100644 index 000000000..4d64407cd --- /dev/null +++ b/lib/bcdice/game_system/Irisbane.rb @@ -0,0 +1,154 @@ +# frozen_string_literal: true + +module BCDice + module GameSystem + class Irisbane < Base + # ゲームシステムの識別子 + ID = 'Irisbane' + + # ゲームシステム名 + NAME = '瞳逸らさぬイリスベイン' + + # ゲームシステム名の読みがな + SORT_KEY = 'ひとみそらさぬいりすへいん' + + # ダイスボットの使い方 + HELP_MESSAGE = <<~HELP + ■攻撃判定( ATTACKx@y<=z ) + x: 攻撃力 + y: 判定数 + z: 目標値 + (※ ATTACK は ATK または AT と簡略化可能) + 例) ATTACK2@3<=5 + 例) ATK10@2<=4 + 例) AT8@3<=2 + + 上記 x y z にはそれぞれ四則演算を指定可能。 + 例) ATTACK2+7@3*2<=5-1 + + □攻撃判定のダメージ増減( ATTACKx@y<=z[+a] ATTACKx@y<=z[-a]) + 末尾に [+a] または [-a] と指定すると、最終的なダメージを増減できる。 + a: 増減量 + 例) ATTACK2@3<=5[+10] + 例) ATK10@2<=4[-8] + 例) AT8@3<=2[-8+5] + + ■シチュエーション(p115) + SceneSituation, SSi + HELP + + ATTACK_ROLL_REG = %r{^AT(TACK|K)?([+\-*/()\d]+)@([+\-*/()\d]+)<=([+\-*/()\d]+)(\[([+\-])([+\-*/()\d]+)\])?}i.freeze + register_prefix('AT(TACK|K)?') + + def initialize(command) + super(command) + + @sort_barabara_dice = true + @round_type = RoundType::CEIL + 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]) + else + roll_tables(command, TABLES) + end + end + + private + + def roll_attack(power_expression, dice_count_expression, border_expression, modification_operator, modification_expression) + power = Arithmetic.eval(power_expression, RoundType::CEIL) + dice_count = Arithmetic.eval(dice_count_expression, RoundType::CEIL) + border = Arithmetic.eval(border_expression, RoundType::CEIL) + modification_value = modification_expression.nil? ? nil : Arithmetic.eval(modification_expression, RoundType::CEIL) + return if power.nil? || dice_count.nil? || border.nil? + return if modification_operator && modification_value.nil? + + power = 0 if power < 0 + border = border.clamp(1, 6) + + command = make_command_text(power, dice_count, border, modification_operator, modification_value) + + if dice_count <= 0 + return "#{command} > 判定数が 0 です" + end + + dices = @randomizer.roll_barabara(dice_count, 6).sort + + success_dice_count = dices.count { |dice| dice <= border } + damage = success_dice_count * power + + message_elements = [] + message_elements << command + message_elements << dices.join(',') + message_elements << "成功ダイス数 #{success_dice_count}" + message_elements << "× 攻撃力 #{power}" if success_dice_count > 0 + + if success_dice_count > 0 + if modification_operator && modification_value + message_elements << "ダメージ #{damage}#{modification_operator}#{modification_value}" + damage = parse_operator(modification_operator).call(damage, modification_value) + damage = 0 if damage < 0 + message_elements << damage.to_s + else + message_elements << "ダメージ #{damage}" + end + end + + Result.new(message_elements.join(' > ')).tap do |r| + r.condition = success_dice_count > 0 + end + end + + def make_command_text(power, dice_count, border, modification_operator, modification_value) + text = "(ATTACK#{power}@#{dice_count}<=#{border}" + text += "[#{modification_operator}#{modification_value}]" if modification_operator + text += ")" + text + end + + def parse_operator(operator) + case operator + when '+' + lambda { |x, y| x + y } + when '-' + lambda { |x, y| x - y } + end + end + + TABLES = { + "SceneSituation" => DiceTable::D66LeftRangeTable.new( + "シチュエーション", + BCDice::D66SortType::NO_SORT, + [ + [1..3, [ + "【日常】何一つ変わることの無い日々の一幕。移ろい易い世界では、それはとても大切である。", + "【準備】何かを為すための用意をする一幕。情報収集、買物遠征、やるべきことは一杯だ。", + "【趣味】自分の時間を、有効活用している一幕。必要に追われていない分、心は軽く晴れやかだ。", + "【喫茶】一息入れ、嗜好品を嗜む時の一幕。穏やかな空気は、だが、往々にして変わりやすい。", + "【鍛錬】体を鍛え、心を養う修練の一幕。己さえ良ければ、その方法も何だって良い。", + "【職務】役割の元、仕事に精を出す時の一幕。目的が何であれ、為すべきことに変わりはない。", + ]], + [4..6, [ + "【移動】何処かから何処かへと向かう一幕。進んでいるなら、手段も目的地も関係あるまい。", + "【墓前】故人が眠る場所へと赴く一幕。共に眠ることだけは無いように。", + "【操作】何かを操り、望みを果たしている一幕。運転にせよ何にせよ、脇見には注意が必要だ。", + "【食事】何かを糧とし、己の力を蓄える一幕。行動すれば消耗する。腹が減っては何とやらだ。", + "【休息】日々の合間の、憩いの一幕。“何もしない”というのも、立派な行いである。", + "【夢幻】現実に存在しない何かへと耽る一幕。時間帯に関わらず、何時かは必ず覚めるだろう。", + ]], + ] + ), + }.transform_keys(&:upcase).freeze + + ALIAS = { + "SSi" => "SceneSituation", + }.transform_keys(&:upcase).transform_values(&:upcase).freeze + + register_prefix(TABLES.keys, ALIAS.keys) + end + end +end diff --git a/test/data/Irisbane.toml b/test/data/Irisbane.toml new file mode 100644 index 000000000..3fab7d7d3 --- /dev/null +++ b/test/data/Irisbane.toml @@ -0,0 +1,450 @@ +[[ test ]] +game_system = "Irisbane" +input = "3b6" +output = "(3B6) > 3,5,6" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 3 }, + { sides = 6, value = 5 }, +] + +[[ test ]] +game_system = "Irisbane" +input = "C(5/2)" +output = "c(5/2) > 3" +rands = [] + +[[ test ]] +game_system = "Irisbane" +input = "ATTACK2@4<=5" +output = "(ATTACK2@4<=5) > 1,3,4,6 > 成功ダイス数 3 > × 攻撃力 2 > ダメージ 6" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 1 }, + { sides = 6, value = 3 }, + { sides = 6, value = 4 }, +] +success = true + +[[ test ]] +game_system = "Irisbane" +input = "ATK10@2<=4" +output = "(ATTACK10@2<=4) > 3,4 > 成功ダイス数 2 > × 攻撃力 10 > ダメージ 20" +rands = [ + { sides = 6, value = 4 }, + { sides = 6, value = 3 }, +] +success = true + +[[ test ]] +game_system = "Irisbane" +input = "AT8@3<=2" +output = "(ATTACK8@3<=2) > 3,4,6 > 成功ダイス数 0" +rands = [ + { sides = 6, value = 4 }, + { sides = 6, value = 3 }, + { sides = 6, value = 6 }, +] +failure = true + +[[ test ]] +game_system = "Irisbane" +input = "ATTACK0@4<=5" +output = "(ATTACK0@4<=5) > 1,3,4,6 > 成功ダイス数 3 > × 攻撃力 0 > ダメージ 0" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 1 }, + { sides = 6, value = 3 }, + { sides = 6, value = 4 }, +] +success = true + +[[ test ]] +game_system = "Irisbane" +input = "ATTACK2@0<=5" +output = "(ATTACK2@0<=5) > 判定数が 0 です" +rands = [] + +[[ test ]] +game_system = "Irisbane" +input = "ATTACK2@4<=0" +output = "(ATTACK2@4<=1) > 1,3,4,6 > 成功ダイス数 1 > × 攻撃力 2 > ダメージ 2" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 1 }, + { sides = 6, value = 3 }, + { sides = 6, value = 4 }, +] +success = true + +[[ test ]] +game_system = "Irisbane" +input = "ATTACK2@4<=7" +output = "(ATTACK2@4<=6) > 1,3,4,6 > 成功ダイス数 4 > × 攻撃力 2 > ダメージ 8" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 1 }, + { sides = 6, value = 3 }, + { sides = 6, value = 4 }, +] +success = true + +[[ test ]] +game_system = "Irisbane" +input = "AT2+7@4<=5" +output = "(ATTACK9@4<=5) > 1,3,4,6 > 成功ダイス数 3 > × 攻撃力 9 > ダメージ 27" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 1 }, + { sides = 6, value = 3 }, + { sides = 6, value = 4 }, +] +success = true + +[[ test ]] +game_system = "Irisbane" +input = "AT2-1@4<=5" +output = "(ATTACK1@4<=5) > 1,3,4,6 > 成功ダイス数 3 > × 攻撃力 1 > ダメージ 3" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 1 }, + { sides = 6, value = 3 }, + { sides = 6, value = 4 }, +] +success = true + +[[ test ]] +game_system = "Irisbane" +input = "AT2-2@4<=5" +output = "(ATTACK0@4<=5) > 1,3,4,6 > 成功ダイス数 3 > × 攻撃力 0 > ダメージ 0" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 1 }, + { sides = 6, value = 3 }, + { sides = 6, value = 4 }, +] +success = true + +[[ test ]] +game_system = "Irisbane" +input = "AT2-3@4<=5" +output = "(ATTACK0@4<=5) > 1,3,4,6 > 成功ダイス数 3 > × 攻撃力 0 > ダメージ 0" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 1 }, + { sides = 6, value = 3 }, + { sides = 6, value = 4 }, +] +success = true + +[[ test ]] +game_system = "Irisbane" +input = "AT(2+3)*2@4<=5" +output = "(ATTACK10@4<=5) > 1,3,4,6 > 成功ダイス数 3 > × 攻撃力 10 > ダメージ 30" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 1 }, + { sides = 6, value = 3 }, + { sides = 6, value = 4 }, +] +success = true + +[[ test ]] +game_system = "Irisbane" +input = "AT(2+3/2@4<=5" +output = "" +rands = [] + +[[ test ]] +game_system = "Irisbane" +input = "AT(2+3)/2@4<=5" +output = "(ATTACK3@4<=5) > 1,3,4,6 > 成功ダイス数 3 > × 攻撃力 3 > ダメージ 9" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 1 }, + { sides = 6, value = 3 }, + { sides = 6, value = 4 }, +] +success = true + +[[ test ]] +game_system = "Irisbane" +input = "AT(2+3/2@4<=5" +output = "" +rands = [] + +[[ test ]] +game_system = "Irisbane" +input = "AT2@4-1<=5" +output = "(ATTACK2@3<=5) > 3,4,6 > 成功ダイス数 2 > × 攻撃力 2 > ダメージ 4" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 3 }, + { sides = 6, value = 4 }, +] +success = true + +[[ test ]] +game_system = "Irisbane" +input = "AT6@5/2<=5" +output = "(ATTACK6@3<=5) > 1,3,6 > 成功ダイス数 2 > × 攻撃力 6 > ダメージ 12" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 1 }, + { sides = 6, value = 3 }, +] +success = true + +[[ test ]] +game_system = "Irisbane" +input = "AT2@4*2<=5" +output = "(ATTACK2@8<=5) > 1,1,2,3,4,5,5,6 > 成功ダイス数 7 > × 攻撃力 2 > ダメージ 14" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 1 }, + { sides = 6, value = 3 }, + { sides = 6, value = 4 }, + { sides = 6, value = 5 }, + { sides = 6, value = 5 }, + { sides = 6, value = 1 }, + { sides = 6, value = 2 }, +] +success = true + +[[ test ]] +game_system = "Irisbane" +input = "AT2@(2*3)+2<=5" +output = "(ATTACK2@8<=5) > 1,1,2,3,4,5,5,6 > 成功ダイス数 7 > × 攻撃力 2 > ダメージ 14" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 1 }, + { sides = 6, value = 3 }, + { sides = 6, value = 4 }, + { sides = 6, value = 5 }, + { sides = 6, value = 5 }, + { sides = 6, value = 1 }, + { sides = 6, value = 2 }, +] +success = true + +[[ test ]] +game_system = "Irisbane" +input = "AT2@(2*3+2<=5" +output = "" +rands = [] + +[[ test ]] +game_system = "Irisbane" +input = "AT2@4<=4+1" +output = "(ATTACK2@4<=5) > 3,4,5,6 > 成功ダイス数 3 > × 攻撃力 2 > ダメージ 6" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 3 }, + { sides = 6, value = 5 }, + { sides = 6, value = 4 }, +] +success = true + +[[ test ]] +game_system = "Irisbane" +input = "AT2@4<=4+3" +output = "(ATTACK2@4<=6) > 3,4,5,6 > 成功ダイス数 4 > × 攻撃力 2 > ダメージ 8" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 3 }, + { sides = 6, value = 5 }, + { sides = 6, value = 4 }, +] +success = true + +[[ test ]] +game_system = "Irisbane" +input = "AT2@4<=4-1" +output = "(ATTACK2@4<=3) > 3,4,5,6 > 成功ダイス数 1 > × 攻撃力 2 > ダメージ 2" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 3 }, + { sides = 6, value = 5 }, + { sides = 6, value = 4 }, +] +success = true + +[[ test ]] +game_system = "Irisbane" +input = "AT2@4<=4-2" +output = "(ATTACK2@4<=2) > 3,4,5,6 > 成功ダイス数 0" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 3 }, + { sides = 6, value = 5 }, + { sides = 6, value = 4 }, +] +failure = true + +[[ test ]] +game_system = "Irisbane" +input = "AT2@4<=4-5" +output = "(ATTACK2@4<=1) > 3,4,5,6 > 成功ダイス数 0" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 3 }, + { sides = 6, value = 5 }, + { sides = 6, value = 4 }, +] +failure = true + +[[ test ]] +game_system = "Irisbane" +input = "AT2@4<=4-" +output = "" +rands = [] + +[[ test ]] +game_system = "Irisbane" +input = "ATTACK2+7@3*2<=5-1" +output = "(ATTACK9@6<=4) > 1,3,4,5,5,6 > 成功ダイス数 3 > × 攻撃力 9 > ダメージ 27" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 3 }, + { sides = 6, value = 5 }, + { sides = 6, value = 4 }, + { sides = 6, value = 1 }, + { sides = 6, value = 5 }, +] +success = true + +[[ test ]] +game_system = "Irisbane" +input = "ATTACK2@4<=5[+10]" +output = "(ATTACK2@4<=5[+10]) > 1,3,4,6 > 成功ダイス数 3 > × 攻撃力 2 > ダメージ 6+10 > 16" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 1 }, + { sides = 6, value = 3 }, + { sides = 6, value = 4 }, +] +success = true + +[[ test ]] +game_system = "Irisbane" +input = "ATTACK2@4<=2[+10]" +output = "(ATTACK2@4<=2[+10]) > 3,4,5,6 > 成功ダイス数 0" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 5 }, + { sides = 6, value = 3 }, + { sides = 6, value = 4 }, +] +failure = true + +[[ test ]] +game_system = "Irisbane" +input = "ATTACK2@4<=2[+10-]" +output = "" +rands = [] + +[[ test ]] +game_system = "Irisbane" +input = "ATTACK2+7@3*2<=5-1[+5]" +output = "(ATTACK9@6<=4[+5]) > 1,3,4,5,5,6 > 成功ダイス数 3 > × 攻撃力 9 > ダメージ 27+5 > 32" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 3 }, + { sides = 6, value = 5 }, + { sides = 6, value = 4 }, + { sides = 6, value = 1 }, + { sides = 6, value = 5 }, +] +success = true + +[[ test ]] +game_system = "Irisbane" +input = "ATTACK2+7@3*2<=5-1[+5+7*2-1]" +output = "(ATTACK9@6<=4[+18]) > 1,3,4,5,5,6 > 成功ダイス数 3 > × 攻撃力 9 > ダメージ 27+18 > 45" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 3 }, + { sides = 6, value = 5 }, + { sides = 6, value = 4 }, + { sides = 6, value = 1 }, + { sides = 6, value = 5 }, +] +success = true + +[[ test ]] +game_system = "Irisbane" +input = "ATTACK2+7@3*2<=5-1[-8]" +output = "(ATTACK9@6<=4[-8]) > 1,3,4,5,5,6 > 成功ダイス数 3 > × 攻撃力 9 > ダメージ 27-8 > 19" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 3 }, + { sides = 6, value = 5 }, + { sides = 6, value = 4 }, + { sides = 6, value = 1 }, + { sides = 6, value = 5 }, +] +success = true + +[[ test ]] +game_system = "Irisbane" +input = "ATTACK2+7@3*2<=5-1[-27]" +output = "(ATTACK9@6<=4[-27]) > 1,3,4,5,5,6 > 成功ダイス数 3 > × 攻撃力 9 > ダメージ 27-27 > 0" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 3 }, + { sides = 6, value = 5 }, + { sides = 6, value = 4 }, + { sides = 6, value = 1 }, + { sides = 6, value = 5 }, +] +success = true + +[[ test ]] +game_system = "Irisbane" +input = "ATTACK2+7@3*2<=5-1[-28]" +output = "(ATTACK9@6<=4[-28]) > 1,3,4,5,5,6 > 成功ダイス数 3 > × 攻撃力 9 > ダメージ 27-28 > 0" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 3 }, + { sides = 6, value = 5 }, + { sides = 6, value = 4 }, + { sides = 6, value = 1 }, + { sides = 6, value = 5 }, +] +success = true + +[[ test ]] +game_system = "Irisbane" +input = "SceneSituation" +output = "シチュエーション(11) > 【日常】何一つ変わることの無い日々の一幕。移ろい易い世界では、それはとても大切である。" +rands = [ + { sides = 6, value = 1 }, + { sides = 6, value = 1 }, +] + +[[ test ]] +game_system = "Irisbane" +input = "SCENESITUATION" +output = "シチュエーション(14) > 【喫茶】一息入れ、嗜好品を嗜む時の一幕。穏やかな空気は、だが、往々にして変わりやすい。" +rands = [ + { sides = 6, value = 1 }, + { sides = 6, value = 4 }, +] + +[[ test ]] +game_system = "Irisbane" +input = "SSi" +output = "シチュエーション(32) > 【準備】何かを為すための用意をする一幕。情報収集、買物遠征、やるべきことは一杯だ。" +rands = [ + { sides = 6, value = 3 }, + { sides = 6, value = 2 }, +] + +[[ test ]] +game_system = "Irisbane" +input = "SSI" +output = "シチュエーション(54) > 【食事】何かを糧とし、己の力を蓄える一幕。行動すれば消耗する。腹が減っては何とやらだ。" +rands = [ + { sides = 6, value = 5 }, + { sides = 6, value = 4 }, +] diff --git a/test/test_d66_left_range_table.rb b/test/test_d66_left_range_table.rb new file mode 100644 index 000000000..fed5a9bc7 --- /dev/null +++ b/test/test_d66_left_range_table.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +require "test/unit" +require "bcdice" +require "bcdice/dice_table/d66_left_range_table" + +require_relative "randomizer_mock" + +class TestD66LeftRangeTable < Test::Unit::TestCase + # 左桁ダイスは範囲指定で見て、右桁ダイスは数値で見る + def test_range_and_number + table = BCDice::DiceTable::D66LeftRangeTable.new( + "テスト", + BCDice::D66SortType::NO_SORT, + [ + [ + 1..4, + [ + "A1", + "A2", + "A3", + "A4", + "A5", + "A6", + ], + ], + [ + 5..6, + [ + "B1", + "B2", + "B3", + "B4", + "B5", + "B6", + ], + ], + ] + ) + + randomizer = RandomizerMock.new([[1, 6], [5, 6]]) + assert_equal("テスト(15) > A5", table.roll(randomizer).to_s) + + randomizer = RandomizerMock.new([[4, 6], [5, 6]]) + assert_equal("テスト(45) > A5", table.roll(randomizer).to_s) + + randomizer = RandomizerMock.new([[3, 6], [1, 6]]) + assert_equal("テスト(31) > A1", table.roll(randomizer).to_s) + + randomizer = RandomizerMock.new([[5, 6], [1, 6]]) + assert_equal("テスト(51) > B1", table.roll(randomizer).to_s) + + randomizer = RandomizerMock.new([[6, 6], [1, 6]]) + assert_equal("テスト(61) > B1", table.roll(randomizer).to_s) + + randomizer = RandomizerMock.new([[6, 6], [3, 6]]) + assert_equal("テスト(63) > B3", table.roll(randomizer).to_s) + end +end