Class: Encounters
- Includes:
- EncountersData, XpDifficultyTable
- Defined in:
- lib/encounters/encounters.rb
Constant Summary collapse
- AVAILABLE_ENCOUNTER_LEVEL =
REVERSED_XP_DIFFICULTY_TABLE.keys
Constants included from XpDifficultyTable
XpDifficultyTable::REVERSED_XP_DIFFICULTY_TABLE, XpDifficultyTable::XP_DIFFICULTY_TABLE
Constants included from EncountersData
EncountersData::BY_XP_ENCOUNTERS, EncountersData::ENCOUNTERS
Instance Method Summary collapse
- #by_id(encounter_id) ⇒ Object
- #by_monster(monster_key) ⇒ Object
-
#initialize ⇒ Encounters
constructor
A new instance of Encounters.
Constructor Details
#initialize ⇒ Encounters
Returns a new instance of Encounters.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/encounters/encounters.rb', line 12 def initialize @monster_manual = MonstersManual.new @monster_manual.load @encounters = {} @by_monster_encounters = {} ENCOUNTERS.each do |e| encounter = Encounter.new( @monster_manual.get( e[:monster_key] ), e[:amount], e[:id], e[:xp_value] ) @encounters[e[:id]] = encounter @by_monster_encounters[e[:monster_key]] ||= [] @by_monster_encounters[e[:monster_key]] << encounter end end |
Instance Method Details
#by_id(encounter_id) ⇒ Object
26 27 28 |
# File 'lib/encounters/encounters.rb', line 26 def by_id( encounter_id ) @encounters[ encounter_id ] end |
#by_monster(monster_key) ⇒ Object
30 31 32 |
# File 'lib/encounters/encounters.rb', line 30 def by_monster( monster_key ) @by_monster_encounters[monster_key] end |