Class: Lairs
- Includes:
- LairsData, XpDifficultyTable
- Defined in:
- lib/encounters/lairs.rb
Constant Summary collapse
- AVAILABLE_ENCOUNTER_LEVEL =
REVERSED_XP_DIFFICULTY_TABLE.keys
- MIN_PARTY_LEVEL_MUL =
0.4
Constants included from XpDifficultyTable
XpDifficultyTable::REVERSED_XP_DIFFICULTY_TABLE, XpDifficultyTable::XP_DIFFICULTY_TABLE
Constants included from LairsData
Instance Attribute Summary collapse
-
#lair_type ⇒ Object
readonly
Returns the value of attribute lair_type.
Class Method Summary collapse
Instance Method Summary collapse
- #encounter ⇒ Object
-
#initialize(encounter_level, hero_levels, lair_type = nil) ⇒ Lairs
constructor
encounter_level : :easy, :medium, :hard, :deadly.
- #to_hash ⇒ Object
Constructor Details
#initialize(encounter_level, hero_levels, lair_type = nil) ⇒ Lairs
encounter_level : :easy, :medium, :hard, :deadly
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/encounters/lairs.rb', line 15 def initialize( encounter_level, hero_levels, lair_type = nil) @encounters = Encounters.new @encounter_level = encounter_level @hero_levels = hero_levels check_params @party_xp_level = hero_levels.map{ |hl| XP_DIFFICULTY_TABLE[hl][@encounter_level] }.reduce(&:+) @lair_type = lair_type ? lair_type : get_available_lairs.sample end |
Instance Attribute Details
#lair_type ⇒ Object (readonly)
Returns the value of attribute lair_type.
12 13 14 |
# File 'lib/encounters/lairs.rb', line 12 def lair_type @lair_type end |
Class Method Details
Instance Method Details
#encounter ⇒ Object
27 28 29 30 |
# File 'lib/encounters/lairs.rb', line 27 def encounter encounter_id = get_available_encounters.sample @encounters.by_id encounter_id end |
#to_hash ⇒ Object
32 33 34 |
# File 'lib/encounters/lairs.rb', line 32 def to_hash { encounter_level: @encounter_level, hero_levels: @hero_levels, lair_type: @lair_type } end |