Class: Astromapper::Builder::Planet

Inherits:
Orbit
  • Object
show all
Defined in:
lib/astromapper/builder/orbit.rb

Direct Known Subclasses

GasGiant, Hostile, Rockball, Terrestrial

Instance Attribute Summary

Attributes inherited from Orbit

#au, #id, #kid, #orbit_number, #port, #xsize

Attributes inherited from Base

#root_dir

Instance Method Summary collapse

Methods inherited from Orbit

#biozone?, #distant?, #inner?, #km, #limit?, #outer?, #period, #populate, #populate_biozone, #populate_inner, #populate_outer, #radii, #to_ascii, #to_s

Methods inherited from Base

#config, constitute, #names, #spawn_command, #toss

Constructor Details

#initialize(star, orbit_number) ⇒ Planet

Returns a new instance of Planet.



119
120
121
122
123
# File 'lib/astromapper/builder/orbit.rb', line 119

def initialize(star,orbit_number)
  super
  @moons = make_moons(toss(1,3))
  @size = toss if @size.nil? or @size == 0
end

Instance Method Details

#make_moons(c) ⇒ Object



124
125
126
127
128
129
130
131
# File 'lib/astromapper/builder/orbit.rb', line 124

def make_moons(c)
  moons = {}
  c.times { |i|
    m = Moon.new(self,i)
    moons["#{m.orbit}"] = m
  }
  moons.values.sort{ |a,b| a.orbit <=> b.orbit } unless @moons.size < 2
end

#uwpObject



132
133
134
# File 'lib/astromapper/builder/orbit.rb', line 132

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