def refresh(self): try: elem = self.get_element() self.val = to_float(re.findall("\s(\S*)", elem.text)[0]) self.avail = "CanAfford" in elem.get_attribute("class") except: pass
def __init__(self, name="", val=0, avail=False, trimps=None): self.val = to_float(val) self.avail = avail self.active = False self.name = name self.driver = trimps.driver self.trimps = trimps self.irrelevant = False
def refresh(self): for key, res in self.items(): try: if key not in ("Trimps", "Workspaces"): #'Food\n893Qa / 16.2Qi\n1 Hour 50 Mins\nGather\n+2.31Qa/sec' val = self.driver.find_element_by_id(key.lower()).text res.val = to_float( re.match("{}\n(\S*)".format(key), val).group(1)) res.max_val = to_float(re.findall(" / (\S*)", val)[0]) elif key == "Trimps": res.val = to_float( self.driver.find_element_by_id("trimpsOwned").text) res.max_val = to_float( self.driver.find_element_by_id("trimpsMax").text) else: val = self.driver.find_element_by_id( "jobsTitleUnemployed").text res.val = to_float(re.findall("(\S*)", val)[0]) except: pass
def __init__(self, name="", val=0, avail=False, base_importance=0, driver=None): self.val = to_float(val) self.avail = avail self.base_importance = base_importance self.importance = base_importance self.name = name self.driver = driver
def __init__(self, val=0, name="", avail=False, base_importance=0, trimps=None): self.val = to_float(val) self.avail = avail self.base_importance = base_importance self.importance = base_importance self.trimps = trimps self.driver = trimps.driver self.name = name
def refresh(self, deep=False): try: elem = self.get_element() #"!Trap\n0" self.val = to_float(re.findall("\s(\S*)", elem.text)[0]) self.avail = "CanAfford" in elem.get_attribute("class") if deep: hover = ActionChains(self.driver).move_to_element(elem) hover.perform() #'... \ngems: 395Qa (12.4%), wood: 989Qa (46.8%), metal: 494Qa (3.50%)' self.tip = self.driver.find_element_by_id("tooltipDiv").text except: pass
def create_map(self): try: fragments = self.trimps.resources["Fragments"].val cost = to_float( self.driver.find_element_by_id("mapCostFragmentCost").text) if cost <= fragments: self.driver.find_element_by_id("mapCreateBtn").click() else: elem = self.driver.find_element_by_id("lootAdvMapsRange") self.driver.execute_script("arguments[0].value = arguments[1]", elem, "0") self.driver.find_element_by_id("mapCreateBtn").click() except: print("World.create_app exception")
def refresh(self, deep=False): try: elem = self.get_element() #"!Trap\n0" self.val = to_float(re.findall("\s(\S*)", elem.text)[0]) self.avail = "CanAfford" in elem.get_attribute("class") if deep: # can be hours and time if unavail. if self.hover is None: self.hover = self.trimps.webactions.move_to_element(elem) self.hover.perform() #'... \ngems: 395Qa (12.4%)' tip = self.driver.find_element_by_id("tooltipDiv").text self.trimps.webactions.reset_actions() self.cost = float(re.findall("\((\S*)%\)", tip)[0]) / 100 except: pass
from selenium import webdriver from modules.util import to_float from modules.trimps import Trimps import time # TESTING NUMBERS print("[1] Testing Number class ... ") assert to_float(0) == 0 assert to_float('1Oc') == 1e+27 #ffprofile = webdriver.FirefoxProfile("/home/artem/.mozilla/firefox/j68w7tb2.default") ffprofile = webdriver.FirefoxProfile( "/home/artem/.mozilla/firefox/j4s2hhud.test") driver = webdriver.Firefox(firefox_profile=ffprofile) driver.get("https://trimps.github.io/indexKong.html") time.sleep(2) trimps = Trimps(driver) #trimps.refresh() #TESTING RESOURCES print("[2] Testing Resource class ...") #assert game.resources['Food'] > 0 trimps.loop() #driver.close() print("Ehehei!")
def __init__(self, val=0, max_val=0): self.val = to_float(val) self.max_val = to_float(max_val)