Class: BCDice::GameSystem::StellarLife::StellarLife2D10Table

Inherits:
Object
  • Object
show all
Defined in:
lib/bcdice/game_system/StellarLife.rb

Overview

D10 を 2 個振って、 100 通りの結果を得るテーブル(このゲームではこの振り方の表に 2D10 と書いてあるので、そういう名前にしてある)

Direct Known Subclasses

StellarLife2D10HalfTable

Defined Under Namespace

Classes: RollResult

Instance Method Summary collapse

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.roll_barabara(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