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

void fActionsHuman(HumanPlayer *pHumanPlayer);

bool fSetFlagUnit(IdDataUnit *pIdDataUnit,ParamPlayer *pParamPlayer);
HDESTRUCTABLE fNearestTree(DataUnit *pDataUnit,ParamPlayer *pParamPlayer);
void fWorkers(HumanPlayer *pHumanPlayer);

bool fBlinkToWall(HumanPlayer *pHumanPlayer);
bool fEscapeFromTheBase(HumanPlayer *pHumanPlayer);

unit fGetNearestUnit2(HGROUP g, DataUnit *pDataUnit);
integer fFilterBuildFirst();

unsigned short fFindNearestBase(HumanPlayer *pHumanPlayer, DataUnit *pDataUnit);
void fASignalForHelp(HumanPlayer *pHumanPlayer);

//bool fRepair(HumanPlayer *pHumanPlayer, IdDataUnit *vUnit, IdDataUnit *vUnit2);
bool fRepair(HumanPlayer *pHumanPlayer, DataUnit *pDataUnit, DataUnit *pDataUnit2);
bool fRepairUnitByUnit(HumanPlayer *pHumanPlayer, DataUnit *pDataUnit, DataUnit *pDataUnit2);
bool fComeToTheRescue(HumanPlayer *pHumanPlayer);

bool fUpgradeUnit(HumanPlayer *pHumanPlayer, unsigned short vComment, integer vId, integer vId2, bool vFlagRicochet, ActionStackForUnits *pActionStackForUnits);

bool fCancel_1(HumanPlayer *pHumanPlayer, unsigned short vCommentUnit);

bool fResurrectionOfSlayer(HumanPlayer *pHumanPlayer);
bool fInitSlayer(HumanPlayer *pHumanPlayer);

bool fSlayerGetGoldCoin(HumanPlayer *pHumanPlayer);
bool fJumpSlayerToManaWell(DataUnit * pDataUnit);

void fSkillSlayer(DataUnit *pDataUnit, integer vFlag);

bool fJumpSlayerToSlayerPlace(DataUnit * pDataUnit, HPLAYERCOLOR vAI);

bool fVampireToManaWell(player vPlayer);
bool fJumpSlayerToInt(DataUnit * pDataUnit, integer vInt);

void fActionsSlayer(HumanPlayer *pHumanPlayer);

bool fIntelligenceService(HumanPlayer *pHumanPlayer);

bool fSlayerToManaWell(player vPlayer);

bool fBuyGold(HumanPlayer *pHumanPlayer);

bool fAttackSlayer(HumanPlayer * pHumanPlayer, integer vId, integer vFlagEnemy2);

integer fAllWood(HumanPlayer *pHumanPlayer);

bool fGetAllWood(HumanPlayer *pHumanPlayer, unsigned short vCurrentEra);

bool fCheckRes(HumanPlayer *pHumanPlayer, integer vGold, integer vWood);

bool fDeto(HumanPlayer *pHumanPlayer, integer vId, unsigned short vQ, ActionStackForUnits *pActionStackForUnits);

unsigned short fBuildAction(HumanPlayer * pHumanPlayer, unsigned short vIdDataUnit, integer vInt, integer vIdDataUnitBuild);

void fGameHuman();

bool fJumpMainHumanToInt(DataUnit * pDataUnit, unsigned int vIntIn);

bool fAddDataUnitInRange(HumanPlayer *pHumanPlayer, DataUnit *pDataUnit);

bool fDetonateAll(HumanPlayer *pHumanPlayer, integer vId, ActionStackForUnits *pActionStackForUnits);

unsigned short fTrainActionCountUnits(HumanPlayer *pHumanPlayer, unsigned short vComment, integer vIdDataUnitBuild, integer vIdDataUnitTrain, unsigned short vCount, ActionStackForUnits *pActionStackForUnits);

unsigned short fTrainAction(HumanPlayer *pHumanPlayer, DataUnit *pDataUnit, integer vIdDataUnitTrain, unsigned short vCount);

bool fBuildANewOne(HumanPlayer *pHumanPlayer);

bool fWeCommentOnTheNew(HumanPlayer *pHumanPlayer, ActionStackForUnits *pActionStackForUnits);

bool fTowersAttack(HumanPlayer *pHumanPlayer, integer vId);

bool fBuildHealTower(HumanPlayer *pHumanPlayer);

unsigned short fTrainActionResearch(HumanPlayer *pHumanPlayer, DataUnit *pDataUnit, integer vNResearch);

unsigned short fAttackAction(HumanPlayer *pHumanPlayer, unsigned short vIdDataUnit, unsigned short vIdDataUnit2);

integer fFilterWorker();

void fAddAllDataUnitOfPlayerWorker(HPLAYER vPlayer);

void fActionsUnitsGoTo(HumanPlayer *pHumanPlayer);

//unsigned short fTrainActionResearch(HumanPlayer *pHumanPlayer, DataUnit *pDataUnit, integer vNResearch);

unsigned short fTrainAction(HumanPlayer *pHumanPlayer, unsigned short vComment, integer vIdDataUnitTrain, unsigned short vCount);

bool fManaBurnToUnit(HumanPlayer *pHumanPlayer, DataUnit *pDataUnit, DataUnit *pDataUnitTarget);

bool fInitSpellsUnitsByHuman(HumanPlayer *pHumanPlayer);

bool fAddActionInStackActions(HumanPlayer *pHumanPlayer, unsigned short vStage, bool vBoolCurrent, unsigned short vN);

void fMapRoutingActions(HumanPlayer *pHumanPlayer);

bool fSyncBegin(HumanPlayer *pHumanPlayer);

bool fDelChainInStackActions(HumanPlayer *pHumanPlayer, unsigned short vN);

bool vFreeCurrentActionInStackActions(HumanPlayer *pHumanPlayer);
bool vFreeCurrentActionInStackActions_2(HumanPlayer *pHumanPlayer);

bool fNewChain(HumanPlayer *pHumanPlayer, bool vBoolCurrentChain, unsigned short vN, unsigned short vStage, unsigned short vAction, unsigned short vComment,
	           integer vId, unsigned short vCommentUnit, unsigned short vNResearch, bool vMandatoryTrain, unsigned short vQTrain, char *vText);
unsigned short fFindFreeNChain(HumanPlayer *pHumanPlayer);
bool fDelChainByN(HumanPlayer *pHumanPlayer, unsigned short vN);

void fMapRoutingChains(HumanPlayer *pHumanPlayer);
bool fChainsEra0(HumanPlayer *pHumanPlayer);

bool fNewChainActionBuild(HumanPlayer *pHumanPlayer, bool vBoolCurrentChain, unsigned short vN, unsigned short vComment, integer vId, unsigned short vCommentUnit, char *vText);
bool fNewChainActionTrain(HumanPlayer *pHumanPlayer, bool vBoolCurrentChain, unsigned short vN, integer vId, unsigned short vQTrain, bool vMandatoryTrain, unsigned short vCommentUnit, char *vText);
bool fNewChainActionResearch(HumanPlayer *pHumanPlayer, bool vBoolCurrentChain, unsigned short vN, unsigned short vNResearch, unsigned short vCommentUnit, char *vText);
bool fNewChainActionUpgrade(HumanPlayer *pHumanPlayer, bool vBoolCurrentChain, unsigned short vN, integer vId, unsigned short vCommentUnit, char *vText);
bool fNewChainActionSetFlagToNearestTree(HumanPlayer *pHumanPlayer, bool vBoolCurrentChain, unsigned short vN, unsigned short vCommentUnit, char *vText);
bool fNewChainActionToWaitResearch(HumanPlayer *pHumanPlayer, bool vBoolCurrentChain, unsigned short vN, unsigned short vNResearch, char *vText);
bool fNewChainActionToWaitBuild(HumanPlayer *pHumanPlayer, bool vBoolCurrentChain, unsigned short vN, unsigned short vCommentUnit, char *vText);
bool fNewChainActionUniversal(HumanPlayer *pHumanPlayer, bool vBoolCurrentChain, unsigned short vN, unsigned short vStage, char *vText);
bool fNewChainAction(HumanPlayer *pHumanPlayer, bool vBoolCurrentChain, unsigned short vN, unsigned short vAction, char *vText);

bool fLoadCurrentChain(HumanPlayer *pHumanPlayer);
bool fFreeAllChains(HumanPlayer *pHumanPlayer);

unsigned short fFindFreeNInStackChains();

integer fAllGold(HumanPlayer *pHumanPlayer);
bool fGetAllGoldLimit2(HumanPlayer *pHumanPlayer);

bool fSaleGold(HumanPlayer *pHumanPlayer);
bool fCheckEra2All(HumanPlayer *pHumanPlayer);

bool fCheckTempleAndLumberHouse(HumanPlayer *pHumanPlayer);

bool fShiftChain(HumanPlayer *pHumanPlayer, unsigned short vChain);
bool fAddChain(HumanPlayer *pHumanPlayer, sStackChains* vChainAdding);

bool fGiveAwayGold(HumanPlayer *pHumanPlayer);

bool fPasteChain(HumanPlayer *pHumanPlayer, sStackChains *vPasteChain, unsigned short vChain);
sStackChains * fCutChain(HumanPlayer *pHumanPlayer, unsigned short vChain);
bool fShiftChainLastToN(HumanPlayer *pHumanPlayer, unsigned short vChain);

void fFurbolgs(HumanPlayer *pHumanPlayer);

bool fStackAttack(HumanPlayer *pHumanPlayer, ActionStackForUnits* vStackAttack, integer vId);

bool fVampiresNoToManaWell(player vPlayer);

bool fActionsHuman_Era0(HumanPlayer *pHumanPlayer);
void fOldStages(HumanPlayer *pHumanPlayer);
void fPreActionsHuman(HumanPlayer *pHumanPlayer);

bool fChainsEra0_New(HumanPlayer *pHumanPlayer);

unsigned short fFreeCommentUnit(HumanPlayer *pHumanPlayer);
bool fIsMassCommentUnit(HumanPlayer *pHumanPlayer, unsigned short vComment);
//bool fChains(HumanPlayer *pHumanPlayer);

bool fNCommentLast(HumanPlayer *pHumanPlayer);

bool fDelAllChainsPlayer(HumanPlayer *pHumanPlayer);

bool fAllChains(HumanPlayer *pHumanPlayer, unsigned short vN);
bool fChains(HumanPlayer *pHumanPlayer, int vBeginNChain);
//bool fChains(HumanPlayer *pHumanPlayer, unsigned short *vMass, unsigned short vQ);

sStackChains* fCopyChain(HumanPlayer *pHumanPlayer, sStackChains *vChain);
bool fSlayerAndVampire(HumanPlayer * pHumanPlayer);

bool fAddRegionClearZero(HumanPlayer * pHumanPlayer, unsigned short vIdDataUnit, real vX, real vY, real vRadius);
unsigned short fGetRegionClearZero(HumanPlayer * pHumanPlayer, unsigned short vIdDataUnit);
bool fDelRegionClearZero(HumanPlayer * pHumanPlayer, unsigned short vN);
bool fGoRegionClearZero(HumanPlayer * pHumanPlayer, unsigned short vIdDataUnit);

bool fNextChain(HumanPlayer *pHumanPlayer);
bool fFreeStackChain(sStackChains *vChain);
bool fNextChainInCurrentChain(HumanPlayer *pHumanPlayer);

bool fDelHumanPlayer(HumanPlayer *pHumanPlayer);

bool fCheckNChains(HumanPlayer *pHumanPlayer, unsigned short vN, bool vFlagFirst);

bool fNBaseCheckCreateMainWall(HumanPlayer *pHumanPlayer, unsigned short vNBase);

void fActionsTracker(HumanPlayer *pHumanPlayer);

bool fChainsEra1_New(HumanPlayer *pHumanPlayer);

void fChainDirections(HumanPlayer *pHumanPlayer);

void fChainsDefanse(HumanPlayer *pHumanPlayer);
void fChainsDevelopment(HumanPlayer *pHumanPlayer);
void fChainsAttack(HumanPlayer *pHumanPlayer);

bool fActionsHuman_Era1(HumanPlayer *pHumanPlayer);

void fWorkPlaces(HumanPlayer *pHumanPlayer);