Class: MarsBase10::Controller

Inherits:
Object
  • Object
show all
Defined in:
lib/mars_base_10/controller.rb

Direct Known Subclasses

GraphRover, GroupRoom, SocialLounge

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(manager:, ship_connection:, viewport:, options: {}) ⇒ Controller

Returns a new instance of Controller.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/mars_base_10/controller.rb', line 11

def initialize(manager:, ship_connection:, viewport:, options: {})
  @manager = manager
  @ship = Ship.new connection: ship_connection
  @stack = Stack.new
  @viewport = viewport
  @viewport.controller = self

  self.wire_up_panes
  self.action_bar = ActionBar.Default.add_action({'i': 'Inspect'})
  self.viewport.activate pane: @pane_1
  self.show
end

Instance Attribute Details

#managerObject (readonly)

Returns the value of attribute manager.



9
10
11
# File 'lib/mars_base_10/controller.rb', line 9

def manager
  @manager
end

#panesObject (readonly)

Returns the value of attribute panes.



9
10
11
# File 'lib/mars_base_10/controller.rb', line 9

def panes
  @panes
end

#shipObject (readonly)

Returns the value of attribute ship.



9
10
11
# File 'lib/mars_base_10/controller.rb', line 9

def ship
  @ship
end

#viewportObject (readonly)

Returns the value of attribute viewport.



9
10
11
# File 'lib/mars_base_10/controller.rb', line 9

def viewport
  @viewport
end

Instance Method Details

#action_barObject



24
25
26
# File 'lib/mars_base_10/controller.rb', line 24

def action_bar
  self.viewport.action_bar
end

#active_nodeObject



28
29
30
# File 'lib/mars_base_10/controller.rb', line 28

def active_node
  self.ship.fetch_node(resource: self.active_resource, index: self.active_node_index)
end

#active_resourceObject



32
33
34
# File 'lib/mars_base_10/controller.rb', line 32

def active_resource
  @pane_1.current_subject_index
end

#showObject



36
37
38
# File 'lib/mars_base_10/controller.rb', line 36

def show
  self.resync
end

#startObject



40
41
42
# File 'lib/mars_base_10/controller.rb', line 40

def start
  self.viewport.open
end

#stopObject



44
45
46
# File 'lib/mars_base_10/controller.rb', line 44

def stop
  self.viewport.close
end