Method: BCDice::CommonCommand::Choice#roll
- Defined in:
- lib/bcdice/common_command/choice.rb
#roll(randomizer) ⇒ Result
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/bcdice/common_command/choice.rb', line 194 def roll(randomizer) if @items.size > 100 return Result.new("項目数は100以下としてください") end items = @items.dup chosens = [] @takes.times do index = randomizer.roll_index(items.size) chosens << items.delete_at(index) end Result.new.tap do |r| chosen = chosens.join(DELIMITER_CHAR[@block_delimiter]) r.secret = @secret r.text = "(#{expr()}) > #{chosen}" end end |