import uinterface, rgb, time, default_icons, urequests, appconfig

base = "https://api.runelite.net/runelite-1.7.19/loottracker?count=300&start=0"
settings = appconfig.get('vyrewatch_loot_tracker', {'uuid': 'EDIT THIS'});
#Edit this on https://webserial.curious.supplies/#/settings
#You can find your UUID in your %userprofile%/.runelite/session file

rgb.setfont(rgb.FONT_6x3)

uuid = settings['uuid']
if(uuid == "EDIT THIS"):
  rgb.clear()
  rgb.text("noConfig",(255,255,255),(0,2))
else: 
  rgb.clear()
  uinterface.connect_wifi()
  data, size, frames = default_icons.animation_loading
  rgb.gif(data, (13, 1), size, frames)

  while True:
    rgb.clear()
    rgb.text("Loading..", (255,255,255),(0,0))
    uinterface.connect_wifi()
    request = urequests.get(url=base,  headers={"runelite-auth":uuid})
    lootjson = request.json();

    for monster in lootjson:
      if(monster['eventId']=='Vyrewatch Sentinel'):
        kc = monster['amount']
        for drop in monster['drops']:
          if(drop['id']==24777):
            shards = drop['qty']
            break;
      break;
    del lootjson
    del request

    for i in range(0, 10):
      rgb.clear()
      rgb.text("KC", (0,128,0),(0,3))
      rgb.text(str(kc), (0,255,0),(rgb.textwidth("KC"),3))
      time.sleep(2)

      rgb.clear()
      rgb.text("Shards", (255,100,100),(0,3))
      rgb.text(str(shards)[:7], (255,0,0),(rgb.textwidth("Shards"),3))
      time.sleep(2)