class Astromapper::Builder::Orbit
Class Orbit
Attributes
au[RW]
id[RW]
kid[RW]
orbit_number[RW]
port[RW]
xsize[RW]
Public Class Methods
new(star,orbit_number,companion=nil)
click to toggle source
# File lib/astromapper/builder/orbit.rb, line 7 def initialize(star,orbit_number,companion=nil) @orbit_number = orbit_number.round @au = star.orbit_to_au(orbit_number) @kid = '.' @star = star @atmo = 0 @moons = 0 @h20 = 0 @popx = 0 @tek = 0 @port = 'X' @govm = 0 @law = 0 @xsize = '.' begin @zone = case when @au < @star.biozone[0] then -1 # Inside when @au > @star.biozone[1] then 1 # Outside else 0 end @distant = (@au > @star.biozone[1] * 10) rescue # There is no biozone, so all is "inside" @zone = -1 @distant = 1000 end end
Public Instance Methods
biozone?()
click to toggle source
# File lib/astromapper/builder/orbit.rb, line 92 def biozone?; return @zone == 0; end
distant?()
click to toggle source
# File lib/astromapper/builder/orbit.rb, line 93 def distant?; @distant; end
inner?()
click to toggle source
# File lib/astromapper/builder/orbit.rb, line 90 def inner?; return @zone < 0; end
km()
click to toggle source
# File lib/astromapper/builder/orbit.rb, line 87 def km; return (150000000 * @au).to_i; end
limit?()
click to toggle source
# File lib/astromapper/builder/orbit.rb, line 89 def limit?; return @au < @star.limit ; end
outer?()
click to toggle source
# File lib/astromapper/builder/orbit.rb, line 91 def outer?; return @zone > 0; end
period()
click to toggle source
# File lib/astromapper/builder/orbit.rb, line 86 def period; (@au * 365.25).round(2); end
populate()
click to toggle source
# File lib/astromapper/builder/orbit.rb, line 40 def populate case when @au > @star.outer_limit then return self when limit? then return self when inner? then populate_inner when outer? then populate_outer else populate_biozone end end
populate_biozone()
click to toggle source
# File lib/astromapper/builder/orbit.rb, line 49 def populate_biozone return World.new(@star, @orbit_number) roll = toss(2,0) return (roll < 12) ? World.new(@star, @orbit_number) : GasGiant.new(@star, @orbit_number) end
populate_inner()
click to toggle source
# File lib/astromapper/builder/orbit.rb, line 54 def populate_inner roll = toss(2,0) return case when roll < 5 then self when (5..6) === roll then Hostile.new(@star, @orbit_number) when (7..9) === roll then Rockball.new(@star, @orbit_number) when (10..11) === roll then Belt.new(@star, @orbit_number) else GasGiant.new(@star, @orbit_number) end end
populate_outer()
click to toggle source
# File lib/astromapper/builder/orbit.rb, line 64 def populate_outer roll = toss(1,0) roll += 1 if distant? return case when roll == 1 then Rockball.new(@star, @orbit_number) when roll == 2 then Belt.new(@star, @orbit_number) when roll == 3 then self when (4..7) === roll then GasGiant.new(@star, @orbit_number) else Rockball.new(@star, @orbit_number) end end
radii()
click to toggle source
# File lib/astromapper/builder/orbit.rb, line 88 def radii; (@au * 200).to_i; end
to_ascii()
click to toggle source
# File lib/astromapper/builder/orbit.rb, line 78 def to_ascii bio = (@zone == 0 ) ? '*' : ' ' bio = '-' if @au > @star.outer_limit output = " -- %2s. %s %s // %s // %4.1f au" % [@orbit_number + 1, bio, @kid, self.uwp, @au] @moons.each {|m| output += m.to_ascii} unless @moons.nil? or @moons == 0 output end
to_s()
click to toggle source
# File lib/astromapper/builder/orbit.rb, line 75 def to_s @kid end
uwp()
click to toggle source
# File lib/astromapper/builder/orbit.rb, line 34 def uwp '.......-.' # "%s%s%s%s%s%s%s-%s" % [port, @size.hexd, @atmo.hexd, @h20.hexd, @popx.hexd, @govm.hexd, @law.hexd, @tek.hexd] end