Class: Goby::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/goby/event/event.rb

Overview

A Player can interact with these on the Map.

Direct Known Subclasses

Chest, NPC, Shop

Constant Summary collapse

DEFAULT_RUN_TEXT =

The default text for when the event doesn’t do anything.

"Nothing happens.\n\n"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command: "event", mode: 0, visible: true) ⇒ Event

Returns a new instance of Event.

Parameters:

  • command (String) (defaults to: "event")

    the command to activate the event.

  • mode (Integer) (defaults to: 0)

    convenient way for an event to have multiple actions.

  • visible (Boolean) (defaults to: true)

    true when the event can be seen/activated.



12
13
14
15
16
# File 'lib/goby/event/event.rb', line 12

def initialize(command: "event", mode: 0, visible: true)
  @command = command
  @mode = mode
  @visible = visible
end

Instance Attribute Details

#commandObject

Specify the command in the subclass.



32
33
34
# File 'lib/goby/event/event.rb', line 32

def command
  @command
end

#modeObject

Specify the command in the subclass.



32
33
34
# File 'lib/goby/event/event.rb', line 32

def mode
  @mode
end

#visibleObject

Specify the command in the subclass.



32
33
34
# File 'lib/goby/event/event.rb', line 32

def visible
  @visible
end

Instance Method Details

#==(rhs) ⇒ Object

Parameters:

  • rhs (Event)

    the event on the right.



27
28
29
# File 'lib/goby/event/event.rb', line 27

def ==(rhs)
  @command == rhs.command
end

#run(player) ⇒ Object

The function that runs when the player activates the event. Override this function for subclasses.

Parameters:

  • player (Player)

    the one activating the event.



22
23
24
# File 'lib/goby/event/event.rb', line 22

def run(player)
  print DEFAULT_RUN_TEXT
end