Skip to content

Commit

Permalink
First batch of fixes
Browse files Browse the repository at this point in the history
- The shortcuts doesn't trigger if there's only one role anymore.
- Champion.GG doesn't return empty position names when the champion name is weird, e.g Kha'Zix or Vel'Koz
- You can no longer choose a position if its runes are empty.
- Incremented version
  • Loading branch information
Ryzzzen committed Aug 9, 2018
1 parent 6768a42 commit c597605
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
16 changes: 11 additions & 5 deletions objects/ChampionSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,19 @@ class ChampionSelect extends EventEmitter {
ipcRenderer.removeAllListeners('runes-previous');
ipcRenderer.removeAllListeners('runes-next');

console.dir(res);

for (let position in res) {
if (res[position].runes.length === 0)
if (res[position].runes.length === 0) {
UI.error(`Couldn't get runes for ${champion.name}, position: ${position}`);
delete res[position];
}
else $('#positions').append(`<option value="${position}">${position === 'ADC' ? 'ADC' : position.charAt(0).toUpperCase() + position.slice(1) }</option>`)
}

$('#positions').change(async function() {
let data = res[this.value];

console.log(this.value);
console.dir(data);

$('button#loadRunes, button#loadSummonerSpells').disableManualButton();

/*
Expand Down Expand Up @@ -156,13 +157,15 @@ class ChampionSelect extends EventEmitter {
console.log('Shortcut: Previous Runes');

const keys = Object.keys(res);

let i = keys.length, positionIndex = keys.indexOf($('#positions').val());
let newIndex = positionIndex;

if (newIndex === 0) newIndex = i - 1;
else newIndex--;

// Useless to reload runes again if it's the same runes..
if (newIndex === positionIndex) return;

$('#positions').val(keys[newIndex]).trigger('change');
});

Expand All @@ -176,6 +179,9 @@ class ChampionSelect extends EventEmitter {
if (newIndex === i - 1) newIndex = 0;
else newIndex++;

// Useless to reload runes again if it's the same runes..
if (newIndex === positionIndex) return;

$('#positions').val(keys[newIndex]).trigger('change');
});

Expand Down
12 changes: 7 additions & 5 deletions objects/providers/ChampionGG.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ class ChampionGGProvider {
}

async getData(champion, preferredPosition, gameMode) {
console.log(`${this.base}champion/${champion.key}${preferredPosition ? '/' + preferredPosition.toLowerCase() : ''}`);

const res = await rp(`${this.base}champion/${champion.key}${preferredPosition ? '/' + preferredPosition.toLowerCase() : ''}`);
const data = this._scrape(res, champion.key, gameMode);

let positions = {};

positions[data.position] = data;

console.dir(data);
console.dir(positions);

for (const position of data.availablePositions) {
console.dir(position);
console.log('ChampionGG - Downloading data for position ' + position.position);
Expand Down Expand Up @@ -72,10 +74,10 @@ class ChampionGGProvider {
*/
champion = $('.champion-profile > h1').text();

const position = $(`li[class^='selected-role'] a[href^='/champion/${champion}']`).first().text().trim();
const position = $(`li[class^='selected-role'] > a[href^='/champion/']`).first().text().trim();
let availablePositions = [];

$(`li[class!='selected-role'] a[href^='/champion/${champion}']`).each(function(index) {
$(`li[class!='selected-role'] > a[href^='/champion/']`).each(function(index) {
availablePositions.push({ position: $(this).first().text().trim().toUpperCase(), link: 'https://champion.gg' + $(this).attr('href') });
});

Expand Down Expand Up @@ -113,7 +115,7 @@ class ChampionGGProvider {
* ItemSets
*/

let itemset = new ItemSet(champion, position).setTitle(`CGG ${$('.champion-profile h1').text()} - ${position}`);
let itemset = new ItemSet(champion, position).setTitle(`CGG ${champion} - ${position}`);
$('.build-wrapper').each(function(index) {
const type = $(this).parent().find('h2').eq(index % 2).text();
let block = new Block().setName(type + ` (${$(this).find('div > strong').text().trim().slice(0, 6)} WR)`);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "manaflux",
"version": "1.4.0",
"version": "1.4.1",
"description": "League of Legends automatic runes downloader",
"main": "main.js",
"scripts": {
Expand Down

0 comments on commit c597605

Please sign in to comment.