Class: Astromapper::Builder::Moon

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

Overview

End World (Mainworld)

Constant Summary collapse

@@orbits =
{ 'C' => (1..14).to_a, 'R' => [1,1,1,2,2,3] }

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(planet, i = 0) ⇒ Moon

Returns a new instance of Moon.



321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
# File 'lib/astromapper/builder/orbit.rb', line 321

def initialize(planet,i=0)
  @planet = planet
  @popx = 0
  @law  = 0
  @tek  = 0
  @govm = 0
  @size = case
    when @planet.xsize = 'L' then toss(2,4)
    when @planet.xsize = 'S' then toss(2,6)
    else @planet.size - toss(1,0)
  end
  orbit = toss(2,i)
  @orbit = (case
    when (@size < 1) then @@orbits['R'][toss(1,1)]
    when (orbit == 12 and @planet.xsize == 'L') then @@orbits['E'][toss(2,0)]
    when (orbit < 8) then @@orbits['C'][toss(2,0)]
    when (orbit > 7) then @@orbits['C'][toss(2,0)]
    else 0
  end).whole
  @h20 = (case
    when (@planet.inner?) then 0
    when (@size == 0)    then 0
    when (@planet.outer?) then toss(2,4)
    when (@planet.biozone?) then toss(2,7)
    else 0
  end).whole
  @atmo = toss(2,7) + @size
  @atmo = (case
    when (@size == 0) then 0
    when (@planet.inner?) then @atmo - 4
    when (@planet.outer?) then @atmo - 4 
    else 0
  end).whole
end

Instance Attribute Details

#h20Object

Returns the value of attribute h20.



316
317
318
# File 'lib/astromapper/builder/orbit.rb', line 316

def h20
  @h20
end

#orbitObject

Returns the value of attribute orbit.



316
317
318
# File 'lib/astromapper/builder/orbit.rb', line 316

def orbit
  @orbit
end

#sizeObject

Returns the value of attribute size.



316
317
318
# File 'lib/astromapper/builder/orbit.rb', line 316

def size
  @size
end

Instance Method Details

#to_asciiObject



355
356
357
# File 'lib/astromapper/builder/orbit.rb', line 355

def to_ascii
  "\n%28s/  %3d rad. %s" % ['', @orbit, uwp]
end

#uwpObject



358
359
360
361
362
363
364
365
366
# File 'lib/astromapper/builder/orbit.rb', line 358

def uwp
  size = case
    when @size < 0 then 'S'
    when @size == 0 then 'R'
    else @size.hexd
  end
  # size = (@size == 0) ? 'R' : @size.hexd
  "%s%s%s%s%s%s%s" % ['X', size,@atmo.hexd,@h20.hexd,@popx.hexd,@govm.hexd,@law.hexd]
end