Exemple #1
0
 def celebrate(self):
     config = util.readConfig()
     villagesId = config["VILLAGESID"]
     while True:
         if (self.isCelebrate()):
             for villageId in villagesId:
                 self.browser.get(config["SERVER"] + "/build.php" +
                                  "?newdid=" + str(villageId) +
                                  "&id=21&type=2")
                 util.waitUntil(self.browser, 5, 'build_logo')
                 time.sleep(1)
                 try:
                     celebrateStatusContainer = self.browser.find_element_by_xpath(
                         "//div[@class='villageListBarBox']/div[@class='bar']"
                     )
                     celebrateStatus = str(
                         celebrateStatusContainer.get_attribute(
                             'style')).split(':')[1]
                     print("<< Celebrate >> Progress: " +
                           str(celebrateStatus))
                     time.sleep(1)
                 except:
                     print("Error")
         else:
             break
Exemple #2
0
 def sendResourceToVillageId(self, villageId):
     config = util.readConfig()
     capitalId = config["VILLAGESID"][0]
     util.goToVillageBuiding(self.browser, capitalId, '36')
     util.waitUntil(self.browser, 5, 'build_logo')
     self.inputResource()
     self.inputCoordinate(villageId)
     self.submitResource(capitalId, villageId)
Exemple #3
0
 def createSettler(self):
     villagesId = util.readConfigWithKey("VILLAGESID")
     for villageId in villagesId:
         util.goToVillageBuiding(self.browser, villageId, '32')
         util.waitUntil(self.browser, 5, 'build_logo')
         time.sleep(1)
         if (self.isSubmitTroop(villageId)):
             return villageId
     self.create()
Exemple #4
0
def upgradeToMaxLevel(browser, villageId, buildingId):
    while (True):
        try:
            util.goToVillageBuiding(browser, villageId, buildingId)
            util.waitUntil(browser, 5, 'build_logo')
            buildUnit(browser)
        except:
            buildingName = browser.find_element_by_class_name('titleInHeader')
            print('### ' + str(buildingName.text) +
                  ' have been upgraded. ####')
            break
Exemple #5
0
 def upgradeToMaxLevel(self, villageId, buildingId):
     while (True):
         try:
             util.goToVillageBuiding(self.browser, villageId, buildingId)
             util.waitUntil(self.browser, 5, 'build_logo')
             self.upgradeUnit()
         except:
             buildingName = self.browser.find_element_by_class_name(
                 'titleInHeader')
             print('<< Build >> ' + str(buildingName.text) +
                   ' reach to max level. ####')
             break
Exemple #6
0
 def isBroken(self, villageId):
     self.browser.get(SERVER + "/dorf2.php?newdid=" + str(villageId))
     util.waitUntil(self.browser, 5, 'village2')
     time.sleep(2)
     try:
         city = self.browser.find_elements_by_xpath(
             "//div[contains(@class, 'max')]")
         print("<< Building Dorf2 >> VillageId: " + str(villageId) +
               " city: " + str(len(city)))
         if (len(city) >= 18):
             return False
         return True
     except:
         return True
Exemple #7
0
 def isBroken(self, villageId):
     self.browser.get(SERVER + "/dorf1.php?newdid=" + str(villageId))
     util.waitUntil(self.browser, 5, 'village1')
     time.sleep(1)
     try:
         farm = self.browser.find_elements_by_xpath(
             "//div[contains(@class, 'max')]")
         print("<< Dorf1 Building >> VillageId: " + str(villageId) +
               " farm: " + str(len(farm)))
         if (len(farm) >= 18):
             return False
         return True
     except:
         return True
def imperatoris(browser):
    util.goToBuildingId(browser, '29')
    Imperatoris = 0
    for village in villages:
        trainingAmount = maximizeTroop(browser, village)
        submitTroop(browser, trainingAmount, 'Equites Imperatoris')
        print('### Imperatoris training ' +
              util.getShortenedInteger(int(trainingAmount)) + ' ##')

        Imperatoris += int(trainingAmount)
        time.sleep(2)
        util.waitUntil(browser, 5, 'build_logo')

    util.sleep()
    return Imperatoris
def praetorian(browser):
    util.goToBuildingId(browser, '30')
    Praetorian = 0
    for village in villages:
        trainingAmount = maximizeTroop(browser, village)
        submitTroop(browser, trainingAmount, 'Praetorian')
        print('### Praetorian training ' +
              util.getShortenedInteger(int(trainingAmount)) + ' ##')

        Praetorian += int(trainingAmount)
        time.sleep(2)
        util.waitUntil(browser, 5, 'build_logo')

    util.sleep()
    return Praetorian
Exemple #10
0
def login(isHeadless):
  config = readConfig()
  print('## Connect to ' + config['SERVER'] + ' ##')
  options = Options()
  options.headless = isHeadless
  options.add_argument('disable-dev-shm-usage')
  browser = webdriver.Chrome(executable_path='Lib/chromedriver', chrome_options=options)
  browser.get(config['SERVER'])

  usernameInput = browser.find_element_by_name('user')
  passwordInput = browser.find_element_by_name('pw')

  usernameInput.send_keys(config['USERNAME'])
  passwordInput.send_keys(config['PASSWORD'])

  submitButton = browser.find_element_by_name('s2')
  print('## Login... ##')
  submitButton.click()
  waitUntil(browser, 5, 'villageBuildings')
  print(' ## Login Successfully ##')
  return browser
Exemple #11
0
 def goToFoundNewVillage(self, villageId, newVillageId):
     config = util.readConfig()
     self.browser.get(config["SERVER"] + "/a2b.php?newdid=" +
                      str(villageId) + "&id=" + str(newVillageId) + "&s=1")
     util.waitUntil(self.browser, 5, 'troopstipo')
Exemple #12
0
 def goToDorf1(self, villageId):
     config = util.readConfig()
     self.browser.get(config["SERVER"] + '/dorf1.php?newdid=' +
                      str(villageId))
     util.waitUntil(self.browser, 5, 'contentContainer')
def maximizeTroop(browser, village):
    util.goToVillage(browser, village)
    util.waitUntil(browser, 5, 'build_logo')
    maximumOfTraining = browser.find_elements_by_xpath("//a")[30]
    trainingAmount = maximumOfTraining.text
    return trainingAmount