Skip to content
This repository has been archived by the owner on Dec 9, 2020. It is now read-only.

Celebrations #41

Merged
merged 21 commits into from
Sep 26, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
parse celebration timers
  • Loading branch information
breuerfelix committed Sep 26, 2018
commit 172b8917a1165a5717b94ad9781b46770495effd
37 changes: 7 additions & 30 deletions src/celebration.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,11 @@ def start_celebration(browser: client, village: int, celebration_type: int) -> N

if 'disabled' in btnClasses:
log(f"not enough resources to start celebration in village: {village}")

close_modal(browser)
return

browser.click(button, 1)
# test
close_modal(browser)

def get_celebration_times(browser: client, villages: []) -> []:
open_village_overview(browser, overview.culture_points)
Expand All @@ -106,44 +105,22 @@ def get_celebration_times(browser: client, villages: []) -> []:
table = tab_content.find_element_by_xpath(".//table[contains(@class, 'villagesTable')]/tbody")

trs = table.find_elements_by_xpath(".//tr")

sleep_time_list = []
available_villages = []
for village in villages:
if len(trs) <= village:
log(f"couldn't access village: {village}")
continue

# village is available
span = trs[village].find_elements_by_xpath('.//td')[2]
log(span.get_attribute("innerHTML"))
span = span.find_element_by_xpath('.//span')

ngif = span.get_attribute('ng-if')

if "== 0" in ngif:
available_villages.append(village)


if '< 0' in ngif:
log(f'no townhall in village {village}')
elif '> 0' in ngif:
# TODO parse sleep time
sleep_time_list.append(10)
if '> 0' in ngif:
span = span.find_element_by_xpath('.//span')
time = span.get_attribute('innerHTML')
sleep_time_list.append(time)

# start celebrating
atag = span.find_element_by_xpath('.//a')
browser.click(atag, 1)

button = browser.find("//button[contains(@clickable, 'startCelebration')]")
btnClasses = button.get_attribute('class')

if 'disabled' in btnClasses:
log(f"not enough resources to start celebration in village: {village}")

close_modal(browser)
# open overview again
open_village_overview(browser, overview.culture_points)
continue

browser.click(button, 1)
pass
return sleep_time_list