Skip to content

Commit

Permalink
Update and fix vendors
Browse files Browse the repository at this point in the history
Update and fix vendors
  • Loading branch information
romaniac01 committed Oct 28, 2023
1 parent 56ede3a commit 4f07b22
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 21 deletions.
17 changes: 11 additions & 6 deletions db/advisors/build.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { merge } from "lodash"

import { API, downloadIcon } from "../download"
import { Advisor } from "../interfaces"
import { Advisor, Vendor } from "../interfaces"
import { translateEn, convertCivilization } from "../shared/convert-text"
import { findVendors } from "../vendors"

Expand Down Expand Up @@ -39,18 +39,23 @@ export async function buildAdvisors(): Promise<Advisor[]> {
level: advisor.minlevel,
civilization,
rarities,
vendors: undefined,
vendors: [],
search: "",
marketplace: [],
lootTable: convertLootTable(advisor)
}

result.vendors = await findVendors(rarity.id);
(result.vendors || []).forEach(vendor => {
const vendorData = await findVendors(rarity.id);
(vendorData || []).forEach(vendor => {
vendor.rarity = advisor.rarity
})

const merged = merge(mergedByName[name], result)

for (let i=0; i<vendorData.length;i++) {
merged.vendors.push(vendorData[i])
}

merged.search = await buildSearchString(advisor, merged)

merged.marketplace = Object.keys(merged.rarities).reduce((queries, key) => {
Expand All @@ -60,7 +65,7 @@ export async function buildAdvisors(): Promise<Advisor[]> {
})
return queries
}, [] as typeof result.marketplace)

mergedByName[name] = merged
}

Expand Down
12 changes: 9 additions & 3 deletions db/consumables/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export async function buildConsumables(): Promise<Consumable[]> {
const result: Consumable = {
id: rarity.id,
name,
vendors: undefined,
vendors: [],
rarities,
civilization,
search: "",
Expand All @@ -94,9 +94,9 @@ export async function buildConsumables(): Promise<Consumable[]> {
}


result.vendors = await findVendors(result.id);
const vendorData = await findVendors(result.id);

(result.vendors || []).forEach(vendor => {
(vendorData || []).forEach(vendor => {
if (consumable.rarity === "cRarityLegendary") {
vendor.rarity = "legendary"
}
Expand All @@ -117,6 +117,12 @@ export async function buildConsumables(): Promise<Consumable[]> {


const merged = merge(mergedByName[name], result)

for (let i=0; i<vendorData.length;i++) {
merged.vendors.push(vendorData[i])
}


merged.search = await buildSearchString(merged,consumable)


Expand Down
2 changes: 1 addition & 1 deletion db/interfaces/Advisor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface Advisor {
age: number
level: number
civilization: string | undefined
vendors: Vendor[] | undefined
vendors: Vendor[]
rarities: {
[index: string]: AdvisorRarity,
}
Expand Down
2 changes: 1 addition & 1 deletion db/interfaces/Consumable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface Consumable {
[index: string]: ConsumableRarity,
}
civilization: string | undefined
vendors: Vendor[] | undefined
vendors: Vendor[]
search: string
marketplace: MarketplaceQuery[],
event?: {
Expand Down
1 change: 1 addition & 0 deletions db/items/legendary-rotation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export function addToLegendaryRotation(item: Item, trait: Trait): void {
rotation,
price,
blueprint: undefined,
quantity: 0
})
item.vendors.sort(compareVendors)
}
4 changes: 2 additions & 2 deletions db/vendors/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const romanAdvisorCheatFilter = [
* Searches all vendors and collects the ones that sell the
* specified item.
*/
export async function findVendors(id: string): Promise<Vendor[] | undefined> {
export async function findVendors(id: string): Promise<Vendor[]> {
const results: Vendor[] = []

const vendors = await API.getVendors()
Expand Down Expand Up @@ -95,5 +95,5 @@ export async function findVendors(id: string): Promise<Vendor[] | undefined> {
})
unique.sort(compareVendors)

return unique.length ? unique : undefined
return unique
}
2 changes: 1 addition & 1 deletion src/app/interfaces/Advisor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface Advisor {
age: number
level: number
civilization: string | undefined
vendors: Vendor[] | undefined
vendors: Vendor[]
rarities: {
[index: string]: AdvisorRarity,
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/interfaces/Consumable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface Consumable {
[index: string]: ConsumableRarity,
}
civilization: string | undefined
vendors: Vendor[] | undefined
vendors: Vendor[]
search: string
marketplace: MarketplaceQuery[],
event?: {
Expand Down
2 changes: 1 addition & 1 deletion src/assets/db/advisors.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/assets/db/blueprints.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/assets/db/consumables.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/assets/db/designs.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/assets/db/items.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/assets/db/materials.json

Large diffs are not rendered by default.

0 comments on commit 4f07b22

Please sign in to comment.