import { reactive } from 'vue'

export const gameData = reactive({
    health: 50,
    maxHealth: 100,
    armor: 50,
    breath: 0,
    weapon: 0,
    ammo: 0,
    maxammo: 0,
    wanted: 0,
    money: 0,
    speed: 0.0,
    username: 'CEF_STUDIO'
});

export type GameData = typeof gameData;

declare const cef: any;

export function sendEvent(e: string, ...a: any[]) {
    console.log("send client event:", e, ...a);

    if (typeof cef !== 'undefined') cef.emit(e, ...a);
};

export function setCursor(s: boolean) {
    console.log("set cursor:", s);

    if (typeof cef !== 'undefined') cef.set_cursor(s);
};

export function setGameData(data: Partial<GameData>) {
    Object.assign(gameData, data);
};