Class: Configuration

Inherits:
Object
  • Object
show all
Includes:
Configuration_accessors
Defined in:
lib/configuration.rb

Instance Attribute Summary

Attributes included from Configuration_accessors

#battlefield, #bullets, #game, #mines, #robots, #toolboxes

Instance Method Summary collapse

Constructor Details

#initialize(filename = "rrobots.yml") ⇒ Configuration

Returns a new instance of Configuration.



20
21
22
23
24
25
26
27
28
# File 'lib/configuration.rb', line 20

def initialize(filename="rrobots.yml")
  @filename = filename
  @game = { :timeout => 50000 }
  @toolboxes = { :with_toolboxes => false, :life_time => 200, :spawning_chances => 100, :energy_heal_points => 20 }
  @robots = { :energy_max => 100, :nb_mines => 3, :radar_mine_scanning_performance => 500 }
  @bullets = { :speed => 30 } 
  @battlefield = { :height => 800, :width => 800 }
  @mines = { :with_mines => false, :energy_hit_points => 20, :bullet_energy_resistance => 2 }
end

Instance Method Details

#write_config(path = '.') ⇒ Object



14
15
16
17
18
# File 'lib/configuration.rb', line 14

def write_config(path='.')
  filepath = "#{path}/#{@filename}"
  File.unlink(filepath) if File::exist?(filepath)
  File.open(filepath, 'w') { |f| f.puts self.to_yaml }
end