Module: Gamefic::Scriptable::Queries

Includes:
Proxies
Included in:
Narrative, Gamefic::Scriptable, Actions
Defined in:
lib/gamefic/scriptable/queries.rb

Overview

Scriptable methods related to creating action queries.

Instance Method Summary collapse

Methods included from Proxies

#unproxy

Instance Method Details

#abstract(*args, ambiguous: false) ⇒ Query::Abstract

Define a query that searches for abstract entities.

An abstract entity is a pseudo-entity that is describable but does not have a parent or children.

Parameters:

  • args (Array<Object>)

    Query arguments

Returns:



25
26
27
# File 'lib/gamefic/scriptable/queries.rb', line 25

def abstract *args, ambiguous: false
  Query::Abstract.new -> { entities }, *args, ambiguous: ambiguous
end

#anywhere(*args, ambiguous: false) ⇒ Query::General

Define a query that searches the entire plot’s entities.

Parameters:

  • args (Array<Object>)

    Query arguments

Returns:



14
15
16
# File 'lib/gamefic/scriptable/queries.rb', line 14

def anywhere *args, ambiguous: false
  Query::General.new -> { entities }, *args, ambiguous: ambiguous, name: 'anywhere'
end

#available(*args, ambiguous: false) ⇒ Query::Scoped Also known as: family

Define a query that searches an actor’s family of entities. The results include the parent, siblings, children, and accessible descendants of siblings and children.

Parameters:

  • args (Array<Object>)

    Query arguments

Returns:



35
36
37
# File 'lib/gamefic/scriptable/queries.rb', line 35

def available *args, ambiguous: false
  Query::Scoped.new Scope::Family, *args, ambiguous: ambiguous, name: 'available'
end

#children(*args, ambiguous: false) ⇒ Query::Scoped

Define a query that searches an actor’s children.

Parameters:

  • args (Array<Object>)

    Query arguments

Returns:



52
53
54
# File 'lib/gamefic/scriptable/queries.rb', line 52

def children *args, ambiguous: false
  Query::Scoped.new Scope::Children, *args, ambiguous: ambiguous, name: 'children'
end

#descendants(*args, ambiguous: false) ⇒ Query::Scoped

Define a query that searches an actor’s descendants.

Parameters:

  • args (Array<Object>)

    Query arguments

Returns:



60
61
62
# File 'lib/gamefic/scriptable/queries.rb', line 60

def descendants *args, ambiguous: false
  Query::Scoped.new Scope::Descendants, *args, ambiguous: ambiguous
end

#myself(*args, ambiguous: false) ⇒ Query::Scoped

Define a query that returns the actor itself.

Parameters:

  • args (Array<Object>)

    Query arguments

Returns:



76
77
78
# File 'lib/gamefic/scriptable/queries.rb', line 76

def myself *args, ambiguous: false
  Query::Scoped.new Scope::Myself, *args, ambiguous: ambiguous, name: 'myself'
end

#parent(*args, ambiguous: false) ⇒ Query::Scoped

Define a query that returns the actor’s parent.

Parameters:

  • args (Array<Object>)

    Query arguments

Returns:



44
45
46
# File 'lib/gamefic/scriptable/queries.rb', line 44

def parent *args, ambiguous: false
  Query::Scoped.new Scope::Parent, *args, ambiguous: ambiguous, name: 'parent'
end

#plaintext(arg = /.*/) ⇒ Query::Text

Define a query that performs a plaintext search. It can take a String or a RegExp as an argument. If no argument is provided, it will match any text it finds in the command. A successful query returns the corresponding text instead of an entity.

Parameters:

  • arg (String, Regexp) (defaults to: /.*/)

    The string or regular expression to match

Returns:



87
88
89
# File 'lib/gamefic/scriptable/queries.rb', line 87

def plaintext arg = /.*/
  Query::Text.new arg, name: 'plaintext'
end

#siblings(*args, ambiguous: false) ⇒ Query::Scoped

Define a query that searches an actor’s siblings.

Parameters:

  • args (Array<Object>)

    Query arguments

Returns:



68
69
70
# File 'lib/gamefic/scriptable/queries.rb', line 68

def siblings *args, ambiguous: false
  Query::Scoped.new Scope::Siblings, *args, ambiguous: ambiguous, name: 'siblings'
end