Top Level Namespace
Defined Under Namespace
Modules: Configuration_accessors, GUI, RDoc, Robot
Classes: Battlefield, Bullet, Configuration, Explosion, Mine, Numeric, RobotRunner, Toolbox
Instance Method Summary
collapse
Instance Method Details
#gem_path(path = '') ⇒ Object
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/misc.rb', line 2
def gem_path(path='')
res = Array::new
table_map = Gem.location_of_caller.first.split('/')
table_map.each do |item|
res.push item
break if item =~ /UG_RRobots/
end
res.push path unless path.empty?
path_prefix = res.join('/')
return false unless File::exist?(path_prefix)
return path_prefix
end
|
#get_locale_from_env ⇒ Object
24
25
26
27
28
29
30
31
32
|
# File 'lib/misc.rb', line 24
def get_locale_from_env
if not ENV['LANGUAGE'].empty? then
locale = ENV['LANGUAGE'].split('_').first
elsif not ENV['LANG'].empty? then
locale = ENV['LANG'].split('_').first
else
locale = 'en'
end
end
|
#init_I18n(locales) ⇒ Object
18
19
20
21
22
|
# File 'lib/misc.rb', line 18
def init_I18n(locales)
I18n.default_locale = locales
locales_path = gem_path('config').concat("/locales")
I18n.load_path << Dir["#{locales_path}/*.yml"]
end
|
#load_gui(battlefield, xres, yres, speed_multiplier) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/GUI/tk.rb', line 4
def load_gui(battlefield, xres, yres, speed_multiplier)
arena = GUI::TkArena.new(battlefield, xres, yres, speed_multiplier)
game_over_counter = battlefield.teams.all?{|k,t| t.size < 2} ? 250 : 500
outcome_printed = false
arena.on_game_over{|battlefield|
unless outcome_printed
print_outcome(battlefield)
outcome_printed = true
end
exit 0 if game_over_counter < 0
game_over_counter -= 1
}
arena.run
end
|