class FTLTools::CrewBuilder
Fills each crew position with a qualified individual. This assumes a smaller ship, with a “standard” complement of crew. A roster has the positions that need to be filled and the skills required for that position.
Attributes
crew[R]
Public Class Methods
new(data = {})
click to toggle source
# File lib/ftl_tools/crew_builder.rb, line 13 def initialize(data = {}) @data = data @ship = @data.fetch(:ship, standard_ship) @roster = @data.fetch(:roster, standard_roster) @crew = FTLTools::Crew.new end
Public Instance Methods
build_crew()
click to toggle source
# File lib/ftl_tools/crew_builder.rb, line 46 def build_crew builder = FTLTools::CharacterBuilder.new builder.reset @crew.add({ :role => 'Pilot', :person => builder.setup({'role' => 'Pilot'})}) builder.reset @crew.add({ :role => 'Navigator', :person => builder.setup({'role' => 'Navigator'})}) builder.reset if steward? @crew.add({ :role => 'Steward', :person => builder.setup({'role' => 'Steward'})}) builder.reset end if medic? @crew.add({ :role => 'Medic', :person => builder.setup({'role' => 'Medic'}) }) builder.reset end engineer_count.times { @crew.add({ :team => 'Engineering', :role => 'Engineer', :person => builder.setup({'role' => 'Engineer'}) }) builder.reset } gunner_count.times { @crew.add({ :team => 'Gunners', :role => 'Gunnery', :person => builder.setup({'role' => 'Gunner'}) }) builder.reset } @crew end
engineer_count()
click to toggle source
# File lib/ftl_tools/crew_builder.rb, line 30 def engineer_count @ship.fetch(:drive_size).fdiv(35).ceil.clamp(1..) end
gunner_count()
click to toggle source
# File lib/ftl_tools/crew_builder.rb, line 34 def gunner_count @ship.fetch(:weapons, 0) end
medic?()
click to toggle source
# File lib/ftl_tools/crew_builder.rb, line 42 def medic? @ship[:size] >= 200 ? true : false end
standard_roster()
click to toggle source
# File lib/ftl_tools/crew_builder.rb, line 20 def standard_roster #{ :pilot => nil, :navigator => nil, :engineers => [], #:steward => nil, :medic => nil, :gunners => [] } { 'Pilot' => nil, 'Navigator' => nil } end
standard_ship()
click to toggle source
# File lib/ftl_tools/crew_builder.rb, line 26 def standard_ship { :drive_size => 35, :size => 200 , :weapons => 0} end
steward?()
click to toggle source
# File lib/ftl_tools/crew_builder.rb, line 38 def steward? @ship[:passengers] end