Class: Studio::Group::Encounter::LevelSetup

Inherits:
Object
  • Object
show all
Defined in:
scripts/00800 Studio/00001 Data/00011 Group.rb

Overview

Data class helping to know the level setup of a creature while picking its level from group

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ LevelSetup

Create a new level setup

Parameters:

  • hash (Hash)


146
147
148
149
150
151
# File 'scripts/00800 Studio/00001 Data/00011 Group.rb', line 146

def initialize(hash)
  @kind = hash['kind'].to_sym
  min_level = @kind == :fixed ? hash['level'].to_i : hash['level']['minimumLevel'].to_i
  max_level = @kind == :fixed ? hash['level'].to_i : hash['level']['maximumLevel'].to_i
  @range = min_level..max_level
end

Instance Attribute Details

#rangeRange (readonly)

Get the level range (to give to a rand function) to get the final level of the creature

Returns:

  • (Range)


142
143
144
# File 'scripts/00800 Studio/00001 Data/00011 Group.rb', line 142

def range
  @range
end

Instance Method Details

#repel_rejected(actor_level) ⇒ Boolean

Tell if that level setup makes the encounter rejected by repel

Parameters:

Returns:

  • (Boolean)


156
157
158
# File 'scripts/00800 Studio/00001 Data/00011 Group.rb', line 156

def repel_rejected(actor_level)
  return @range.end < actor_level
end

#strong_selected(actor_level) ⇒ Boolean

Tell if that level setup makes the encounter being selected because actor is weaker

Parameters:

Returns:

  • (Boolean)


163
164
165
# File 'scripts/00800 Studio/00001 Data/00011 Group.rb', line 163

def strong_selected(actor_level)
  return @range.end + 5 >= actor_level
end