lolautoaccept/include/clientapi.h

170 lines
3.7 KiB
C++

#pragma once
#include "clientaccess.h"
#include "restclient.h"
class ClientAPI : public RestClient {
public:
enum class ReadyCheckState : uint32_t {
INVALID = 0,
NONE,
INPROGRESS,
Accepted,
DECLINED
};
static ReadyCheckState toReadyCheckState(const QJsonObject& json);
enum class GameflowPhase : uint32_t {
NONE = 0,
LOBBY,
MATCHMAKING,
CHECKEDINTOTOURNAMENT,
READYCHECK,
CHAMPSELECT,
GAMESTART,
FAILEDTOLAUNCH,
INPROGRESS,
RECONNECT,
WAITINGFORSTATS,
PREENDOFGAME,
ENDOFGAME,
TERMINATEDINERROR,
};
static GameflowPhase toGameflowPhase(const std::string&);
enum class ChampSelectPhase : uint32_t {
INVALID = 0,
PLANNING,
BAN_PICK,
FINALIZATION
};
static ChampSelectPhase toChampSelectPhase(const std::string& str);
enum class Position : uint32_t {
INVALID = 0,
TOP,
MIDDLE,
BOTTOM,
JUNGLE,
UTILITY
};
static Position toPosition(const std::string& str);
enum class ChampSelectActionType : uint32_t {
INVALID = 0,
BAN,
PICK,
TEN_BANS_REVEAL,
};
static ChampSelectActionType toChampSelectActionType(const std::string& str);
struct TimerInfo {
int64_t adjustedTimeLeftInPhase;
int64_t internalNowInEpochMs;
bool isefinite;
ChampSelectPhase phase;
int64_t totalTimeInPhase;
bool valid = false;
TimerInfo();
explicit TimerInfo(const QJsonObject& json);
};
struct PlayerInfo {
int64_t summonerid = 0; // to test validity -> test if this is not null
std::string gameName;
std::string name;
std::string statusMessage;
// lol specific
std::string puuid;
uint32_t level = 0;
};
struct ChampSelectAction {
int32_t actorCellID = -1;
int32_t championID = 0;
int32_t id = 0;
bool completed = false;
bool isAllyAction = true;
bool isInProgress = false;
ChampSelectActionType type = ChampSelectActionType::INVALID;
ChampSelectAction();
explicit ChampSelectAction(const QJsonObject& json);
};
struct ChampSelectCell {
Position position;
int32_t cellID = 0;
int32_t championID = 0;
int32_t championPickIntentID = 0;
int64_t summonerID = 0;
ChampSelectCell();
explicit ChampSelectCell(const QJsonObject& json);
};
static std::vector<ChampSelectCell> loadAllInfos(const QJsonArray& arr);
struct ChampSelectSession {
std::vector<ChampSelectAction> actions;
int32_t counter = 0; // ??
int64_t gameid = 0;
bool allowDuplicatePick = false;
bool allowRerolling = false;
bool allowSkinSelection = true;
bool hasSimultaneousBans = true;
bool hasSimultaneousPicks = false;
bool isCustomGame = false;
bool isSpectating = false;
bool skipChampionSelect = false;
int32_t rerollsRemaining = 0;
int32_t localPlayerCellId = 0;
std::vector<ChampSelectCell> myTeam;
std::vector<ChampSelectCell> theirTeam;
TimerInfo timer;
// std::vector<> trades; // TODO
ChampSelectSession();
explicit ChampSelectSession(const QJsonObject& json);
operator bool();
};
ClientAPI(const ClientAccess& access);
~ClientAPI();
ReadyCheckState getReadyCheckState();
GameflowPhase getGameflowPhase();
void acceptMatch();
void declineMatch();
ChampSelectSession getChampSelectSession();
bool setChampSelectAction(int32_t actionid, int32_t champid, bool completed);
PlayerInfo getSelf();
std::vector<std::string> getLog();
std::vector<int32_t> getBannableChampIDs();
std::vector<int32_t> getPickableChampIDs();
TimerInfo getTimerInfo();
protected:
private:
ClientAccess access;
};
std::ostream& operator<<(std::ostream&, const ClientAPI::ReadyCheckState&);
std::ostream& operator<<(std::ostream&, const ClientAPI::GameflowPhase&);
std::ostream& operator<<(std::ostream&, const ClientAPI::ChampSelectPhase&);
std::ostream& operator<<(std::ostream&, const ClientAPI::Position&);
std::ostream& operator<<(std::ostream&, const ClientAPI::ChampSelectActionType&);