travian_bot 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +2 -1
- data/Gemfile.lock +4 -0
- data/VERSION +1 -1
- data/lib/travian_bot/application.rb +6 -2
- data/lib/travian_bot/application/connection.rb +2 -2
- data/lib/travian_bot/application/hero.rb +29 -0
- data/lib/travian_bot/application/navigation.rb +4 -1
- data/lib/travian_bot/application/time.rb +11 -0
- data/travian_bot.gemspec +7 -2
- metadata +22 -9
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -3,6 +3,8 @@ GEM
|
|
3
3
|
specs:
|
4
4
|
childprocess (0.2.2)
|
5
5
|
ffi (~> 1.0.6)
|
6
|
+
chronic_duration (0.9.6)
|
7
|
+
numerizer (~> 0.1.1)
|
6
8
|
ffi (1.0.9)
|
7
9
|
git (1.2.5)
|
8
10
|
jeweler (1.6.4)
|
@@ -10,6 +12,7 @@ GEM
|
|
10
12
|
git (>= 1.2.5)
|
11
13
|
rake
|
12
14
|
json_pure (1.6.1)
|
15
|
+
numerizer (0.1.1)
|
13
16
|
rake (0.9.2.2)
|
14
17
|
rubyzip (0.9.4)
|
15
18
|
selenium-webdriver (2.9.1)
|
@@ -23,5 +26,6 @@ PLATFORMS
|
|
23
26
|
|
24
27
|
DEPENDENCIES
|
25
28
|
bundler
|
29
|
+
chronic_duration
|
26
30
|
jeweler (~> 1.6.4)
|
27
31
|
selenium-webdriver
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.3
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'selenium-webdriver'
|
2
|
-
Dir.glob(File.join(File.dirname(__FILE__), '/application/*.rb')).sort.each { |lib| load lib }
|
3
2
|
|
3
|
+
Dir.glob(File.join(File.dirname(__FILE__), '/application/*.rb')).sort.each { |lib| load lib }
|
4
4
|
|
5
5
|
class TravianBot
|
6
6
|
class Application
|
@@ -9,16 +9,20 @@ class TravianBot
|
|
9
9
|
include Queue
|
10
10
|
include Display
|
11
11
|
include Buildings
|
12
|
+
include Hero
|
12
13
|
|
13
14
|
# Is executed by the travinbot shell script.
|
14
15
|
def run!(*arguments)
|
15
16
|
h1('Welcome to your TravianBot')
|
16
17
|
@game = login
|
17
18
|
|
19
|
+
h2('Your avaible actions')
|
20
|
+
#command = gets
|
21
|
+
#self.send(command)
|
18
22
|
current_building_queue
|
19
23
|
current_troop_movements
|
20
24
|
current_avaible_buildings
|
21
|
-
|
25
|
+
start_closest_adventure @game
|
22
26
|
@game.quit
|
23
27
|
|
24
28
|
return 1
|
@@ -5,9 +5,9 @@ class TravianBot
|
|
5
5
|
module Connection
|
6
6
|
# Login in to travian page
|
7
7
|
def login
|
8
|
-
url, user, password = get_credentials
|
8
|
+
@url, user, password = get_credentials
|
9
9
|
driver = Selenium::WebDriver.for :firefox
|
10
|
-
driver.navigate.to(url)
|
10
|
+
driver.navigate.to(@url)
|
11
11
|
# Get the form fields.
|
12
12
|
name_input = driver.find_element(:name, 'name')
|
13
13
|
password_input = driver.find_element(:name, 'password')
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'travian_bot/application/time'
|
2
|
+
|
3
|
+
class TravianBot
|
4
|
+
class Application
|
5
|
+
module Hero
|
6
|
+
include TravianBot::Application::Navigation
|
7
|
+
include TravianBot::Application::Time
|
8
|
+
|
9
|
+
def start_closest_adventure(selenium)
|
10
|
+
to_hero_quest_page(selenium)
|
11
|
+
elements = selenium.find_elements(:xpath, '//div[@class="hero_adventure"]/table/tbody/tr')
|
12
|
+
quests = Hash.new
|
13
|
+
|
14
|
+
elements.each_with_index do |item, index|
|
15
|
+
quests[index] = to_seconds(item.find_element(:class, 'moveTime').text)
|
16
|
+
end
|
17
|
+
|
18
|
+
shortest_quest = quests.sort{|a,b| a[1] <=> b[1]}.first.first
|
19
|
+
elements[shortest_quest].find_element(:class, 'gotoAdventure').click
|
20
|
+
|
21
|
+
link = selenium.find_element(:link_text, 'Abenteuer starten')
|
22
|
+
link.click
|
23
|
+
|
24
|
+
confirm_link = selenium.find_element(:id, 'btn_ok')
|
25
|
+
confirm_link.click
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -21,9 +21,12 @@ class TravianBot
|
|
21
21
|
to_page(selenium, 'reports')
|
22
22
|
end
|
23
23
|
|
24
|
+
def to_hero_quest_page(selenium)
|
25
|
+
selenium.navigate.to @url + "hero_adventure.php"
|
26
|
+
end
|
27
|
+
|
24
28
|
private
|
25
29
|
def to_page(selenium, target)
|
26
|
-
wait = Selenium::WebDriver::Wait.new
|
27
30
|
link = selenium.find_element(:xpath, "//ul[@id='navigation']/li[@class='#{target}']/a")
|
28
31
|
link.click
|
29
32
|
end
|
data/travian_bot.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "travian_bot"
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Roman Simecek"]
|
12
|
-
s.date = "2011-10-
|
12
|
+
s.date = "2011-10-25"
|
13
13
|
s.description = "A little bot for travian."
|
14
14
|
s.email = "roman.simecek@cyt.ch"
|
15
15
|
s.executables = ["travianbot"]
|
@@ -31,8 +31,10 @@ Gem::Specification.new do |s|
|
|
31
31
|
"lib/travian_bot/application/buildings.rb",
|
32
32
|
"lib/travian_bot/application/connection.rb",
|
33
33
|
"lib/travian_bot/application/display.rb",
|
34
|
+
"lib/travian_bot/application/hero.rb",
|
34
35
|
"lib/travian_bot/application/navigation.rb",
|
35
36
|
"lib/travian_bot/application/queue.rb",
|
37
|
+
"lib/travian_bot/application/time.rb",
|
36
38
|
"test/helper.rb",
|
37
39
|
"test/test_travian_bot.rb",
|
38
40
|
"travian_bot.gemspec"
|
@@ -48,15 +50,18 @@ Gem::Specification.new do |s|
|
|
48
50
|
|
49
51
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
50
52
|
s.add_runtime_dependency(%q<selenium-webdriver>, [">= 0"])
|
53
|
+
s.add_runtime_dependency(%q<chronic_duration>, [">= 0"])
|
51
54
|
s.add_development_dependency(%q<bundler>, [">= 0"])
|
52
55
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
53
56
|
else
|
54
57
|
s.add_dependency(%q<selenium-webdriver>, [">= 0"])
|
58
|
+
s.add_dependency(%q<chronic_duration>, [">= 0"])
|
55
59
|
s.add_dependency(%q<bundler>, [">= 0"])
|
56
60
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
57
61
|
end
|
58
62
|
else
|
59
63
|
s.add_dependency(%q<selenium-webdriver>, [">= 0"])
|
64
|
+
s.add_dependency(%q<chronic_duration>, [">= 0"])
|
60
65
|
s.add_dependency(%q<bundler>, [">= 0"])
|
61
66
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
62
67
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: travian_bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-10-
|
12
|
+
date: 2011-10-25 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: selenium-webdriver
|
16
|
-
requirement: &
|
16
|
+
requirement: &2165300380 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,21 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2165300380
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: chronic_duration
|
27
|
+
requirement: &2165299440 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2165299440
|
25
36
|
- !ruby/object:Gem::Dependency
|
26
37
|
name: bundler
|
27
|
-
requirement: &
|
38
|
+
requirement: &2165298460 !ruby/object:Gem::Requirement
|
28
39
|
none: false
|
29
40
|
requirements:
|
30
41
|
- - ! '>='
|
@@ -32,10 +43,10 @@ dependencies:
|
|
32
43
|
version: '0'
|
33
44
|
type: :development
|
34
45
|
prerelease: false
|
35
|
-
version_requirements: *
|
46
|
+
version_requirements: *2165298460
|
36
47
|
- !ruby/object:Gem::Dependency
|
37
48
|
name: jeweler
|
38
|
-
requirement: &
|
49
|
+
requirement: &2165297340 !ruby/object:Gem::Requirement
|
39
50
|
none: false
|
40
51
|
requirements:
|
41
52
|
- - ~>
|
@@ -43,7 +54,7 @@ dependencies:
|
|
43
54
|
version: 1.6.4
|
44
55
|
type: :development
|
45
56
|
prerelease: false
|
46
|
-
version_requirements: *
|
57
|
+
version_requirements: *2165297340
|
47
58
|
description: A little bot for travian.
|
48
59
|
email: roman.simecek@cyt.ch
|
49
60
|
executables:
|
@@ -66,8 +77,10 @@ files:
|
|
66
77
|
- lib/travian_bot/application/buildings.rb
|
67
78
|
- lib/travian_bot/application/connection.rb
|
68
79
|
- lib/travian_bot/application/display.rb
|
80
|
+
- lib/travian_bot/application/hero.rb
|
69
81
|
- lib/travian_bot/application/navigation.rb
|
70
82
|
- lib/travian_bot/application/queue.rb
|
83
|
+
- lib/travian_bot/application/time.rb
|
71
84
|
- test/helper.rb
|
72
85
|
- test/test_travian_bot.rb
|
73
86
|
- travian_bot.gemspec
|
@@ -86,7 +99,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
86
99
|
version: '0'
|
87
100
|
segments:
|
88
101
|
- 0
|
89
|
-
hash:
|
102
|
+
hash: -1008102311582387206
|
90
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
104
|
none: false
|
92
105
|
requirements:
|