-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglad-methods.rb
executable file
·197 lines (171 loc) · 7.04 KB
/
glad-methods.rb
1
2
3
4
5
6
7
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# -*- coding: utf-8 -*-
@total_time = 0
def login
@driver = Selenium::WebDriver.for :firefox
@driver.get "http://s1.gladiatus.gr/game/"
@driver.find_element(:id, "login_username").click
@driver.find_element(:id, "login_username").clear
@driver.find_element(:id, "login_username").send_keys "yourusername"
@driver.find_element(:id, "login_password").clear
@driver.find_element(:id, "login_password").send_keys "yourpassword"
@driver.find_element(:id, "loginsubmit").click
end
def login2
@driver = Selenium::WebDriver.for :firefox
@driver.get "http://s1.gladiatus.gr/game/"
@driver.find_element(:id, "login_username").click
@driver.find_element(:id, "login_username").clear
@driver.find_element(:id, "login_username").send_keys "yourusername2"
@driver.find_element(:id, "login_password").clear
@driver.find_element(:id, "login_password").send_keys "yourpassword2"
@driver.find_element(:id, "loginsubmit").click
end
def get_time_of_next_attack
# From Attacks
cooldown = @driver.find_elements(:id, "cooldown_bar_text_expedition")
time = cooldown.first.text
hours = time.match(/\d+/)
minutes = time.match(/:\d+/)#.gsub(":", "")
seconds = time.match(/:\d+:\d+/)
hours = hours.to_s.to_i
minutes = minutes.to_s.slice(1..3).to_i
seconds = seconds.to_s.slice(4..5).to_i
@exp_time = 0
@exp_time = hours*60*60 + minutes * 60 + seconds + 30
puts "Expedition: #{@exp_time}"
# From Mpountroumi
cooldown = @driver.find_elements(:id, "cooldown_bar_text_dungeon")
time = cooldown.first.text
hours = time.match(/\d+/)
minutes = time.match(/:\d+/)#.gsub(":", "")
seconds = time.match(/:\d+:\d+/)
hours = hours.to_s.to_i
minutes = minutes.to_s.slice(1..3).to_i
seconds = seconds.to_s.slice(4..5).to_i
@mpou_time = 0
@mpou_time = hours*60*60 + minutes * 60 + seconds + 30
puts "Mpountroumi: #{@mpou_time}"
# From Arena
cooldown = @driver.find_elements(:id, "cooldown_bar_text_arena")
time = cooldown.first.text
hours = time.match(/\d+/)
minutes = time.match(/:\d+/)#.gsub(":", "")
seconds = time.match(/:\d+:\d+/)
hours = hours.to_s.to_i
minutes = minutes.to_s.slice(1..3).to_i
seconds = seconds.to_s.slice(4..5).to_i
@arena_time = 0
@arena_time = hours*60*60 + minutes * 60 + seconds + 30
puts "Arena: #{@arena_time}"
# From Cosmoarena
cooldown = @driver.find_elements(:id, "cooldown_bar_text_ct")
time = cooldown.first.text
hours = time.match(/\d+/)
minutes = time.match(/:\d+/)#.gsub(":", "")
seconds = time.match(/:\d+:\d+/)
hours = hours.to_s.to_i
minutes = minutes.to_s.slice(1..3).to_i
seconds = seconds.to_s.slice(4..5).to_i
@cosmo_arena_time = 0
@cosmo_arena_time = hours*60*60 + minutes * 60 + seconds + 30
puts "Cosmo Arena: #{@cosmo_arena_time}"
@times = []
@times << @mpou_time
@times << @exp_time
@times << @arena_time
@times << @cosmo_arena_time
@times.sort!
@total_time = @times[0]
#if @mpou_time < @exp_time
# @total_time = @mpou_time
#else
# @total_time = @exp_time
#end
puts "ATTACK!" if @total_time == 30
end
def show_hp
@hp = @driver.find_element(:id, "header_values_hp_percent").text
@hp = @hp.to_s.gsub("%","").to_i
puts "HP: #{@hp}"
end
def exp_attack
@driver.find_element(:class, "cooldown_bar_link").click # p "Attack!"
@driver.find_element(:xpath, "(//button[@value=''])[2]").click
end
def mpou_attack
@driver.find_element(:xpath, "(//a[@class='cooldown_bar_link'])[2]").click
start_boundroumi = @driver.find_elements(:class, "button1")
start_boundroumi.first.click if start_boundroumi.first.attribute('value') == "Κανονικό"
@driver.find_elements(:xpath, "(//img[@onclick])").first.click
end
def arena_attack
@driver.find_element(:xpath, "(//a[@class='cooldown_bar_link'])[3]").click
@driver.find_element(:link, "Αρένα Επαρχιών").click
@arena_table = []
(2..6).each do |i|
@arena_table << [i, @driver.find_element(:xpath, "/html/body/div[2]/div/div[5]/div/div[2]/div[2]/table/tbody/tr[2]/td/div[2]/div/table/tbody/tr[#{i}]/td[2]").text]
end
@arena_table.sort_by! { |row| row[1] }
puts "To mikrotero level einai tis grammis #{@arena_table[0][0] - 1} me level #{@arena_table[0][1]}"
@driver.find_element(:xpath, "/html/body/div[2]/div/div[5]/div/div[2]/div[2]/table/tbody/tr[2]/td/div[2]/div/table/tbody/tr[#{@arena_table[0][0]}]/td[4]/span").click
end
def cosmoarena_attack
@driver.find_element(:xpath, "(//a[@class='cooldown_bar_link'])[4]").click
@driver.find_element(:link, "Αρένα Κοσμοσυρροής").click
@cosmo_table = []
(2..6).each do |i|
@cosmo_table << [i, @driver.find_element(:xpath, "/html/body/div[2]/div/div[5]/div/div[2]/div[2]/table/tbody/tr[2]/td/div[2]/div/table/tbody/tr[#{i}]/td[2]").text]
end
@cosmo_table.sort_by! { |row| row[1] }
puts "To mikrotero level einai tis grammis #{@cosmo_table[0][0] - 1} me level #{@cosmo_table[0][1]}"
@driver.find_element(:xpath, "/html/body/div[2]/div/div[5]/div/div[2]/div[2]/table/tbody/tr[2]/td/div[2]/div/table/tbody/tr[#{@cosmo_table[0][0]}]/td[4]/span").click
#@driver.find_element(:xpath, "/html/body/div[2]/div/div[5]/div/div[2]/div[2]/table/tbody/tr[2]/td/div[2]/div/table/tbody/tr[3]/td[4]/span").click
end
def gladjob_one
@driver.execute_script("switchMenu(1)")
@driver.find_element(:link, "Δουλειά").click
@driver.find_element(:id, "content").click
unless @driver.find_elements(:id, "ticker1").size == 1
Selenium::WebDriver::Support::Select.new(@driver.find_element(:id, "workTime")).select_by(:text, "1 Ώρα")
@driver.find_element(:id, "doWork").click
end
`killall -9 firefox`
sleep 3720
puts "3720"
end
def gladjob_eight
@driver.execute_script("switchMenu(1)")
@driver.find_element(:link, "Δουλειά").click
@driver.find_element(:id, "content").click
unless @driver.find_elements(:id, "ticker1").size == 1
Selenium::WebDriver::Support::Select.new(@driver.find_element(:id, "workTime")).select_by(:text, "8 Ώρες")
@driver.find_element(:id, "doWork").click
end
`killall -9 firefox`
sleep 3720
puts "3720"
end
def show_tagma_enemies
login
@driver.find_element(:link, "Τάγμα").click
@driver.find_element(:id, "war_master_div").click
@driver.find_elements(:xpath, "//div[@class='report_statistic']//table//tr").each do |table_line|
#puts table_line.find_elements(:xpath, "//td").first.text #first.find_element(:xpath, "//a").
puts table_line.text[0..-3]
end
end
def max_job_per_hour
@driver.execute_script("switchMenu(1)")
@driver.find_element(:link, "Δουλειά").click
@driver.find_element(:id, "content").click
@driver.find_element(:id, "job_row_4").click
unless @driver.find_elements(:id, "ticker1").size == 1
Selenium::WebDriver::Support::Select.new(@driver.find_element(:id, "workTime")).select_by(:text, "1 Ώρα")
@driver.find_element(:id, "doWork").click
end
`killall -9 firefox`
puts "3720"
sleep 3720
end
def eat
end