Module: Gamefic::Standard::Standardized

Defined in:
lib/gamefic/standard/standardized.rb

Overview

Common features of standard entities.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#itemized=(value) ⇒ Boolean (writeonly)

Returns:

  • (Boolean)


9
10
11
# File 'lib/gamefic/standard/standardized.rb', line 9

def itemized=(value)
  @itemized = value
end

#locale_descriptionString?

An optional description to use when itemizing entities in room descriptions. The locale_description will be used instead of adding the entity’s name to a list.

Returns:

  • (String, nil)


19
20
21
# File 'lib/gamefic/standard/standardized.rb', line 19

def locale_description
  @locale_description
end

#portable=(value) ⇒ Boolean (writeonly)

Returns:

  • (Boolean)


12
13
14
# File 'lib/gamefic/standard/standardized.rb', line 12

def portable=(value)
  @portable = value
end

Instance Method Details

#attached=(bool) ⇒ Object

Parameters:

  • bool (Boolean)


41
42
43
44
45
46
47
48
# File 'lib/gamefic/standard/standardized.rb', line 41

def attached=(bool)
  @attached = if parent.nil?
                # @todo Log attachment failure
                false
              else
                bool
              end
end

#attached?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/gamefic/standard/standardized.rb', line 36

def attached?
  @attached ||= false
end

#itemized?Boolean

Itemized entities are automatically listed in room descriptions.

Returns:

  • (Boolean)


24
25
26
# File 'lib/gamefic/standard/standardized.rb', line 24

def itemized?
  @itemized
end

#parent=(new_parent) ⇒ Object



50
51
52
53
# File 'lib/gamefic/standard/standardized.rb', line 50

def parent=(new_parent)
  self.attached = false unless new_parent == parent
  super
end

#portable?Boolean

Portable entities can be taken with TAKE actions.

Returns:

  • (Boolean)


31
32
33
# File 'lib/gamefic/standard/standardized.rb', line 31

def portable?
  @portable
end

#roomRoom

The entity’s parent room (i.e., the closest ascendant that is a Room).

Returns:



58
59
60
61
62
# File 'lib/gamefic/standard/standardized.rb', line 58

def room
  ascendant = parent
  ascendant = ascendant.parent until ascendant.is_a?(Room) || ascendant.nil?
  ascendant
end