module DndTreasureCalc
coins.rb
dice.rb
Constants
- COINS
- D_100
- HORDE_TABLES
- INDIVIDUAL_TABLES
- VERSION
Public Class Methods
get_index(challenge_rating)
click to toggle source
# File lib/dnd_treasure_calc.rb, line 50 def DndTreasureCalc.get_index(challenge_rating) idx = challenge_rating / 5 idx = 3 if idx > 3 idx end
horde(challenge_rating)
click to toggle source
Calculate horde treasure at challenge rating provided
# File lib/dnd_treasure_calc.rb, line 36 def DndTreasureCalc.horde(challenge_rating) raise RuntimeError, 'Not yet implemented.' end
horde_table_for(challenge_rating)
click to toggle source
# File lib/dnd_treasure_calc.rb, line 45 def DndTreasureCalc.horde_table_for(challenge_rating) idx = get_index(challenge_rating) HORDE_TABLES[idx] end
individual(challenge_rating)
click to toggle source
Calculate individual treasure at challenge rating provided
# File lib/dnd_treasure_calc.rb, line 15 def DndTreasureCalc.individual(challenge_rating) table = individual_table_for(challenge_rating) roll = D_100.roll table.each do |threshold, dice| if roll <= threshold coins = [] dice.each do |d| die = Dice.new(d[:rolls], d[:faces]) amount = die.roll * d[:multiplier] coins << Coins.new(amount, d[:type]) end return coins end end raise RuntimeError, "#{roll} did not meet any of the thresholds!" end
individual_table_for(challenge_rating)
click to toggle source
# File lib/dnd_treasure_calc.rb, line 40 def DndTreasureCalc.individual_table_for(challenge_rating) idx = get_index(challenge_rating) INDIVIDUAL_TABLES[idx] end