#pragma once #include "clientaccess.h" #include "restclient.h" #include "position.h" #include "runeaspekt.h" #include "runepage.h" #include "runestyle.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, GAME_STARTING, PLANNING, BAN_PICK, FINALIZATION }; static ChampSelectPhase toChampSelectPhase(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 = 0; int64_t internalNowInEpochMs = 0; bool isefinite = false; ChampSelectPhase phase = ChampSelectPhase::INVALID; int64_t totalTimeInPhase = 0; 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 = Position::INVALID; int32_t cellID = 0; int32_t championID = 0; int32_t championPickIntentID = 0; int64_t summonerID = 0; int64_t spell1Id = 0; // 4 = flash, 6 = ghost, 7 = heal, 11 = smite, 12 = teleport, 13 = klarheitz, 14 = ignite, 32 = snowball int64_t spell2Id = 0; ChampSelectCell(); explicit ChampSelectCell(const QJsonObject& json); }; static std::vector loadAllInfos(const QJsonArray& arr); struct ChampSelectSession { std::vector 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 myTeam; std::vector theirTeam; TimerInfo timer; // std::vector<> trades; // TODO ChampSelectSession(); explicit ChampSelectSession(const QJsonObject& json); operator bool(); }; struct RunePage { uint64_t id = 0; uint64_t lastmodified = 0; std::string name; 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; RunePage(); explicit RunePage(const QJsonObject& json); }; struct Message { std::string body; std::string fromId; std::string fromPid; int64_t fromSummonerId; std::string id; bool isHistorical; std::string timestamp; std::string type; // known types: chat (1:1), customGame, championSelect, groupchat Message(); explicit Message(const QJsonObject& json); }; struct Conversation { std::string gameName; std::string gameTag; std::string id; bool isMuted; std::shared_ptr lastMessage; std::string name; std::string password; std::string pid; std::string targetRegion; std::string type; int64_t unreadMessageCount; Conversation(); explicit Conversation(const QJsonObject& json); }; 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 getBannableChampIDs(); std::vector getPickableChampIDs(); TimerInfo getTimerInfo(); // chats std::vector getAllConversations(); Message sendMessage(const std::string& chatid, const std::string& messagebody); // rune stuff RunePage getCurrentRunePage(); std::vector getAllRunePages(); bool selectRunePage(uint64_t id); bool editRunePage(const RunePage& page); bool createRunePage(const RunePage& page); bool deleteRunePage(uint64_t id); std::vector getAllRuneAspekts(); std::vector getAllRuneStyles(); const std::string& getRuneStyleByID(uint32_t id); 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::ChampSelectActionType&);