Class: ItemLibrary::Object
Defined Under Namespace
Classes: InvalidInteractionAction
Constant Summary
Natural20::Entity::ALL_SKILLS, Natural20::Entity::ATTRIBUTE_TYPES, Natural20::Entity::ATTRIBUTE_TYPES_ABBV, Natural20::Entity::SKILL_AND_ABILITY_MAP
Instance Attribute Summary collapse
#casted_effects, #current_hit_die, #death_fails, #death_saves, #effects, #entity_event_hooks, #entity_uid, #max_hit_die, #session
Instance Method Summary
collapse
#list_notes
#ability_mod, #acrobatics_proficient?, #action?, #active_effects, #add_casted_effect, #add_item, #all_ability_mods, #all_ability_scores, #any_class_feature?, #athletics_proficient?, #attach_handler, #attack_ability_mod, #attack_roll_mod, #available_movement, #available_spells, #break_stealth!, #can_see?, #carry_capacity, #cha_mod, #check_equip, #class_feature?, #con_mod, #conscious!, #conscious?, #darkvision?, #dead!, #dead?, #death_saving_throw!, #deduct_item, #description, #dex_mod, #dexterity_check!, #disengage!, #disengage?, #dismiss_effect!, #dodge?, #dodging!, #drop_grapple!, #drop_items!, #entered_melee?, #equip, #equipped?, #equipped_items, #equipped_weapons, #escape_grapple_from!, #expertise, #expertise?, #free_object_interaction?, #grappled?, #grappled_by!, #grapples, #grappling, #grappling?, #grappling_targets, #hand_slots_required, #has_reaction?, #has_spell_effect?, #has_spells?, #heal!, #help!, #help?, #hiding!, #hiding?, #hit_die, #incapacitated?, #initiative!, #insight_proficient?, #int_mod, #inventory, #inventory_count, #inventory_weight, #investigation_proficient?, #item_count, #languages, #locate_melee_positions, #lockpick!, #long_jump_distance, #max_spell_slots, #medicine_check!, #medicine_proficient?, #melee_distance, #melee_squares, #opened?, #passive_perception, #perception_proficient?, #proficiency_bonus, #proficient?, #proficient_with_armor?, #proficient_with_equipped_armor?, #proficient_with_weapon?, #prone!, #prone?, #push_from, #race, #ranged_spell_attack!, #register_effect, #register_event_hook, #reset_turn!, #resistant_to?, #saving_throw!, #sentient?, #shield_equipped?, #short_rest!, #size_identifier, #speed, #spell_slots, #squeezed!, #squeezed?, #stable!, #stable?, #stand!, #standing_jump_distance, #stealth_proficient?, #str_mod, #strength_check!, #take_damage!, #to_item, #token_size, #total_actions, #total_bonus_actions, #total_reactions, #trigger_event, #unconscious!, #unconscious?, #unequip, #unequip_all, #ungrapple, #unsqueeze, #usable_items, #usable_objects, #use_hit_die!, #used_hand_slots, #wearing_armor?, #wis_mod, #wisdom_check!
#apply_effect, #eval_if
Constructor Details
#initialize(map, properties) ⇒ Object
Returns a new instance of Object.
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# 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
|
Instance Attribute Details
Returns the value of attribute hp.
26
27
28
|
# File 'lib/natural_20/item_library/object.rb', line 26
def hp
@hp
end
|
Returns the value of attribute map.
26
27
28
|
# File 'lib/natural_20/item_library/object.rb', line 26
def map
@map
end
|
Returns the value of attribute name.
26
27
28
|
# File 'lib/natural_20/item_library/object.rb', line 26
def name
@name
end
|
#resistances ⇒ Object
Returns the value of attribute resistances.
26
27
28
|
# File 'lib/natural_20/item_library/object.rb', line 26
def resistances
@resistances
end
|
Returns the value of attribute statuses.
26
27
28
|
# File 'lib/natural_20/item_library/object.rb', line 26
def statuses
@statuses
end
|
Instance Method Details
#armor_class ⇒ Object
64
65
66
|
# File 'lib/natural_20/item_library/object.rb', line 64
def armor_class
@properties[:default_ac]
end
|
#available_interactions(_entity, _battle) ⇒ Object
119
120
121
|
# File 'lib/natural_20/item_library/object.rb', line 119
def available_interactions(_entity, _battle)
[]
end
|
#can_hide? ⇒ Boolean
95
96
97
|
# File 'lib/natural_20/item_library/object.rb', line 95
def can_hide?
@properties.fetch(:allow_hide, false)
end
|
60
61
62
|
# File 'lib/natural_20/item_library/object.rb', line 60
def color
@properties[:color]
end
|
#concealed? ⇒ Boolean
140
141
142
|
# File 'lib/natural_20/item_library/object.rb', line 140
def concealed?
false
end
|
76
77
78
79
80
81
82
83
84
85
|
# 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 ⇒ Object
144
145
146
|
# File 'lib/natural_20/item_library/object.rb', line 144
def describe_health
''
end
|
#half_cover? ⇒ Boolean
72
73
74
|
# File 'lib/natural_20/item_library/object.rb', line 72
def half_cover?
@properties[:cover] == 'half'
end
|
#interactable? ⇒ Boolean
99
100
101
|
# File 'lib/natural_20/item_library/object.rb', line 99
def interactable?
false
end
|
#items_label ⇒ Object
160
161
162
|
# 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? ⇒ Boolean
This terrain needs to be jumped over for movement
128
129
130
|
# File 'lib/natural_20/item_library/object.rb', line 128
def jump_required?
@properties[:jump]
end
|
52
53
54
|
# File 'lib/natural_20/item_library/object.rb', line 52
def label
@properties[:label] || name
end
|
#light_properties ⇒ Object
123
124
125
|
# File 'lib/natural_20/item_library/object.rb', line 123
def light_properties
@properties[:light]
end
|
#movement_cost ⇒ Object
107
108
109
|
# File 'lib/natural_20/item_library/object.rb', line 107
def movement_cost
@properties[:movement_cost] || 1
end
|
#npc? ⇒ Boolean
152
153
154
|
# File 'lib/natural_20/item_library/object.rb', line 152
def npc?
false
end
|
#object? ⇒ Boolean
148
149
150
|
# File 'lib/natural_20/item_library/object.rb', line 148
def object?
true
end
|
#opaque? ⇒ Boolean
68
69
70
|
# File 'lib/natural_20/item_library/object.rb', line 68
def opaque?
@properties[:opaque]
end
|
#passable? ⇒ Boolean
132
133
134
|
# File 'lib/natural_20/item_library/object.rb', line 132
def passable?
@properties[:passable]
end
|
#pc? ⇒ Boolean
156
157
158
|
# File 'lib/natural_20/item_library/object.rb', line 156
def pc?
false
end
|
#placeable? ⇒ Boolean
103
104
105
|
# File 'lib/natural_20/item_library/object.rb', line 103
def placeable?
@properties.key?(:placeable) ? @properties[:placeable] : true
end
|
56
57
58
|
# File 'lib/natural_20/item_library/object.rb', line 56
def position
map.position_of(self)
end
|
115
116
117
|
# File 'lib/natural_20/item_library/object.rb', line 115
def size
@properties[:size] || :medium
end
|
#three_quarter_cover? ⇒ Boolean
87
88
89
|
# File 'lib/natural_20/item_library/object.rb', line 87
def three_quarter_cover?
@properties[:cover] == 'three_quarter'
end
|
111
112
113
|
# File 'lib/natural_20/item_library/object.rb', line 111
def token
@properties[:token]
end
|
#total_cover? ⇒ Boolean
91
92
93
|
# File 'lib/natural_20/item_library/object.rb', line 91
def total_cover?
@properties[:cover] == 'total'
end
|
#wall? ⇒ Boolean
136
137
138
|
# File 'lib/natural_20/item_library/object.rb', line 136
def wall?
@properties[:wall]
end
|