Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/loot additions #67

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/connector/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ XWehWA==
}

export function readLockfile(): string {
// TODO: OSX & Linux
const re = process.platform === 'win32' ? /"--install-directory=(.*?)"/ : /--install-directory=(.*?)( --|\n|$)/;
const cmd = process.platform === 'win32' ? 'WMIC PROCESS WHERE name=\'LeagueClientUx.exe\' GET CommandLine' : 'ps x -o args | grep \'LeagueClientUx\'';

Expand Down
3 changes: 2 additions & 1 deletion src/electron/enums/loot-item-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ export enum LootItemStatus {
NONE = 'NONE',
FREE = 'FREE',
RENTAL = 'RENTAL',
OWNED = 'OWNED'
OWNED = 'OWNED',
ALREADY_OWNED = 'ALREADY_OWNED'
}
68 changes: 47 additions & 21 deletions src/electron/modules/disenchant-loot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ export class DisenchantLootModule extends Module {
click: async() => this.disenchantChampionShards()
}));

submenu.append(new MenuItem({
label: 'Open Chests',
click: async() => this.openChests()
}));

submenu.append(new MenuItem({
label: 'Eternals Set Shards',
click: async() => this.disenchantEternalShards()
Expand Down Expand Up @@ -53,6 +58,25 @@ export class DisenchantLootModule extends Module {
return this.updateMenu(menuItem);
}

private async openChests(): Promise<void> {
const allLoot = await this.getLoot();
const chestLoot = Object.entries(allLoot).filter(([lootKey]) => {
return lootKey == 'CHEST_champion_mastery';
});
const keyLoot = Object.entries(allLoot).filter(([lootKey]) => {
return lootKey == 'MATERIAL_key';
});
if (chestLoot.length < 1) {
await this.showInsufficientResourcesDialogue('Open Chest', 'Chests');
} else if (keyLoot.length < 1) {
await this.showInsufficientResourcesDialogue('Open Chest', 'Keys');
} else {
const disenchantResponse = await connection.forgeLoot('CHEST_champion_mastery_OPEN', ['CHEST_champion_mastery', 'MATERIAL_key'], chestLoot.length);
console.log(disenchantResponse);
return disenchantResponse.json();
}
}

private async disenchantKeyFragments(): Promise<void> {
const keyFragmentsPerKey = 3;
const allLoot = await this.getLoot();
Expand Down Expand Up @@ -81,7 +105,24 @@ export class DisenchantLootModule extends Module {
}

private async disenchantChampionCapsules(): Promise<void> {
return this.disenchantChests('CHEST_128_OPEN', LootCategories.CHAMPION_CAPSULE, LootTypes.LOOT_ID);
const recipeName = 'CHEST_128_OPEN';
const lootCategoryFilter = LootCategories.CHAMPION_CAPSULE;
const lootType = LootTypes.LOOT_ID;
const prettyCategory = 'Chest(s)';
const allLoot = await this.getLoot();

const filteredLoot = Object.values(allLoot).filter((lootItem) => {
return lootItem[lootType] === lootCategoryFilter;
});

if (filteredLoot.length > 0) {
const chestCount = filteredLoot[0]['count'];
const disenchantResponse = await connection.forgeLoot(recipeName, [lootCategoryFilter], chestCount);
console.log(disenchantResponse);
return disenchantResponse.json();
} else {
await this.showNoResourcesDialogue(prettyCategory);
}
}

private async disenchantChampionShards(): Promise<void> {
Expand All @@ -97,35 +138,20 @@ export class DisenchantLootModule extends Module {
}

private async disenchantEternalShards(): Promise<void> {
return this.disenchantShards(LootCategories.ETERNALS, LootTypes.DISPLAY_CATEGORIES);
// TODO: Needs custom logic due to Eternals having unique keys
// STATSTONE_SHARD_66600016 (type:STATSTONE_SHARD)
// Recipe: STATSTONE_SHARD_DISENCHANT, STATSTONE_SHARD_UPGRADE
// "redeemableStatus": "ALREADY_OWNED",
// return this.disenchantShards(LootCategories.ETERNALS, LootTypes.DISPLAY_CATEGORIES);
}

private async disenchantIconShards(): Promise<void> {
return this.disenchantShards(LootCategories.SUMMONER_ICON, LootTypes.DISPLAY_CATEGORIES);
}

private async disenchantChests(recipeName: string, lootCategoryFilter: LootCategories, lootType: LootTypes): Promise<void> {
const prettyCategory = 'Chest(s)';
const allLoot = await this.getLoot();

const filteredLoot = Object.values(allLoot).filter((lootItem) => {
return lootItem[lootType] === lootCategoryFilter;
});

if (filteredLoot.length > 0) {
const chestCount = filteredLoot[0]['count'];
const disenchantResponse = await connection.forgeLoot(recipeName, [lootCategoryFilter], chestCount);
console.log(disenchantResponse);
return disenchantResponse.json();
} else {
await this.showNoResourcesDialogue(prettyCategory);
}
}

private async disenchantShards(lootCategoryFilter: LootCategories, lootType: LootTypes): Promise<void> {
const prettyCategory = lootCategoryFilter.toLowerCase().replace('_', ' ');
const allLoot = await this.getLoot();
// console.log(allLoot);

const allCategoryLoot = Object.values(allLoot).filter((lootItem) => {
return lootItem[lootType] === lootCategoryFilter;
Expand Down
2 changes: 1 addition & 1 deletion src/electron/subscriptions/eog-listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import { Endpoints } from '../enums';

export class EndOfGameSubscription extends Subscription {
path = Endpoints.END_OF_GAME_STATS;
eventType = EventType.CREATE; // TODO: Double check
eventType = EventType.CREATE;
}