Class: Missions::Events::MissionEvent

Inherits:
Omega::Server::HandledEvent show all
Defined in:
lib/missions/events/mission.rb

Overview

Spawned by the local missions subsystem upon mission event

Subclasses just need to define 'type'

Direct Known Subclasses

Expired, Failed, Victory

Instance Attribute Summary collapse

Attributes inherited from Omega::Server::Event

#handlers, #id, #timestamp

Instance Method Summary collapse

Methods inherited from Omega::Server::HandledEvent

#handlers_json

Methods inherited from Omega::Server::Event

#handlers_json, #invoke, json_create, #should_exec?, #time_elapsed?, #to_json, #to_s

Constructor Details

#initialize(args = {}) ⇒ MissionEvent

Completed Event intializer


23
24
25
26
27
# File 'lib/missions/events/mission.rb', line 23

def initialize(args={})
  attr_from_args args, :mission => nil, :registry => nil
  id = "mission-#{mission.nil? ? nil : mission.id}-#{type}"
  super(args.merge({:id => id, :type => type.to_s}))
end

Instance Attribute Details

#missionObject

Handle to mission that was completed


16
17
18
# File 'lib/missions/events/mission.rb', line 16

def mission
  @mission
end

#registryObject

FIXME registry not serialized


20
21
22
# File 'lib/missions/events/mission.rb', line 20

def registry
  @registry
end

Instance Method Details

#event_argsObject


34
35
36
# File 'lib/missions/events/mission.rb', line 34

def event_args
  [mission]
end

#json_dataObject


38
39
40
# File 'lib/missions/events/mission.rb', line 38

def json_data
  super.merge({:mission => @mission})
end

#typeObject

subclasses should override


30
31
32
# File 'lib/missions/events/mission.rb', line 30

def type
  'event'
end