class ScreenAndMouseIoManager(): ASK_AOI = Rectangle(-1, -1, -1, -1) PURCHASE_BUTTON = [-1, -1] TRADER_AOI = Rectangle(-1, -1, -1, -1) def get_asks(self): return [Ask(-1, -1, -1, -1)] def get_fee(self): return -1 def get_trader(self): return Trader(-1, -1) def did_buy_succeed(self): return PurchaseResult.FAILURE def buy_lowest_ask(self): Robot.move_relative(*self.PURCHASE_BUTTON) Robot.click() Robot.type('y') result = PurchaseResult.UNKNOWN while result == PurchaseResult.UNKNOWN: result = self.did_buy_succeed() Robot.long_sleep(0.5) return result def sell_first_item(self, price): # TODO use Robot to sell pass def wait(self, seconds=2): Robot.long_sleep(seconds)
''' Positions and sizes of various objects within the screenshot ''' # Sizes for an iPhone 6S+ (1242x2208px screen) from common import Rectangle, Point ScreenWidth = 1242 # Height of various objects in the image StatusBarHeight = 0 ErrorMsgHeight = 163 MeterBounds = Rectangle(118, 285, 1006, 503) MeterBallRadius = 10 # slight underestimate CPBounds = Rectangle(364, 121, 480, 126) HPBounds = Rectangle(314, 1162, 618, 62) DustBounds = Rectangle(686, 1756, 172, 77) CandyNameBounds = Rectangle(580, 1616, 598, 47) EvolveButtonPixel = Point(373, 1897) EvolveCandyBounds = Rectangle(933, 1945, 74, 48) TypeBounds = Rectangle(53, 1293, 390, 85)
def capture(): return capture(Rectangle(0, 0, 1920, 1080))