import adb_bindings
import adb_bindings.adb
from adb_bindings.grid import Grid
from datetime import datetime, timedelta
from adb_bindings.randomize import random_sleep_between_second, random_sleep_between_millisecond, random_between

adb: adb_bindings.adb.Adb = adb_bindings.list_devices()[0]

inventory = Grid(1916, 462, 2254, 975, 7, 4)

def press_rock_cake():
    adb.tap_center_of_grid_cell(inventory, 7, 1)

start = datetime.now()

while datetime.now() < (start + timedelta(hours=4)):
    press_rock_cake()
    random_sleep_between_millisecond(1000, 1300)
    press_rock_cake()
    random_sleep_between_millisecond(1000, 1300)
    press_rock_cake()
    row = random_between(1, 6)
    column = random_between(1, 4)
    print(f"{row} {column}")
    random_sleep_between_millisecond(1000, 1300)
    adb.tap_center_of_grid_cell(inventory, row, column)

    random_sleep_between_second(110, 130)