Class: XenosEnigma::HitCollector

Inherits:
Object
  • Object
show all
Defined in:
lib/xenos_enigma/hit_collector.rb

Overview

HitCollector will consume all ship hits, and cache their data and coordinates

Instance Method Summary collapse

Constructor Details

#initializeHitCollector

Returns a new instance of HitCollector.



4
5
6
# File 'lib/xenos_enigma/hit_collector.rb', line 4

def initialize
  @hit_matrix_cache = {}
end

Instance Method Details

#already_detected?(position_x, position_y) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/xenos_enigma/hit_collector.rb', line 12

def already_detected?(position_x, position_y)
  !get_cache(position_x, position_y).nil?
end

#detection_data(position_x, position_y) ⇒ Object



8
9
10
# File 'lib/xenos_enigma/hit_collector.rb', line 8

def detection_data(position_x, position_y)
  get_cache(position_x, position_y)
end

#push(xeno_hit, scan_position_x, scan_position_y) ⇒ Object



16
17
18
19
20
21
# File 'lib/xenos_enigma/hit_collector.rb', line 16

def push(xeno_hit, scan_position_x, scan_position_y)
  xeno_hit.radar_x_position = scan_position_x
  xeno_hit.radar_y_position = scan_position_y

  consume(xeno_hit)
end