travian_bot 0.2.4 → 0.3.0

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 CHANGED
@@ -7,4 +7,8 @@ end
7
7
 
8
8
  gem 'selenium-webdriver'
9
9
  gem 'chronic_duration'
10
- gem 'term-ansicolor'
10
+ gem 'term-ansicolor'
11
+
12
+ # Possible Gems to use.
13
+ gem 'bombshell' # Custom IRB consoles made easy https://github.com/rossmeissl/bombshell
14
+ # gem 'rubikon' # A simple to use, yet powerful Ruby framework for building console-based applications. https://github.com/koraktor/rubikon
@@ -1,6 +1,7 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
+ bombshell (0.1.5)
4
5
  childprocess (0.2.2)
5
6
  ffi (~> 1.0.6)
6
7
  chronic_duration (0.9.6)
@@ -26,6 +27,7 @@ PLATFORMS
26
27
  ruby
27
28
 
28
29
  DEPENDENCIES
30
+ bombshell
29
31
  bundler
30
32
  chronic_duration
31
33
  jeweler (~> 1.6.4)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.4
1
+ 0.3.0
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.dirname(__FILE__) + '/../lib') unless $:.include?(File.dirname(__FILE__) + '/../lib')
3
+
4
+ require 'rubygems'
5
+ require 'travian_bot/shell'
6
+ require 'bombshell'
7
+
8
+ Bombshell.launch(TravianBot::Shell)
@@ -1,3 +1 @@
1
- class TravianBot
2
- autoload :Application, 'travian_bot/application'
3
- end
1
+ Dir.glob(File.join(File.dirname(__FILE__), '/travian_bot/*.rb')).sort.each { |lib| load lib }
@@ -16,14 +16,19 @@ class TravianBot
16
16
  h1('Welcome to your TravianBot')
17
17
  @game = login
18
18
 
19
- current_building_queue
20
- current_troop_movements
21
- current_avaible_buildings
19
+ #current_building_queue
20
+ #current_troop_movements
21
+ #current_avaible_buildings
22
22
 
23
23
  h2('Custom actions actions')
24
- text 'closest_adventure'
25
- command = gets
26
- start_closest_adventure @game if command == 'closest_adventure'
24
+ text '1 => closest_adventure'
25
+ new_line
26
+
27
+ command = gets.chomp
28
+ if '1'.eql?(command)
29
+ h2 'Start the closest adventure'
30
+ puts start_closest_adventure(@game)
31
+ end
27
32
  @game.quit
28
33
 
29
34
  return 1
@@ -38,6 +43,7 @@ class TravianBot
38
43
  text building.to_s
39
44
  end
40
45
  new_line
46
+ sleep(3)
41
47
  end
42
48
 
43
49
  def current_building_queue
@@ -53,6 +59,7 @@ class TravianBot
53
59
  end
54
60
  end
55
61
  new_line
62
+ sleep(3)
56
63
  end
57
64
 
58
65
  def current_troop_movements
@@ -68,6 +75,7 @@ class TravianBot
68
75
  end
69
76
  end
70
77
  new_line
78
+ sleep(3)
71
79
  end
72
80
  end
73
81
  end
@@ -12,13 +12,11 @@ class TravianBot
12
12
  puts "#{text}".red
13
13
  puts "=".red * text.length
14
14
  puts ' '
15
- puts ' '
16
15
  end
17
16
 
18
17
  def h2(text)
19
18
  puts "#{text}".yellow
20
19
  puts "-".yellow * text.length
21
- puts ' '
22
20
  end
23
21
 
24
22
  def text(text)
@@ -18,11 +18,21 @@ class TravianBot
18
18
  shortest_quest = quests.sort{|a,b| a[1] <=> b[1]}.first.first
19
19
  elements[shortest_quest].find_element(:class, 'gotoAdventure').click
20
20
 
21
- link = selenium.find_element(:link_text, 'Abenteuer starten')
22
- link.click
21
+ begin
22
+ link = selenium.find_element(:link_text, 'Abenteuer starten')
23
+ link.click
24
+ rescue
25
+ return ['Currently the hero is busy for a quest.', [0, 0]]
26
+ end
27
+
28
+ mission_name = selenium.find_element(:xpath, '//span[@class="coordinates coordinatesWithText"]/span[@class="coordText"]')
29
+ coordinate_x = selenium.find_element(:xpath, 'span[@class="coordinates coordinatesWithText"]/span[@class="coordinateX"]')
30
+ coordinate_y = selenium.find_element(:xpath, 'span[@class="coordinates coordinatesWithText"]/span[@class="coordinateY"]')
23
31
 
24
32
  confirm_link = selenium.find_element(:id, 'btn_ok')
25
33
  confirm_link.click
34
+
35
+ [mission_name, [coordinate_x.sub('(', ''), coordinate_y.sub(')', '')]]
26
36
  end
27
37
  end
28
38
  end
@@ -0,0 +1,28 @@
1
+ require 'bombshell'
2
+ require 'travian_bot/application'
3
+
4
+ class TravianBot
5
+ class Shell < Bombshell::Environment
6
+ include Bombshell::Shell
7
+ include TravianBot::Application::Connection
8
+ include TravianBot::Application::Hero
9
+
10
+ prompt_with 'travianbot'
11
+
12
+ having_launched do
13
+ @browser = login
14
+ init # binding is on your shell *class*
15
+ end
16
+
17
+ def start_quest
18
+ start_closest_adventure @browser
19
+ end
20
+
21
+ def help
22
+ h1 'Help'
23
+ end
24
+
25
+ private
26
+ include TravianBot::Application::Display
27
+ end
28
+ end
@@ -5,14 +5,14 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "travian_bot"
8
- s.version = "0.2.4"
8
+ s.version = "0.3.0"
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-25"
12
+ s.date = "2011-10-27"
13
13
  s.description = "A little bot for travian."
14
14
  s.email = "roman.simecek@cyt.ch"
15
- s.executables = ["travianbot"]
15
+ s.executables = ["travianbot", "travianshell"]
16
16
  s.extra_rdoc_files = [
17
17
  "LICENSE.txt",
18
18
  "README.rdoc"
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
26
26
  "Rakefile",
27
27
  "VERSION",
28
28
  "bin/travianbot",
29
+ "bin/travianshell",
29
30
  "lib/travian_bot.rb",
30
31
  "lib/travian_bot/application.rb",
31
32
  "lib/travian_bot/application/buildings.rb",
@@ -35,6 +36,7 @@ Gem::Specification.new do |s|
35
36
  "lib/travian_bot/application/navigation.rb",
36
37
  "lib/travian_bot/application/queue.rb",
37
38
  "lib/travian_bot/application/time.rb",
39
+ "lib/travian_bot/shell.rb",
38
40
  "test/helper.rb",
39
41
  "test/test_travian_bot.rb",
40
42
  "travian_bot.gemspec"
@@ -52,12 +54,14 @@ Gem::Specification.new do |s|
52
54
  s.add_runtime_dependency(%q<selenium-webdriver>, [">= 0"])
53
55
  s.add_runtime_dependency(%q<chronic_duration>, [">= 0"])
54
56
  s.add_runtime_dependency(%q<term-ansicolor>, [">= 0"])
57
+ s.add_runtime_dependency(%q<bombshell>, [">= 0"])
55
58
  s.add_development_dependency(%q<bundler>, [">= 0"])
56
59
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
57
60
  else
58
61
  s.add_dependency(%q<selenium-webdriver>, [">= 0"])
59
62
  s.add_dependency(%q<chronic_duration>, [">= 0"])
60
63
  s.add_dependency(%q<term-ansicolor>, [">= 0"])
64
+ s.add_dependency(%q<bombshell>, [">= 0"])
61
65
  s.add_dependency(%q<bundler>, [">= 0"])
62
66
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
63
67
  end
@@ -65,6 +69,7 @@ Gem::Specification.new do |s|
65
69
  s.add_dependency(%q<selenium-webdriver>, [">= 0"])
66
70
  s.add_dependency(%q<chronic_duration>, [">= 0"])
67
71
  s.add_dependency(%q<term-ansicolor>, [">= 0"])
72
+ s.add_dependency(%q<bombshell>, [">= 0"])
68
73
  s.add_dependency(%q<bundler>, [">= 0"])
69
74
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
70
75
  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
4
+ version: 0.3.0
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-25 00:00:00.000000000Z
12
+ date: 2011-10-27 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: selenium-webdriver
16
- requirement: &2156662640 !ruby/object:Gem::Requirement
16
+ requirement: &2152470780 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2156662640
24
+ version_requirements: *2152470780
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: chronic_duration
27
- requirement: &2156661960 !ruby/object:Gem::Requirement
27
+ requirement: &2152470300 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2156661960
35
+ version_requirements: *2152470300
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: term-ansicolor
38
- requirement: &2156659580 !ruby/object:Gem::Requirement
38
+ requirement: &2152469820 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,21 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2156659580
46
+ version_requirements: *2152469820
47
+ - !ruby/object:Gem::Dependency
48
+ name: bombshell
49
+ requirement: &2152469340 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *2152469340
47
58
  - !ruby/object:Gem::Dependency
48
59
  name: bundler
49
- requirement: &2156658900 !ruby/object:Gem::Requirement
60
+ requirement: &2152468860 !ruby/object:Gem::Requirement
50
61
  none: false
51
62
  requirements:
52
63
  - - ! '>='
@@ -54,10 +65,10 @@ dependencies:
54
65
  version: '0'
55
66
  type: :development
56
67
  prerelease: false
57
- version_requirements: *2156658900
68
+ version_requirements: *2152468860
58
69
  - !ruby/object:Gem::Dependency
59
70
  name: jeweler
60
- requirement: &2156658280 !ruby/object:Gem::Requirement
71
+ requirement: &2152468380 !ruby/object:Gem::Requirement
61
72
  none: false
62
73
  requirements:
63
74
  - - ~>
@@ -65,11 +76,12 @@ dependencies:
65
76
  version: 1.6.4
66
77
  type: :development
67
78
  prerelease: false
68
- version_requirements: *2156658280
79
+ version_requirements: *2152468380
69
80
  description: A little bot for travian.
70
81
  email: roman.simecek@cyt.ch
71
82
  executables:
72
83
  - travianbot
84
+ - travianshell
73
85
  extensions: []
74
86
  extra_rdoc_files:
75
87
  - LICENSE.txt
@@ -83,6 +95,7 @@ files:
83
95
  - Rakefile
84
96
  - VERSION
85
97
  - bin/travianbot
98
+ - bin/travianshell
86
99
  - lib/travian_bot.rb
87
100
  - lib/travian_bot/application.rb
88
101
  - lib/travian_bot/application/buildings.rb
@@ -92,6 +105,7 @@ files:
92
105
  - lib/travian_bot/application/navigation.rb
93
106
  - lib/travian_bot/application/queue.rb
94
107
  - lib/travian_bot/application/time.rb
108
+ - lib/travian_bot/shell.rb
95
109
  - test/helper.rb
96
110
  - test/test_travian_bot.rb
97
111
  - travian_bot.gemspec
@@ -110,7 +124,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
124
  version: '0'
111
125
  segments:
112
126
  - 0
113
- hash: 4286807613602955578
127
+ hash: 1724651346905237761
114
128
  required_rubygems_version: !ruby/object:Gem::Requirement
115
129
  none: false
116
130
  requirements: