Class: Tardvig::Act Abstract

Inherits:
Command show all
Defined in:
lib/tardvig/act.rb

Overview

This class is abstract.

Represents the abstract part of your game. It may be anything, depends on your realization: level, location, cut-scene, credits, etc.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

call, #call, #initialize

Constructor Details

This class inherits a constructor from Tardvig::Command

Class Method Details

.act_type(type) ⇒ Object .act_typeObject

Overloads:

  • .act_type(type) ⇒ Object

    Parameters:

    • type (String, Symbol)

      set your custom act type. This is needed for your display to differ acts and correspondingly intepret them.

  • .act_typeObject

    Returns type of your act.

    Returns:

    • type of your act



12
13
14
15
16
17
18
19
20
# File 'lib/tardvig/act.rb', line 12

def act_type(type = nil)
  if type
    @type = type
  elsif @type
    @type
  elsif superclass.respond_to? :act_type
    superclass.act_type
  end
end

.subject(value) ⇒ Object .subjectObject

Overloads:

  • .subject(value) ⇒ Object

    If there was MVC, I would say act is a model, subject is its data and other part of act is business logic. But there is no MVC, so *subject is the content of your act and the methods of the act should process it*.

    For example, if your act is a location of FPS, subject is the location file and methods of your act should control player’s enemies. If act is a cut-scene, subject is the video file (probably name of the file).

    Parameters:

    • value (Object)

      subject of your act.

  • .subjectObject

    Returns subject of your act.

    Returns:

    • (Object)

      subject of your act



35
36
37
38
39
40
41
# File 'lib/tardvig/act.rb', line 35

def subject(value = nil)
  if value
    @subject = value
  else
    @subject
  end
end

Instance Method Details

#display_formatObject

This method should return the object which will be sent to the display. By default it returns the subject. But you can redefine it.



65
66
67
# File 'lib/tardvig/act.rb', line 65

def display_format
  self.class.subject
end

#notify_displayObject

This method notifies your display via GameIO when the act is executed. You can redefine it if you want to send another message or do not want to send anything.



58
59
60
# File 'lib/tardvig/act.rb', line 58

def notify_display
  io.happen :act_start, type: self.class.act_type, subject: display_format
end