forked from MrBesen/lolautoaccept
fix currentcounter in stage, show runes
This commit is contained in:
parent
d3379ab794
commit
d8e8e1c459
|
@ -12,6 +12,7 @@
|
||||||
class LolAutoAccept {
|
class LolAutoAccept {
|
||||||
public:
|
public:
|
||||||
using onposchange_func = std::function<void(Position)>;
|
using onposchange_func = std::function<void(Position)>;
|
||||||
|
using onruneschange_func = std::function<void(const std::vector<uint32_t>, uint32_t, uint32_t)>;
|
||||||
protected:
|
protected:
|
||||||
struct Stage {
|
struct Stage {
|
||||||
Stage();
|
Stage();
|
||||||
|
@ -29,6 +30,7 @@ protected:
|
||||||
Config::RootConfig& config;
|
Config::RootConfig& config;
|
||||||
DataDragon& dd;
|
DataDragon& dd;
|
||||||
onposchange_func onPoschange;
|
onposchange_func onPoschange;
|
||||||
|
onruneschange_func onRuneschange;
|
||||||
|
|
||||||
bool shouldrun = false;
|
bool shouldrun = false;
|
||||||
std::thread lolaathread;
|
std::thread lolaathread;
|
||||||
|
@ -45,7 +47,7 @@ public:
|
||||||
PICK = 2,
|
PICK = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
LolAutoAccept(Config::RootConfig& config, DataDragon& dd, onposchange_func = {});
|
LolAutoAccept(Config::RootConfig& config, DataDragon& dd, onposchange_func = {}, onruneschange_func = {});
|
||||||
~LolAutoAccept();
|
~LolAutoAccept();
|
||||||
|
|
||||||
void setChamps(const std::vector<uint32_t>& champs, State s);
|
void setChamps(const std::vector<uint32_t>& champs, State s);
|
||||||
|
|
|
@ -15,7 +15,7 @@ public:
|
||||||
~RuneDisplay();
|
~RuneDisplay();
|
||||||
|
|
||||||
void setRuneMeta(const std::vector<RuneAspekt>& runeinfo);
|
void setRuneMeta(const std::vector<RuneAspekt>& runeinfo);
|
||||||
void setRunes(std::vector<uint32_t> ids, uint32_t primary, uint32_t secondary);
|
void setRunes(const std::vector<uint32_t>& ids, uint32_t primary, uint32_t secondary);
|
||||||
private:
|
private:
|
||||||
void updateText();
|
void updateText();
|
||||||
std::string getRuneText(uint32_t id);
|
std::string getRuneText(uint32_t id);
|
||||||
|
|
|
@ -51,7 +51,7 @@ BlitzAPI::ChampionInfo::ChampionInfo(const QJsonObject& json) {
|
||||||
if(!it.isObject()) continue;
|
if(!it.isObject()) continue;
|
||||||
|
|
||||||
QJsonObject rune = it.toObject();
|
QJsonObject rune = it.toObject();
|
||||||
auto runeid = rune["runeid"];
|
auto runeid = rune["runeId"];
|
||||||
if(runeid.isDouble()) {
|
if(runeid.isDouble()) {
|
||||||
runes.push_back(runeid.toDouble());
|
runes.push_back(runeid.toDouble());
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
LolAutoAccept::Stage::Stage() {}
|
LolAutoAccept::Stage::Stage() {}
|
||||||
LolAutoAccept::Stage::~Stage() {}
|
LolAutoAccept::Stage::~Stage() {}
|
||||||
|
|
||||||
LolAutoAccept::LolAutoAccept(Config::RootConfig& config, DataDragon& dd, onposchange_func onposch) : config(config), dd(dd), onPoschange(onposch) {
|
LolAutoAccept::LolAutoAccept(Config::RootConfig& config, DataDragon& dd, onposchange_func onposch, onruneschange_func onrunch) : config(config), dd(dd), onPoschange(onposch), onRuneschange(onrunch) {
|
||||||
std::lock_guard lock(stagesMutex);
|
std::lock_guard lock(stagesMutex);
|
||||||
stages.resize(3); // accept, ban, pick
|
stages.resize(3); // accept, ban, pick
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,8 @@ void LolAutoAccept::setChamps(const std::vector<uint32_t>& champs, State s) {
|
||||||
Log::warn << "setChamps() called on invalid State";
|
Log::warn << "setChamps() called on invalid State";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Log::debug << "LolAutoAccept::setChamps";
|
||||||
|
|
||||||
{
|
{
|
||||||
std::lock_guard lock(stagesMutex);
|
std::lock_guard lock(stagesMutex);
|
||||||
stages.at((int) s).champids = champs;
|
stages.at((int) s).champids = champs;
|
||||||
|
@ -174,7 +176,7 @@ void LolAutoAccept::loadPosition(Position pos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t LolAutoAccept::getChampOfState(State s) {
|
uint32_t LolAutoAccept::getChampOfState(State s) {
|
||||||
assert(((int) s) >= 0 && s <= State::PICK);
|
assert(s > State::LOBBY && s <= State::PICK);
|
||||||
|
|
||||||
Stage& stage = stages[(int) s];
|
Stage& stage = stages[(int) s];
|
||||||
uint32_t size = stage.champids.size();
|
uint32_t size = stage.champids.size();
|
||||||
|
@ -191,7 +193,7 @@ uint32_t LolAutoAccept::getChampOfState(State s) {
|
||||||
void LolAutoAccept::nextChampOfState(State s) {
|
void LolAutoAccept::nextChampOfState(State s) {
|
||||||
assert(s > State::LOBBY && s <= State::PICK);
|
assert(s > State::LOBBY && s <= State::PICK);
|
||||||
|
|
||||||
auto stage = stages[(int) s];
|
Stage& stage = stages[(int) s];
|
||||||
uint32_t size = stage.champids.size();
|
uint32_t size = stage.champids.size();
|
||||||
|
|
||||||
stage.currentOffset++;
|
stage.currentOffset++;
|
||||||
|
@ -286,9 +288,12 @@ void LolAutoAccept::champSelect() {
|
||||||
|
|
||||||
// find own cellid info
|
// find own cellid info
|
||||||
const ClientAPI::ChampSelectCell* me = nullptr;
|
const ClientAPI::ChampSelectCell* me = nullptr;
|
||||||
|
uint32_t pickedChamp = 0;
|
||||||
|
static uint32_t lastPickedChamp = 0;
|
||||||
for(const auto& it : session.myTeam) {
|
for(const auto& it : session.myTeam) {
|
||||||
if(it.cellID == cellid) {
|
if(it.cellID == cellid) {
|
||||||
me = ⁢
|
me = ⁢
|
||||||
|
pickedChamp = it.championID;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -298,6 +303,20 @@ void LolAutoAccept::champSelect() {
|
||||||
pos = Position::UTILITY; // default: support TODO: make the default changeable? extra tab?
|
pos = Position::UTILITY; // default: support TODO: make the default changeable? extra tab?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// check if runes need adjustment
|
||||||
|
if(pickedChamp != lastPickedChamp) {
|
||||||
|
Log::info << "picked champ changed from: " << lastPickedChamp << " to: " << pickedChamp;
|
||||||
|
lastPickedChamp = pickedChamp;
|
||||||
|
|
||||||
|
// update runes
|
||||||
|
if(onRuneschange) {
|
||||||
|
auto champinfo = blitzapi.getChampionInfo(pickedChamp, pos); // TODO: add detection for enemy champ
|
||||||
|
Log::info << "champinfo aquired: " << champinfo.runes.size() << " runes primary: " << champinfo.primaryRune;
|
||||||
|
onRuneschange(champinfo.runes, champinfo.primaryRune, 0); //
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// reload config based on position if changed
|
// reload config based on position if changed
|
||||||
if(pos != currentPosition) {
|
if(pos != currentPosition) {
|
||||||
Log::note << "LolAutoAccept reloading config for position: " << pos << " because it was: " << currentPosition;
|
Log::note << "LolAutoAccept reloading config for position: " << pos << " because it was: " << currentPosition;
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
|
|
||||||
#include <Log.h>
|
#include <Log.h>
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), dd(QLocale().name().toStdString()), lolaa(conf.getConfig(), dd, std::bind(&MainWindow::onPosChange, this, std::placeholders::_1)) {
|
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), dd(QLocale().name().toStdString()),
|
||||||
|
lolaa(conf.getConfig(), dd, std::bind(&MainWindow::onPosChange, this, std::placeholders::_1), std::bind(&MainWindow::onRuneChanged, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
conf.load();
|
conf.load();
|
||||||
|
|
|
@ -15,7 +15,7 @@ void RuneDisplay::setRuneMeta(const std::vector<RuneAspekt>& ri) {
|
||||||
runeinfo = ri;
|
runeinfo = ri;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RuneDisplay::setRunes(std::vector<uint32_t> ids, uint32_t primary, uint32_t secondary) {
|
void RuneDisplay::setRunes(const std::vector<uint32_t>& ids, uint32_t primary, uint32_t secondary) {
|
||||||
runes = ids;
|
runes = ids;
|
||||||
this->primary = primary;
|
this->primary = primary;
|
||||||
this->secondary = secondary;
|
this->secondary = secondary;
|
||||||
|
@ -26,10 +26,10 @@ void RuneDisplay::setRunes(std::vector<uint32_t> ids, uint32_t primary, uint32_t
|
||||||
void RuneDisplay::updateText() {
|
void RuneDisplay::updateText() {
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
|
|
||||||
out << "primary: " << getRuneText(primary) << " secondary: " << getRuneText(secondary) << " ";
|
out << "primary: " << getRuneText(primary) << " secondary: " << getRuneText(secondary) << '\n';
|
||||||
|
|
||||||
for(uint32_t rune : runes) {
|
for(uint32_t rune : runes) {
|
||||||
out << getRuneText(rune);
|
out << getRuneText(rune) << '\n';
|
||||||
}
|
}
|
||||||
ui->runetext->setText(QString::fromStdString(out.str()));
|
ui->runetext->setText(QString::fromStdString(out.str()));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user