class Astromapper::Builder::Star
Constants
- BIOZONE
- BODE_RATIO
- COMPANION_SEPARATION
- INNER_LIMIT
- MASS
- SPECTRAL
- STAR_CHART
@@stars = {}
Attributes
biozone[RW]
bode_constant[RW]
companions[RW]
id[RW]
mass[RW]
orbit[RW]
orbits[RW]
primary[RW]
size_dm[RW]
star_size[RW]
type_dm[RW]
volume[RW]
world[RW]
Public Class Methods
new(volume, primary=nil,ternary=0)
click to toggle source
# File lib/astromapper/builder/star.rb, line 71 def initialize(volume, primary=nil,ternary=0) @volume = volume @primary = primary @orbits = [] @companions = [] @world = nil @type_dm = 0 @size_dm = 0 @has_gg = false if primary.nil? @orbit = 0 @type_dm = (toss(2,0) + @volume.star_dm ).max(12) @size_dm = (toss(2,0) + 0 ).max(12) @star_type = %w{B B A M M M M M K G F F F}[@type_dm] @star_size = %w{0 1 2 3 4 5 5 5 5 5 5 6 500}[@size_dm].to_i else separation = (toss(2,0) * COMPANION_SEPARATION[toss(3) + (4 * ternary) - 2]).round(2) # Gurps Space 4e p.105 @orbit = au_to_orbit(separation) - 1 @star_type = %w{X B A F F G G K K M M M M}[(toss(2,0) + primary.type_dm).max(12)] @star_size = %w{0 1 2 3 4 500 500 5 5 6 500 500 500 500}[(toss(2,0) + primary.size_dm).max(12)].to_i end @spectral = @star_type + SPECTRAL[@star_type].sample.to_s @star_size ||= 500 @bode_constant = (@star_type=='M' and @star_size==5) ? 0.2 : BODE_RATIO[toss] if @star_size == 500 @star_subtype = (true) ? 'B' : @star_type @star_type = 'D' end dm = 0 dm += 4 if @star_size == 3 dm += 8 if @star_size < 3 dm -= 4 if @star_type == 'M' dm -= 2 if @star_type == 'K' # Populate Orbits (toss(2,0) + dm).whole.times do |i| @orbits << Orbit.new(self,i).populate unless orbit_to_au(i) > outer_limit @world = @orbits.last if @orbits.last.is_a?(World) end @world.gas_giant = (@orbits.map{|o| o.kid}.include?('G')) ? 'G' : '.' unless @world.nil? prune! end
Public Instance Methods
au_to_orbit(au)
click to toggle source
# File lib/astromapper/builder/star.rb, line 137 def au_to_orbit(au) constant = (@primary.nil?) ? @bode_constant : @primary.bode_constant (Math.log(au / constant) / Math.log(2) ).round(2).abs - inner_limit end
classification()
click to toggle source
# File lib/astromapper/builder/star.rb, line 171 def classification return @star_type + @star_subtype if (@star_type == 'D') "#{@spectral}#{@star_size.roman}" end
column()
click to toggle source
# File lib/astromapper/builder/star.rb, line 179 def column; @volume.column; end
companions=(star)
click to toggle source
# File lib/astromapper/builder/star.rb, line 141 def companions=(star) orbit = star.orbit.abs companion = Companion.new(self, orbit, star) # Gurps Space 4e p.107 - Clear Forbidden orbits inner = au_to_orbit(companion.au * 0.67).floor outer = au_to_orbit(companion.au * 3).ceil @forbidden = (inner .. outer) @forbidden.each { |x| @orbits[x] = nil } @orbits[orbit - 1] = companion @companions << star prune! end
crib()
click to toggle source
# File lib/astromapper/builder/star.rb, line 163 def crib stars = [classification] @companions.each { |s| stars << s.classification } "%-17s %-16s" % [stars.join('/'), @orbits.map{|o| o.kid}.join('')] end
inner_limit()
click to toggle source
# File lib/astromapper/builder/star.rb, line 187 def inner_limit; limit; end
kid()
click to toggle source
# File lib/astromapper/builder/star.rb, line 155 def kid; 'C'; end
limit()
click to toggle source
# File lib/astromapper/builder/star.rb, line 188 def limit return 0 if @star_size.nil? INNER_LIMIT[@star_type][@star_size % 10] end
location()
click to toggle source
# File lib/astromapper/builder/star.rb, line 182 def location; @volume.location; end
luminosity()
click to toggle source
# File lib/astromapper/builder/star.rb, line 193 def luminosity; STAR_CHART[@spectral][2]; end
orbit_to_au(o)
click to toggle source
# File lib/astromapper/builder/star.rb, line 134 def orbit_to_au(o) inner_limit + (self.bode_constant * (2 ** o)).round(1) end
orbits_to_ascii()
click to toggle source
# File lib/astromapper/builder/star.rb, line 159 def orbits_to_ascii return '' if @orbits.empty? "\n" + @orbits.map{|o| o.to_ascii}.join("\n") + "\n" end
outer_limit()
click to toggle source
# File lib/astromapper/builder/star.rb, line 158 def outer_limit; 40 * mass; end
prune!()
click to toggle source
# File lib/astromapper/builder/star.rb, line 119 def prune! # Ensure last orbits are not empty. @orbits.each_index { |x| @orbits[x] = Orbit.new(self,x) if @orbits[x].nil?} c = @orbits # exit tk = false @orbits = @orbits.sort{|b,a| a.orbit_number <=> b.orbit_number}.map {|o| tk = true unless (o.kid == '.' or tk); o if tk }.reverse.compact # @orbits.each_index { |x| @orbits[x] = Orbit.new(self,x) if @orbits[x].nil?} return if @orbits.size < 2 @orbits.length.times do |i| @orbits[i].orbit_number = i @orbits[i].au = self.orbit_to_au(i) end end
radius()
click to toggle source
# File lib/astromapper/builder/star.rb, line 156 def radius; (155000 * Math.sqrt(luminosity)) ** 2; end
row()
click to toggle source
# File lib/astromapper/builder/star.rb, line 180 def row; @volume.row; end
sector()
click to toggle source
# File lib/astromapper/builder/star.rb, line 181 def sector; @volume.sector; end
size()
click to toggle source
# File lib/astromapper/builder/star.rb, line 185 def size; @star_size; end
size=(s)
click to toggle source
# File lib/astromapper/builder/star.rb, line 186 def size=(s); @star_size = s; end
snow_line()
click to toggle source
# File lib/astromapper/builder/star.rb, line 157 def snow_line; 4.85 * Math.sqrt(luminosity); end
temperature()
click to toggle source
# File lib/astromapper/builder/star.rb, line 194 def temperature; @temperature = STAR_CHART[@spectral][1].around(20) if @temperature.nil?; end
to_ascii()
click to toggle source
# File lib/astromapper/builder/star.rb, line 168 def to_ascii classification end
to_s()
click to toggle source
# File lib/astromapper/builder/star.rb, line 154 def to_s; kid; end
type()
click to toggle source
# File lib/astromapper/builder/star.rb, line 183 def type; @star_type; end
type=(s)
click to toggle source
# File lib/astromapper/builder/star.rb, line 184 def type=(s); @star_type = s; end
world?()
click to toggle source
# File lib/astromapper/builder/star.rb, line 175 def world? return @orbits.join('').include?('W') return false end