Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.19 KB | None | 0 0
  1. diff --git a/bin/edpmh b/bin/edpmh
  2. index 6e6bb69..e508958 100755
  3. --- a/bin/edpmh
  4. +++ b/bin/edpmh
  5. @@ -83,6 +83,7 @@ command :import do |c|
  6.        system.security = security unless security.id.nil?
  7.        system.primary_economy = primary_economy unless primary_economy.id.nil?
  8.        system.needs_permit = row['needs_permit']
  9. +      system.minor_faction_count = row['minor_faction_presences'].length
  10.        system.save unless system.id.nil?
  11.        $stdout.write "\e[2K#{row['name']}\r"
  12.        $stdout.flush
  13. @@ -212,26 +213,31 @@ command :search do |c|
  14.        _srcs = []
  15.        srcs.each do |s|
  16.          next if t.id == s.id
  17. -        _srcs << s
  18. +        pool = System.where{{systems[:id] => Station.distinct.select(:system_id).where(max_landing_pad_size: opts[:'landing-pad'])}}
  19. +        pool = filter_dist(pool, s, opts[:'max-jump'])
  20. +        _srcs << [s, (pool.count - 1)]
  21.        end
  22.        next if opts[:'max-sources'] and _srcs.length > opts[:'max-sources']
  23. -      _srcs.sort!{|a, b| dist(a, t) <=> dist(b, t)}
  24. +      _srcs.sort!{|a, b| dist(a[0], t) <=> dist(b[0], t)}
  25.        pairs << [t, _srcs] unless _srcs.empty?
  26.      end
  27.  
  28.      if ref.nil?
  29. -      pairs.sort!{|a, b| a[1].length <=> b[1].length}
  30. +      pairs.sort!{|a, b| a[1][0].length <=> b[1][0].length}
  31.      else
  32.        pairs.sort!{|a, b| dist(a[0], ref) <=> dist(b[0], ref)}
  33.      end
  34.      puts "#{pairs.length} possible targets found:"
  35.      pairs.each do |t, _srcs|
  36.        puts
  37. -      puts "[ #{_srcs.length} ]"
  38. -      puts t.format
  39. +      puts "[ #{_srcs.length} sources within #{opts[:'max-jump']} Ly of the Destination ]"
  40. +      puts
  41. +      puts "Destination #{t.format}"
  42.        puts
  43.        _srcs.each do |s|
  44. -        puts s.format(ident: 1, ref: t)
  45. +        puts "       [ Source pool: #{s[1]} systems within #{opts[:'max-jump']} Ly radius having landing pad size: #{opts[:'landing-pad']} ]"
  46. +        puts s[0].format(ident: 5, ref: t)
  47. +        puts
  48.        end
  49.      end
  50.    end
  51. diff --git a/lib/elite_dangerous/db.rb b/lib/elite_dangerous/db.rb
  52. index 632ce80..bc33601 100644
  53. --- a/lib/elite_dangerous/db.rb
  54. +++ b/lib/elite_dangerous/db.rb
  55. @@ -27,6 +27,7 @@ module EliteDangerous
  56.          column :is_populated, TrueClass
  57.          column :power, String
  58.          column :needs_permit, TrueClass
  59. +        column :minor_faction_count, Integer
  60.          foreign_key :government_id, :governments
  61.          foreign_key :allegiance_id, :allegiances
  62.          foreign_key :power_state_id, :power_states
  63. diff --git a/lib/elite_dangerous/models.rb b/lib/elite_dangerous/models.rb
  64. index bcbd431..3da5a7a 100644
  65. --- a/lib/elite_dangerous/models.rb
  66. +++ b/lib/elite_dangerous/models.rb
  67. @@ -49,6 +49,7 @@ module EliteDangerous
  68.            pfx = '  ' * ident
  69.            str = ''
  70.            str << pfx << "System: #{name} (#{id})#{", #{dist(self, ref)} Ly" unless ref.nil?}#{" [PERMIT REQUIRED]" if needs_permit}\n"
  71. +          str << pfx << "  Minor Factions: #{minor_faction_count}\n"
  72.            str << pfx << "  Allegiance: #{allegiance.name} (#{government.name})\n"
  73.            str << pfx << "  Power: #{power} (#{power_state.name})\n" unless power.nil?
  74.            str << pfx << "  Primary Economy: #{primary_economy.name}\n" unless primary_economy.nil?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement