class ItemLibrary::Object
Attributes
hp[RW]
map[RW]
name[RW]
resistances[RW]
statuses[RW]
Public Class Methods
new(map, properties)
click to toggle source
# File lib/natural_20/item_library/object.rb, line 28 def initialize(map, properties) @name = properties[:name] @map = map @session = map.session @statuses = Set.new @properties = properties @resistances = properties[:resistances].presence || [] setup_other_attributes @hp = if !properties[:hp_die].blank? Natural20::DieRoll.roll(properties[:hp_die]).result else properties[:max_hp] end if @properties[:inventory] @inventory = @properties[:inventory].map do |inventory| [inventory[:type].to_sym, OpenStruct.new({ qty: inventory[:qty] })] end.to_h end end
Public Instance Methods
armor_class()
click to toggle source
# File lib/natural_20/item_library/object.rb, line 64 def armor_class @properties[:default_ac] end
available_interactions(_entity, _battle)
click to toggle source
# File lib/natural_20/item_library/object.rb, line 119 def available_interactions(_entity, _battle) [] end
can_hide?()
click to toggle source
# File lib/natural_20/item_library/object.rb, line 95 def can_hide? @properties.fetch(:allow_hide, false) end
color()
click to toggle source
# File lib/natural_20/item_library/object.rb, line 60 def color @properties[:color] end
concealed?()
click to toggle source
# File lib/natural_20/item_library/object.rb, line 140 def concealed? false end
cover_ac()
click to toggle source
# File lib/natural_20/item_library/object.rb, line 76 def cover_ac case @properties[:cover].to_sym when :half 2 when :three_quarter 5 else 0 end end
describe_health()
click to toggle source
# File lib/natural_20/item_library/object.rb, line 144 def describe_health '' end
half_cover?()
click to toggle source
# File lib/natural_20/item_library/object.rb, line 72 def half_cover? @properties[:cover] == 'half' end
interactable?()
click to toggle source
# File lib/natural_20/item_library/object.rb, line 99 def interactable? false end
items_label()
click to toggle source
# File lib/natural_20/item_library/object.rb, line 160 def items_label I18n.t(:"object.#{self.class}.item_label", default: "#{name} Items") end
jump_required?()
click to toggle source
This terrain needs to be jumped over for movement
# File lib/natural_20/item_library/object.rb, line 128 def jump_required? @properties[:jump] end
label()
click to toggle source
# File lib/natural_20/item_library/object.rb, line 52 def label @properties[:label] || name end
light_properties()
click to toggle source
# File lib/natural_20/item_library/object.rb, line 123 def light_properties @properties[:light] end
movement_cost()
click to toggle source
# File lib/natural_20/item_library/object.rb, line 107 def movement_cost @properties[:movement_cost] || 1 end
npc?()
click to toggle source
# File lib/natural_20/item_library/object.rb, line 152 def npc? false end
object?()
click to toggle source
# File lib/natural_20/item_library/object.rb, line 148 def object? true end
opaque?()
click to toggle source
# File lib/natural_20/item_library/object.rb, line 68 def opaque? @properties[:opaque] end
passable?()
click to toggle source
# File lib/natural_20/item_library/object.rb, line 132 def passable? @properties[:passable] end
pc?()
click to toggle source
# File lib/natural_20/item_library/object.rb, line 156 def pc? false end
placeable?()
click to toggle source
# File lib/natural_20/item_library/object.rb, line 103 def placeable? @properties.key?(:placeable) ? @properties[:placeable] : true end
position()
click to toggle source
# File lib/natural_20/item_library/object.rb, line 56 def position map.position_of(self) end
size()
click to toggle source
# File lib/natural_20/item_library/object.rb, line 115 def size @properties[:size] || :medium end
three_quarter_cover?()
click to toggle source
# File lib/natural_20/item_library/object.rb, line 87 def three_quarter_cover? @properties[:cover] == 'three_quarter' end
token()
click to toggle source
# File lib/natural_20/item_library/object.rb, line 111 def token @properties[:token] end
total_cover?()
click to toggle source
# File lib/natural_20/item_library/object.rb, line 91 def total_cover? @properties[:cover] == 'total' end
wall?()
click to toggle source
# File lib/natural_20/item_library/object.rb, line 136 def wall? @properties[:wall] end
Protected Instance Methods
setup_other_attributes()
click to toggle source
# File lib/natural_20/item_library/object.rb, line 166 def setup_other_attributes; end