import json
import sys
from pathlib import Path

import cv2

repo = Path.home() / 'TibiaPilotNG'
sys.path.insert(0, str(repo))

from src.repositories.radar.core import getCoordinate, getFloorLevel


profiles = json.loads((repo / 'file.json').read_text(encoding='utf-8-sig'))
waypoints = profiles['_default']['1']['config']['ng_cave']['waypoints']['items']
screenshot = cv2.imread(str(repo / '.obs-tibia.png'), cv2.IMREAD_GRAYSCALE)
print(json.dumps({
    'floor': getFloorLevel(screenshot),
    'coordinate': getCoordinate(screenshot, waypoints=waypoints),
}))
