2022-03-06 01:00:19 +01:00
|
|
|
#pragma once
|
|
|
|
|
2022-04-21 00:47:57 +02:00
|
|
|
#include <thread>
|
2022-06-29 23:09:01 +02:00
|
|
|
#include <memory>
|
2022-07-04 00:30:00 +02:00
|
|
|
#include <mutex>
|
2022-06-29 23:09:01 +02:00
|
|
|
|
2022-07-09 01:01:51 +02:00
|
|
|
#include "blitzapi.h"
|
2022-06-29 23:09:01 +02:00
|
|
|
#include "clientapi.h"
|
2022-07-04 22:59:48 +02:00
|
|
|
#include "config.h"
|
|
|
|
#include "datadragon.h"
|
2022-07-10 14:32:44 +02:00
|
|
|
#include "runepage.h"
|
2022-07-10 15:56:09 +02:00
|
|
|
#include "runestyle.h"
|
2022-03-06 01:00:19 +01:00
|
|
|
|
|
|
|
class LolAutoAccept {
|
2022-07-04 22:59:48 +02:00
|
|
|
public:
|
|
|
|
using onposchange_func = std::function<void(Position)>;
|
2022-07-10 14:32:44 +02:00
|
|
|
using onruneschange_func = std::function<void(const RunePage&)>;
|
2022-07-29 00:05:22 +02:00
|
|
|
using onfailed_func = std::function<void()>;
|
2022-04-24 14:06:27 +02:00
|
|
|
protected:
|
|
|
|
struct Stage {
|
2022-06-29 23:09:01 +02:00
|
|
|
Stage();
|
2022-04-24 14:06:27 +02:00
|
|
|
virtual ~Stage();
|
|
|
|
|
2022-07-02 22:25:20 +02:00
|
|
|
std::vector<uint32_t> champids; // not every stage has a champ
|
2022-04-24 14:06:27 +02:00
|
|
|
bool enabled = false;
|
2022-07-03 00:31:13 +02:00
|
|
|
uint32_t currentOffset = 0;
|
2022-04-24 21:04:36 +02:00
|
|
|
};
|
|
|
|
|
2022-07-04 00:30:00 +02:00
|
|
|
std::mutex stagesMutex; // protects stagesvector
|
2022-07-04 22:59:48 +02:00
|
|
|
std::vector<Stage> stages;
|
|
|
|
Position currentPosition = Position::INVALID;
|
2022-07-17 00:21:15 +02:00
|
|
|
bool currentPositionSet = false;
|
2022-07-29 00:05:22 +02:00
|
|
|
uint32_t lastPickedChamp = 0;
|
2022-07-04 22:59:48 +02:00
|
|
|
|
|
|
|
Config::RootConfig& config;
|
|
|
|
DataDragon& dd;
|
|
|
|
onposchange_func onPoschange;
|
2022-07-09 16:23:09 +02:00
|
|
|
onruneschange_func onRuneschange;
|
2022-07-29 00:05:22 +02:00
|
|
|
onfailed_func onFailed;
|
2022-03-06 01:00:19 +01:00
|
|
|
|
2022-04-20 00:54:10 +02:00
|
|
|
bool shouldrun = false;
|
2022-04-21 00:47:57 +02:00
|
|
|
std::thread lolaathread;
|
2022-04-20 00:54:10 +02:00
|
|
|
|
2022-06-29 23:09:01 +02:00
|
|
|
std::shared_ptr<ClientAPI> clientapi;
|
|
|
|
|
2022-07-09 01:01:51 +02:00
|
|
|
BlitzAPI blitzapi;
|
|
|
|
std::vector<RuneAspekt> runeaspekts;
|
2022-07-10 15:56:09 +02:00
|
|
|
std::vector<RuneStyle> runestyles;
|
2022-07-09 01:01:51 +02:00
|
|
|
|
2022-07-10 01:51:42 +02:00
|
|
|
bool nextApplyRunes = false;
|
|
|
|
|
2022-08-26 02:12:25 +02:00
|
|
|
std::string chatid; // the chatid of the chat from the champselect
|
|
|
|
std::chrono::time_point<std::chrono::system_clock> lastMessageSent;
|
|
|
|
|
2022-03-06 01:00:19 +01:00
|
|
|
public:
|
2022-04-24 14:06:27 +02:00
|
|
|
enum class State {
|
|
|
|
LOBBY = 0,
|
2022-07-04 00:30:00 +02:00
|
|
|
BAN = 1,
|
|
|
|
PICK = 2,
|
2022-04-24 14:06:27 +02:00
|
|
|
};
|
|
|
|
|
2022-07-29 00:05:22 +02:00
|
|
|
LolAutoAccept(Config::RootConfig& config, DataDragon& dd, onfailed_func = {}, onposchange_func = {}, onruneschange_func = {});
|
2022-04-21 00:47:57 +02:00
|
|
|
~LolAutoAccept();
|
2022-03-06 01:00:19 +01:00
|
|
|
|
2022-07-03 00:31:13 +02:00
|
|
|
void setChamps(const std::vector<uint32_t>& champs, State s);
|
2022-04-24 14:06:27 +02:00
|
|
|
void setEnabled(bool b, State s);
|
2022-03-08 00:04:56 +01:00
|
|
|
|
2022-04-20 00:54:10 +02:00
|
|
|
bool init(); // returns true on success
|
2022-03-06 01:00:19 +01:00
|
|
|
void run();
|
2022-04-20 00:54:10 +02:00
|
|
|
void stop();
|
2022-04-21 00:47:57 +02:00
|
|
|
|
2022-07-04 22:59:48 +02:00
|
|
|
void reload(); // reload the config, when something was changed
|
|
|
|
|
2022-07-09 01:01:51 +02:00
|
|
|
const std::vector<RuneAspekt>& getRuneAspekts();
|
2022-07-10 15:56:09 +02:00
|
|
|
const std::vector<RuneStyle>& getRuneStyles();
|
2022-07-09 01:01:51 +02:00
|
|
|
void applyRunes();
|
2022-07-10 14:32:44 +02:00
|
|
|
void setOnRuneChangeFunc(onruneschange_func on);
|
2022-07-09 01:01:51 +02:00
|
|
|
|
2022-04-21 00:47:57 +02:00
|
|
|
private:
|
|
|
|
void stopJoinThread();
|
|
|
|
void innerRun();
|
2022-07-03 00:31:13 +02:00
|
|
|
void resetAllOffsets();
|
2022-07-10 15:19:25 +02:00
|
|
|
void resetRunes(); // when there is no option to push runes, make sure there is an update to trigger that, there are no runes showed
|
2022-07-04 22:59:48 +02:00
|
|
|
void applyConfigToStage(Stage& stage, const Config::StageConfig& stageconf);
|
|
|
|
void loadPosition(Position pos);
|
2022-07-03 00:31:13 +02:00
|
|
|
|
2022-07-03 12:01:51 +02:00
|
|
|
uint32_t getChampOfState(State s);
|
|
|
|
void nextChampOfState(State s);
|
2022-07-02 13:21:09 +02:00
|
|
|
|
2022-07-03 14:50:43 +02:00
|
|
|
static bool isChampIntentofTeammate(uint32_t champid, const ClientAPI::ChampSelectSession& session);
|
2022-07-04 22:59:48 +02:00
|
|
|
static bool isChampBanned(uint32_t champid, const ClientAPI::ChampSelectSession& session);
|
2022-07-03 14:50:43 +02:00
|
|
|
|
2022-07-02 13:21:09 +02:00
|
|
|
using ownactions_t = std::vector<ClientAPI::ChampSelectAction>;
|
|
|
|
ownactions_t getOwnActions(int32_t cellid, const std::vector<ClientAPI::ChampSelectAction> actions);
|
|
|
|
void prepickPhase(const ownactions_t& ownactions);
|
2022-07-03 14:50:43 +02:00
|
|
|
void banPhase(const ownactions_t& ownactions, const ClientAPI::ChampSelectSession& session);
|
2022-07-03 12:01:51 +02:00
|
|
|
void pickPhase(const ownactions_t& ownactions);
|
2022-07-03 14:50:43 +02:00
|
|
|
void phase(const ownactions_t& ownactions, ClientAPI::ChampSelectActionType type, State s, bool complete, std::function<bool(uint32_t)> filter = {});
|
2022-07-10 01:51:42 +02:00
|
|
|
static int32_t getBestRunePage(const std::vector<ClientAPI::RunePage>& allpages);
|
2022-07-10 14:32:44 +02:00
|
|
|
static int32_t getMatchingRunePage(const RunePage& rp, const std::vector<ClientAPI::RunePage>& allpages);
|
2022-07-02 13:21:09 +02:00
|
|
|
void champSelect();
|
2022-08-26 02:12:25 +02:00
|
|
|
void smiteWarning(const std::vector<ClientAPI::ChampSelectCell>& cells);
|
|
|
|
const std::string& getChatid();
|
2022-07-10 14:32:44 +02:00
|
|
|
void applyRunes_internal(uint32_t champid, Position pos);
|
2022-08-26 02:12:25 +02:00
|
|
|
};
|