lolautoaccept/include/clientapi.h

241 lines
5.5 KiB
C
Raw Normal View History

2022-06-27 20:45:01 +02:00
#pragma once
#include "clientaccess.h"
2023-05-01 22:36:11 +02:00
#include "datadragonimagecache.h"
#include "memoryimagecache.h"
2022-07-04 00:30:00 +02:00
#include "position.h"
2023-05-01 22:36:11 +02:00
#include "restclient.h"
2022-07-09 01:01:51 +02:00
#include "runeaspekt.h"
#include "runepage.h"
2022-07-10 15:56:09 +02:00
#include "runestyle.h"
2022-06-27 20:45:01 +02:00
class ClientAPI : public RestClient {
Q_OBJECT
2022-06-27 20:45:01 +02:00
public:
2022-06-29 23:09:01 +02:00
enum class ReadyCheckState : uint32_t {
2022-06-27 20:45:01 +02:00
INVALID = 0,
2022-06-29 23:09:01 +02:00
NONE,
INPROGRESS,
Accepted,
DECLINED
2022-07-02 12:36:38 +02:00
2022-06-27 20:45:01 +02:00
};
2022-07-02 12:36:38 +02:00
static ReadyCheckState toReadyCheckState(const QJsonObject& json);
2022-06-27 20:45:01 +02:00
2022-06-29 23:09:01 +02:00
enum class GameflowPhase : uint32_t {
NONE = 0,
LOBBY,
MATCHMAKING,
CHECKEDINTOTOURNAMENT,
READYCHECK,
CHAMPSELECT,
GAMESTART,
FAILEDTOLAUNCH,
INPROGRESS,
RECONNECT,
WAITINGFORSTATS,
PREENDOFGAME,
ENDOFGAME,
TERMINATEDINERROR,
};
2023-05-31 22:22:23 +02:00
static GameflowPhase toGameflowPhase(const QString&);
2022-06-29 23:09:01 +02:00
2022-07-01 00:13:38 +02:00
enum class ChampSelectPhase : uint32_t {
INVALID = 0,
GAME_STARTING,
2022-07-01 00:13:38 +02:00
PLANNING,
BAN_PICK,
FINALIZATION
};
2023-05-31 22:22:23 +02:00
static ChampSelectPhase toChampSelectPhase(const QString& str);
2022-07-01 00:13:38 +02:00
2022-07-02 12:36:38 +02:00
enum class ChampSelectActionType : uint32_t {
INVALID = 0,
BAN,
PICK,
TEN_BANS_REVEAL,
};
2023-05-31 22:22:23 +02:00
static ChampSelectActionType toChampSelectActionType(const QString& str);
2022-07-01 00:13:38 +02:00
2022-06-29 23:09:01 +02:00
struct TimerInfo {
2022-07-17 00:49:07 +02:00
int64_t adjustedTimeLeftInPhase = 0;
int64_t internalNowInEpochMs = 0;
bool isefinite = false;
ChampSelectPhase phase = ChampSelectPhase::INVALID;
int64_t totalTimeInPhase = 0;
2022-06-29 23:09:01 +02:00
bool valid = false;
2022-07-02 12:36:38 +02:00
TimerInfo();
explicit TimerInfo(const QJsonObject& json);
2022-06-29 23:09:01 +02:00
};
2022-06-27 20:45:01 +02:00
2022-07-01 00:13:38 +02:00
struct PlayerInfo {
int64_t summonerid = 0; // to test validity -> test if this is not null
2023-05-31 22:22:23 +02:00
QString gameName;
QString name;
QString statusMessage;
2022-07-01 00:13:38 +02:00
// lol specific
2023-05-31 22:22:23 +02:00
QString puuid;
2022-07-01 00:13:38 +02:00
uint32_t level = 0;
};
2022-07-02 12:36:38 +02:00
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 {
2022-07-17 00:49:07 +02:00
Position position = Position::INVALID;
2022-07-02 12:36:38 +02:00
int32_t cellID = 0;
int32_t championID = 0;
int32_t championPickIntentID = 0;
int64_t summonerID = 0;
2022-09-21 13:47:08 +02:00
int64_t spell1Id = 0; // 4 = flash, 6 = ghost, 7 = heal, 11 = smite, 12 = teleport, 13 = klarheitz, 14 = ignite, 32 = snowball
2022-08-26 02:12:25 +02:00
int64_t spell2Id = 0;
2022-07-02 12:36:38 +02:00
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();
};
2022-07-09 01:01:51 +02:00
struct RunePage {
uint64_t id = 0;
uint64_t lastmodified = 0;
2023-05-31 22:22:23 +02:00
QString name;
2022-07-09 01:01:51 +02:00
bool isDeleteable = true;
bool isEditable = true;
bool isActive = false; // what is the difference between active and current????
bool isCurrent = false;
bool isValid = true;
uint32_t order = 0; // position in the ui
::RunePage runepage;
2022-07-09 01:01:51 +02:00
RunePage();
explicit RunePage(const QJsonObject& json);
};
2022-08-26 02:12:25 +02:00
struct Message {
2023-05-31 22:22:23 +02:00
QString body;
QString fromId;
QString fromPid;
2022-08-26 02:12:25 +02:00
int64_t fromSummonerId;
2023-05-31 22:22:23 +02:00
QString id;
2022-08-26 02:12:25 +02:00
bool isHistorical;
2023-05-31 22:22:23 +02:00
QString timestamp;
QString type; // known types: chat (1:1), customGame, championSelect, groupchat
2022-08-26 02:12:25 +02:00
Message();
explicit Message(const QJsonObject& json);
};
struct Conversation {
2023-05-31 22:22:23 +02:00
QString gameName;
QString gameTag;
QString id;
2022-08-26 02:12:25 +02:00
bool isMuted;
std::shared_ptr<Message> lastMessage;
2023-05-31 22:22:23 +02:00
QString name;
QString password;
QString pid;
QString targetRegion;
QString type;
2022-08-26 02:12:25 +02:00
int64_t unreadMessageCount;
Conversation();
explicit Conversation(const QJsonObject& json);
};
2022-06-27 20:45:01 +02:00
ClientAPI(const ClientAccess& access);
~ClientAPI();
2022-06-29 23:09:01 +02:00
ReadyCheckState getReadyCheckState();
GameflowPhase getGameflowPhase();
2022-06-27 20:45:01 +02:00
void acceptMatch();
void declineMatch();
2022-07-02 12:36:38 +02:00
ChampSelectSession getChampSelectSession();
2022-07-02 13:21:09 +02:00
bool setChampSelectAction(int32_t actionid, int32_t champid, bool completed);
2022-07-01 00:13:38 +02:00
PlayerInfo getSelf();
2023-09-02 11:55:02 +02:00
void dodge();
2022-06-27 20:45:01 +02:00
2022-06-29 23:09:01 +02:00
std::vector<int32_t> getBannableChampIDs();
std::vector<int32_t> getPickableChampIDs();
TimerInfo getTimerInfo();
2022-08-26 02:12:25 +02:00
// chats
std::vector<Conversation> getAllConversations();
2023-05-31 22:22:23 +02:00
Message sendMessage(const QString& chatid, const QString& messagebody);
2022-08-26 02:12:25 +02:00
2022-07-09 01:01:51 +02:00
// rune stuff
RunePage getCurrentRunePage();
std::vector<RunePage> getAllRunePages();
bool selectRunePage(uint64_t id);
bool editRunePage(const RunePage& page);
2023-04-30 16:20:13 +02:00
bool createRunePage(const RunePage& page);
bool deleteRunePage(uint64_t id);
2022-07-09 01:01:51 +02:00
std::vector<RuneAspekt> getAllRuneAspekts();
2022-07-10 15:56:09 +02:00
std::vector<RuneStyle> getAllRuneStyles();
2022-07-09 01:01:51 +02:00
2023-05-31 22:22:23 +02:00
const QString& getRuneStyleByID(uint32_t id);
2022-06-27 20:45:01 +02:00
2023-05-01 22:36:11 +02:00
QPixmap getImageResource(QString path);
2022-06-27 20:45:01 +02:00
private:
ClientAccess access;
2023-05-01 22:36:11 +02:00
MemoryImageCache memImageCache;
DataDragonImageCache imageCache;
2022-06-27 20:45:01 +02:00
};
2022-06-29 23:09:01 +02:00
2023-05-31 22:22:23 +02:00
#define DEFINEOPERATOR(CLASS) \
std::ostream& operator<<(std::ostream&, const ClientAPI::CLASS&); \
QDebug operator<<(QDebug, const ClientAPI::CLASS&);
2023-09-02 12:01:41 +02:00
DEFINEOPERATOR(ReadyCheckState)
DEFINEOPERATOR(GameflowPhase)
DEFINEOPERATOR(ChampSelectPhase)
DEFINEOPERATOR(ChampSelectActionType)
2023-05-31 22:22:23 +02:00
#undef DEFINEOPERATOR