Class: Astromapper::Builder::Orbit
- Inherits:
-
Base
- Object
- Base
- Astromapper::Builder::Orbit
show all
- Defined in:
- lib/astromapper/builder/orbit.rb
Overview
Instance Attribute Summary collapse
Attributes inherited from Base
#root_dir
Instance Method Summary
collapse
Methods inherited from Base
#config, constitute, #names, #spawn_command, #toss
Constructor Details
#initialize(star, orbit_number, companion = nil) ⇒ Orbit
Returns a new instance of Orbit.
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# 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 when @au > @star.biozone[1] then 1 else 0
end
@distant = (@au > @star.biozone[1] * 10)
rescue
@zone = -1
@distant = 1000
end
end
|
Instance Attribute Details
#au ⇒ Object
Returns the value of attribute au.
6
7
8
|
# File 'lib/astromapper/builder/orbit.rb', line 6
def au
@au
end
|
#id ⇒ Object
Returns the value of attribute id.
6
7
8
|
# File 'lib/astromapper/builder/orbit.rb', line 6
def id
@id
end
|
#kid ⇒ Object
Returns the value of attribute kid.
6
7
8
|
# File 'lib/astromapper/builder/orbit.rb', line 6
def kid
@kid
end
|
#orbit_number ⇒ Object
Returns the value of attribute orbit_number.
6
7
8
|
# File 'lib/astromapper/builder/orbit.rb', line 6
def orbit_number
@orbit_number
end
|
#port ⇒ Object
Returns the value of attribute port.
6
7
8
|
# File 'lib/astromapper/builder/orbit.rb', line 6
def port
@port
end
|
#xsize ⇒ Object
Returns the value of attribute xsize.
6
7
8
|
# File 'lib/astromapper/builder/orbit.rb', line 6
def xsize
@xsize
end
|
Instance Method Details
#biozone? ⇒ Boolean
92
|
# File 'lib/astromapper/builder/orbit.rb', line 92
def biozone?; return @zone == 0; end
|
#distant? ⇒ Boolean
93
|
# File 'lib/astromapper/builder/orbit.rb', line 93
def distant?; @distant; end
|
#inner? ⇒ Boolean
90
|
# File 'lib/astromapper/builder/orbit.rb', line 90
def inner?; return @zone < 0; end
|
#km ⇒ Object
87
|
# File 'lib/astromapper/builder/orbit.rb', line 87
def km; return (150000000 * @au).to_i; end
|
#limit? ⇒ Boolean
89
|
# File 'lib/astromapper/builder/orbit.rb', line 89
def limit?; return @au < @star.limit ; end
|
#outer? ⇒ Boolean
91
|
# File 'lib/astromapper/builder/orbit.rb', line 91
def outer?; return @zone > 0; end
|
#period ⇒ Object
86
|
# File 'lib/astromapper/builder/orbit.rb', line 86
def period; (@au * 365.25).round(2); end
|
#populate ⇒ Object
40
41
42
43
44
45
46
47
48
|
# 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 ⇒ Object
49
50
51
52
53
|
# 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 ⇒ Object
54
55
56
57
58
59
60
61
62
63
|
# 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 ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
|
# 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 ⇒ Object
88
|
# File 'lib/astromapper/builder/orbit.rb', line 88
def radii; (@au * 200).to_i; end
|
#to_ascii ⇒ Object
78
79
80
81
82
83
84
85
|
# 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 ⇒ Object
75
76
77
|
# File 'lib/astromapper/builder/orbit.rb', line 75
def to_s
@kid
end
|
#uwp ⇒ Object
34
35
36
|
# File 'lib/astromapper/builder/orbit.rb', line 34
def uwp
'.......-.' end
|