Module: Missions::DSL::Requirements

Includes:
Helpers
Defined in:
lib/missions/dsl/requirements.rb

Overview

Mission Requirements

Class Method Summary collapse

Methods included from Helpers

#dsl_module_for, included, #is_dsl_category?

Class Method Details

.docked_at(station) ⇒ Object

Ensure user mission is being assigned to has a ship at the specified station


36
37
38
39
40
41
42
43
44
45
46
# File 'lib/missions/dsl/requirements.rb', line 36

def self.docked_at(station)
  proc { |mission, assigning_to|
    # ensure user has ship docked at specified station
    aentities  = node.invoke('manufactured::get_entities',
                             'of_type', 'Manufactured::Ship',
                             'owned_by', assigning_to.id)
    astats     = aentities.collect { |s| s.docked_at_id }.compact

    astats.include?(station.id)
  }
end

.shared_stationObject

Ensure both mission owner and user its being assigned to have at least one ship docked at a common station


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/missions/dsl/requirements.rb', line 17

def self.shared_station
  proc { |mission, assigning_to|
    # ensure users have a ship docked at a common station
    created_by = mission.creator
    centities  = node.invoke('manufactured::get_entities',
                             'of_type', 'Manufactured::Ship',
                             'owned_by', created_by.id)
    cstats     = centities.collect { |s| s.docked_at_id }.compact

    aentities  = node.invoke('manufactured::get_entities',
                             'of_type', 'Manufactured::Ship',
                             'owned_by', assigning_to.id)
    astats     = aentities.collect { |s| s.docked_at_id }.compact

    !(cstats & astats).empty?
  }
end