#pragma once
#include "Jass.h"
#include "Game_structures.h"

integer fBeginGameProcess();
void fGame();
void fEndGame();

HumanPlayer * fGetHumanePlayer(HTIMER vTimer);
VampirePlayer * fGetVampirePlayer(HTIMER vTimer);

//void fActionsUnits(HPLAYERCOLOR vNPlayer, ParamPlayer *pParamPlayer);

//void fActionsHuman(HumanPlayer *pHumanPlayer);

unsigned short fGoToAction(unsigned short vIdDataUnit, integer vInt, unsigned short vAction);
bool fIsEnoughResourses(HPLAYER vPlayer, integer vId);

bool fIsEnoughResourses(HPLAYER vPlayer, ParamPlayer *pParamPlayer, integer vNResearch, integer *vId);
void fEndGame2(Pointer *p);

void fKillUnitsBots();
void fKillUnitsOfPlayer();

void fActionItemsGold();

bool fIsXYToRect(real vX, real vY, HRECT vRect);
bool fUnitToRect(DataUnit *pDataUnit, HRECT vRect);

real fXCenter(integer vId, unsigned int vIntIn);
real fYCenter(integer vId, unsigned int vIntIn);

real fXCenter(integer vId, unsigned short vX2);
real fYCenter(integer vId, unsigned short vY2);

integer fBeginGameProcessAI(integer vNPlayerAI);

sPlayerUser * fGetPlayerUser(HTRIGGER hTrigger);
void fActionPlayerLeave();

bool fBuyAUnit(unsigned short vShop, integer vIdUnit, sInventory *vInventory);
bool fBuyItem(unsigned short vShop, integer vIdItem, sInventory *vInventory);

bool fTransferRes(HPLAYER vPlayerFrom, HPLAYER vPlayerToWhom, HPLAYERSTATE vRes, integer vCost);

unsigned short fTrainActionResearch(ParamPlayer *pParamPlayer, DataUnit *pDataUnit, integer vNResearch);

unsigned short fTrainAction(HPLAYER vPlayer, ActionStackForUnits * pActionStackForUnits, unsigned short vComment, integer vIdDataUnitTrain, unsigned short vCount);

void fRefreshLastCoordinates(DataUnit *pDataUnit);

bool fSync(DataUnit *pDataUnit);
bool fCheckSync(DataUnit *pDataUnit);
bool fFreeSync(DataUnit *pDataUnit);

bool fGetLastCoordinates(DataUnit *pDataUnit);

bool fCompliteBuild(DataUnit *pDataUnit, float vTime);

unsigned short fNBaseUnit(DataUnit *pDataUnit);

bool fCompliteResearch(DataUnit *pDataUnit, float vTime);

bool fCheckLeavePlayers();

void fPreActionsGame();

DWORD WINAPI ThreadResultGame(void *p);

void fPreBeginGameProcess();

void fTimerMain();