diff --git a/lib/bcdice/common_command/barabara_dice/node.rb b/lib/bcdice/common_command/barabara_dice/node.rb index 814941bd7..022dfc268 100644 --- a/lib/bcdice/common_command/barabara_dice/node.rb +++ b/lib/bcdice/common_command/barabara_dice/node.rb @@ -1,4 +1,5 @@ require "bcdice/format" +require "bcdice/common_command/barabara_dice/result" module BCDice module CommonCommand @@ -12,7 +13,9 @@ def initialize(secret:, notations:, cmp_op:, target_number:) @target_number = target_number end - # @return [String, nil] + # @param game_system [Base] ゲームシステム + # @param randomizer [Randomizer] ランダマイザ + # @return [Result] def eval(game_system, randomizer) round_type = game_system.round_type notations = @notations.map { |n| n.to_dice(round_type) } @@ -38,6 +41,9 @@ def eval(game_system, randomizer) Result.new.tap do |r| r.secret = @secret r.text = sequence.join(" > ") + r.rands = randomizer.rand_results + r.detailed_rands = randomizer.detailed_rand_results + r.success_num = success_num end end end diff --git a/lib/bcdice/common_command/barabara_dice/result.rb b/lib/bcdice/common_command/barabara_dice/result.rb new file mode 100644 index 000000000..8177c6155 --- /dev/null +++ b/lib/bcdice/common_command/barabara_dice/result.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +require "bcdice/result" + +module BCDice + module CommonCommand + module BarabaraDice + # バラバラロールの結果を表すクラス + class Result < ::BCDice::Result + # @return [Integer] 成功数 + attr_accessor :success_num + + # @param text [String, nil] 結果の文章 + def initialize(text = nil) + super(text) + + @success_num = 0 + end + end + end + end +end diff --git a/lib/bcdice/result.rb b/lib/bcdice/result.rb index 09e90440a..2c3b1fc6a 100644 --- a/lib/bcdice/result.rb +++ b/lib/bcdice/result.rb @@ -38,6 +38,8 @@ def nothing def initialize(text = nil) @text = text + @rands = nil + @detailed_rands = nil @secret = false @success = false @failure = false