Class: Gamefic::Entity

Inherits:
Element show all
Includes:
Messaging, Node
Defined in:
lib/gamefic/entity.rb

Overview

A physical object that can exist in a plot. Most objects with which players interact are entities. Player characters themselves typically derive from entities, e.g., the Gamefic::Actor class.

Direct Known Subclasses

Actor

Constant Summary

Constants included from Keywords

Keywords::SPLIT_REGEXP

Instance Attribute Summary

Attributes included from Describable

#definite_article, #indefinite_article, #name, #synonyms

Instance Method Summary collapse

Methods included from Messaging

#flush, #messages, #stream, #tell

Methods included from Node

#accessible?, #children, #flatten, #parent

Methods inherited from Element

default_attributes, inherited, #initialize, #post_initialize, set_default

Methods included from Index

clear, #destroy, elements, from_serial, #initialize, serials, stick, stuck, stuck?, #to_serial, unserialize

Methods included from Describable

default_description, default_description=, #definitely, #description, #description=, #has_description?, #indefinitely, #keywords, #proper_named=, #proper_named?, #to_s

Methods included from Keywords

#keywords, #specified?

Constructor Details

This class inherits a constructor from Gamefic::Element

Instance Method Details

#[](key) ⇒ Object

Get a custom property.



38
39
40
# File 'lib/gamefic/entity.rb', line 38

def [](key)
  session[key]
end

#[]=(key, value) ⇒ Object

Set a custom property.



46
47
48
# File 'lib/gamefic/entity.rb', line 46

def []=(key, value)
  session[key] = value
end

#parent=(node) ⇒ Object

Set the Entity’s parent.



17
18
19
20
21
22
# File 'lib/gamefic/entity.rb', line 17

def parent=(node)
  if node != nil and node.kind_of?(Entity) == false
    raise "Entity's parent must be an Entity"
  end
  super
end

#sessionHash

A freeform property dictionary. Authors can use the session hash to assign custom properties to the entity. It can also be referenced directly using [] without the method name, e.g., entity.session or entity.



30
31
32
# File 'lib/gamefic/entity.rb', line 30

def session
  @session ||= {}
end