Module: Gamefic::Scriptable::Queries

Included in:
Action, Response, Gamefic::Scriptable, Responses, Gamefic::Scripting
Defined in:
lib/gamefic/scriptable/queries.rb

Overview

Scriptable methods related to creating action queries.

Instance Method Summary collapse

Instance Method Details

#available(*args) ⇒ Query::Family Also known as: family, avail

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:



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

def available *args
  Query::Family.new(*args, name: 'available')
end

#children(*args) ⇒ Query::Children

Define a query that searches an actor’s children.

Parameters:

  • args (Array<Object>)

    Query arguments

Returns:



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

def children *args
  Query::Children.new(*args, name: 'children')
end

#descendants(*args) ⇒ Query::Descendants

Define a query that searches an actor’s descendants.

Parameters:

  • args (Array<Object>)

    Query arguments

Returns:



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

def descendants *args
  Query::Descendants.new(*args)
end

#extended(*args) ⇒ Query::Extended

Define a query that searches an actor’s siblings and their descendants.

Parameters:

  • args (Array<Object>)

    Query arguments

Returns:



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

def extended *args
  Query::Extended.new(*args, name: 'extended')
end

#global(*args) ⇒ Query::Global Also known as: anywhere

Define a query that searches all entities in the subject’s epic.

If the subject is not an actor, the result will always be empty.

Parameters:

  • args (Array<Object>)

    Query arguments

Returns:



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

def global *args
  Query::Global.new(*args, name: 'global')
end

#integerQuery::Integer

Define a query that matches integers. Unlike other queries, #integer does not take arguments. It will match and return an integer if the corresponding command token is an integer or the corresponding input is a string representation of an integer. A successful query returns the integer instead of an entity.

Returns:



97
98
99
# File 'lib/gamefic/scriptable/queries.rb', line 97

def integer
  Query::Integer.new name: 'integer'
end

#myself(*args) ⇒ Query::Myself

Define a query that returns the actor itself.

Parameters:

  • args (Array<Object>)

    Query arguments

Returns:



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

def myself *args
  Query::Myself.new(*args, name: 'myself')
end

#parent(*args) ⇒ Query::Parent

Define a query that returns the actor’s parent.

Parameters:

  • args (Array<Object>)

    Query arguments

Returns:



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

def parent *args
  Query::Parent.new(*args, 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:



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

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

#siblings(*args) ⇒ Query::Siblings

Define a query that searches an actor’s siblings.

Parameters:

  • args (Array<Object>)

    Query arguments

Returns:



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

def siblings *args
  Query::Siblings.new(*args, name: 'siblings')
end