#pragma once #include #include #include #include "blitzapi.h" #include "clientapi.h" #include "config.h" #include "datadragon.h" #include "runepage.h" #include "runestyle.h" class LolAutoAccept { public: using onposchange_func = std::function; using onruneschange_func = std::function; using onfailed_func = std::function; protected: struct Stage { Stage(); virtual ~Stage(); std::vector champids; // not every stage has a champ bool enabled = false; uint32_t currentOffset = 0; }; std::mutex stagesMutex; // protects stagesvector std::vector stages; Position currentPosition = Position::INVALID; bool currentPositionSet = false; uint32_t lastPickedChamp = 0; Config::RootConfig& config; DataDragon& dd; onposchange_func onPoschange; onruneschange_func onRuneschange; onfailed_func onFailed; bool shouldrun = false; std::thread lolaathread; std::shared_ptr clientapi; BlitzAPI blitzapi; std::vector runeaspekts; std::vector runestyles; bool nextApplyRunes = false; std::string chatid; // the chatid of the chat from the champselect std::chrono::time_point lastMessageSent; public: enum class State { LOBBY = 0, BAN = 1, PICK = 2, }; LolAutoAccept(Config::RootConfig& config, DataDragon& dd, onfailed_func = {}, onposchange_func = {}, onruneschange_func = {}); ~LolAutoAccept(); void setChamps(const std::vector& champs, State s); void setEnabled(bool b, State s); bool init(); // returns true on success void run(); void stop(); void reload(); // reload the config, when something was changed const std::vector& getRuneAspekts(); const std::vector& getRuneStyles(); void applyRunes(); void setOnRuneChangeFunc(onruneschange_func on); private: void stopJoinThread(); void innerRun(); void resetAllOffsets(); void resetRunes(); // when there is no option to push runes, make sure there is an update to trigger that, there are no runes showed void applyConfigToStage(Stage& stage, const Config::StageConfig& stageconf); void loadPosition(Position pos); uint32_t getChampOfState(State s); void nextChampOfState(State s); static bool isChampIntentofTeammate(uint32_t champid, const ClientAPI::ChampSelectSession& session); static bool isChampBanned(uint32_t champid, const ClientAPI::ChampSelectSession& session); using ownactions_t = std::vector; ownactions_t getOwnActions(int32_t cellid, const std::vector actions); void prepickPhase(const ownactions_t& ownactions); void banPhase(const ownactions_t& ownactions, const ClientAPI::ChampSelectSession& session); void pickPhase(const ownactions_t& ownactions); void phase(const ownactions_t& ownactions, ClientAPI::ChampSelectActionType type, State s, bool complete, std::function filter = {}); static int32_t getBestRunePage(const std::vector& allpages); static int32_t getMatchingRunePage(const RunePage& rp, const std::vector& allpages); void champSelect(); void smiteWarning(const std::vector& cells); const std::string& getChatid(); void applyRunes_internal(uint32_t champid, Position pos); };