Class: BCDice::GameSystem::StellarLife::StellarLife2D10Table
- Inherits:
-
Object
- Object
- BCDice::GameSystem::StellarLife::StellarLife2D10Table
- Defined in:
- lib/bcdice/game_system/StellarLife.rb
Overview
D10 を 2 個振って、 100 通りの結果を得るテーブル(このゲームではこの振り方の表に 2D10 と書いてあるので、そういう名前にしてある)
Direct Known Subclasses
Defined Under Namespace
Classes: RollResult
Instance Method Summary collapse
-
#initialize(name, *items) ⇒ StellarLife2D10Table
constructor
A new instance of StellarLife2D10Table.
- #roll(randomizer) ⇒ Object
Constructor Details
#initialize(name, *items) ⇒ StellarLife2D10Table
Returns a new instance of StellarLife2D10Table.
136 137 138 139 |
# File 'lib/bcdice/game_system/StellarLife.rb', line 136 def initialize(name, *items) @name = name @items = items.freeze end |
Instance Method Details
#roll(randomizer) ⇒ Object
141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/bcdice/game_system/StellarLife.rb', line 141 def roll(randomizer) dices = randomizer.(2, 10) row_index = dices[0] == 10 ? 0 : dices[0] column_index = dices[1] == 10 ? 0 : dices[1] key = row_index * 10 + column_index chosen = @items[key] return RollResult.new(@name, format("%02d", key), chosen) end |