Class: Zyps::PopulationLimit

Inherits:
EnvironmentalFactor show all
Defined in:
lib/zyps/environmental_factors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(count) ⇒ PopulationLimit

Returns a new instance of PopulationLimit.



218
219
220
# File 'lib/zyps/environmental_factors.rb', line 218

def initialize(count)
	self.count = count
end

Instance Attribute Details

#countObject

Maximum allowed population.



216
217
218
# File 'lib/zyps/environmental_factors.rb', line 216

def count
  @count
end

Instance Method Details

#act(environment) ⇒ Object

Remove target if there are too many objects in environment.



223
224
225
226
# File 'lib/zyps/environmental_factors.rb', line 223

def act(environment)
	excess = environment.objects.length - @count
	environment.objects.slice!(0, excess) if excess > 0
end