Class: Thing

Inherits:
Gamefic::Entity
  • Object
show all
Includes:
Edibility, Grammar::Attributes
Defined in:
lib/gamefic-standard/edible.rb,
lib/gamefic-standard/entities/thing.rb

Direct Known Subclasses

Character, Fixture, Item, Portal, Receptacle, Room, Scenery, Supporter

Instance Attribute Summary collapse

Attributes included from Grammar::Attributes

#gender, #plural

Attributes included from Edibility

#edible

Instance Method Summary collapse

Methods included from Grammar::Attributes

#person, #plural?

Methods included from Edibility

#edible?

Instance Attribute Details

#itemized=(value) ⇒ Boolean (writeonly)

Returns:

  • (Boolean)


5
6
7
# File 'lib/gamefic-standard/entities/thing.rb', line 5

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)


15
16
17
# File 'lib/gamefic-standard/entities/thing.rb', line 15

def locale_description
  @locale_description
end

#portable=(value) ⇒ Boolean (writeonly)

Returns:

  • (Boolean)


8
9
10
# File 'lib/gamefic-standard/entities/thing.rb', line 8

def portable=(value)
  @portable = value
end

Instance Method Details

#attached=(bool) ⇒ Object

Parameters:

  • bool (Boolean)


40
41
42
43
44
45
46
47
# File 'lib/gamefic-standard/entities/thing.rb', line 40

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

#attached?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/gamefic-standard/entities/thing.rb', line 35

def attached?
  @attached ||= false
end

#itemized?Boolean

Itemized entities are automatically listed in room descriptions.

Returns:

  • (Boolean)


23
24
25
# File 'lib/gamefic-standard/entities/thing.rb', line 23

def itemized?
  @itemized
end

#parent=(new_parent) ⇒ Object



49
50
51
52
# File 'lib/gamefic-standard/entities/thing.rb', line 49

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)


30
31
32
# File 'lib/gamefic-standard/entities/thing.rb', line 30

def portable?
  @portable
end

#roomRoom

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

Returns:



57
58
59
60
61
62
63
# File 'lib/gamefic-standard/entities/thing.rb', line 57

def room
  p = parent
  until p.is_a?(Room) or p.nil?
    p = p.parent
  end
  p
end