lib/lacuna_util/task/build_excavators.rb
# TODO: should this be a configuration file option?
# Note: this number should not be more than 50 to avoid an issue with building
#   more than 50 ships per request.
should this be a configuration file option.
Note: this number should not be more than 50 to avoid an issue with building
more than 50 ships per request.
should this be a configuration file option . Note : this number should not be more than 50 to avoid an issue with building more than 50 ships per request .
def _run(args, config)
        Lacuna::Empire.planets.each do |id, name|
            Logger.log "Looking on #{name} to build Excavators."
            buildings = Lacuna::Body.get_buildings(id)['buildings']
            sp = Lacuna::Body.find_building(buildings, 'Space Port')
            next if sp.nil?
            ships = Lacuna::SpacePort.view_all_ships(sp['id'], { :no_paging => 1 })['ships']
            count = (ships.select { |ship| ship['type'] =~ /excavator/ }).size
            if count >= TARGET
                Logger.log "Already #{count} built!"
                next
            end
            build_count = TARGET - count
            Logger.log "Found #{count} Excavators."
            self.build_excavators(buildings, build_count)
        end
    end
def _run ( args , config ) Lacuna :: Empire . planets . each do | id , name | Logger . log "Looking on #{name} to build Excavators." buildings = Lacuna :: Body . get_buildings ( id ) [ 'buildings' ] sp = Lacuna :: Body . find_building ( buildings , 'Space Port' ) next if sp . nil? ships = Lacuna :: SpacePort . view_all_ships ( sp [ 'id' ] , { :no_paging => 1 } ) [ 'ships' ] count = ( ships . select { | ship | ship [ 'type' ] =~ / excavator / } ) . size if count >= TARGET Logger . log "Already #{count} built!" next end build_count = TARGET - count Logger . log "Found #{count} Excavators." self . build_excavators ( buildings , build_count ) end end
TODO: should this be a configuration file option?
TODO : should this be a configuration file option?
# Skip if there's enough.
args
config