Module: TravianBot::Application::Buildings

Includes:
Navigation
Included in:
TravianBot::Application
Defined in:
lib/travian_bot/application/buildings.rb

Instance Method Summary collapse

Methods included from Navigation

#to_hero_quest_page, #to_map_page, #to_reports_page, #to_resources_page, #to_stats_page, #to_village_page

Instance Method Details

#avaible_buildings(selenium) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/travian_bot/application/buildings.rb', line 8

def avaible_buildings(selenium)
  begin
    elements = selenium.find_elements(:xpath, '//map[@id="rx"]/area')
    resources = elements.inject([]) do |out, element|
      out << element.attribute('alt')
      
      out
    end
  rescue Selenium::WebDriver::Error::NoSuchElementError
    resources = []
  end
  
  to_village_page(selenium)
  show_building_level(selenium)
  
  begin
    elements = selenium.find_elements(:xpath, '//div[@id="village_map"]/map/area')
    buildings = elements.inject([]) do |out, element|
      out << element.attribute('alt')
      
      out
    end
  rescue Selenium::WebDriver::Error::NoSuchElementError
    buildings = []
  end
  
  resources + buildings
end