diff --git a/TypeScript/13AddTrader/src/mod.ts b/TypeScript/13AddTrader/src/mod.ts index 37e2c55..71d643a 100644 --- a/TypeScript/13AddTrader/src/mod.ts +++ b/TypeScript/13AddTrader/src/mod.ts @@ -42,6 +42,8 @@ class SampleTrader implements IPreAkiLoadMod, IPostDBLoadMod { this.logger.debug(`[${this.mod}] Delayed Loading... `); const databaseServer: DatabaseServer = container.resolve("DatabaseServer"); + const configServer: ConfigServer = container.resolve("ConfigServer"); + const traderConfig: ITraderConfig = configServer.getConfig(ConfigTypes.TRADER); const jsonUtil = container.resolve("JsonUtil"); // Keep a reference to the tables @@ -51,11 +53,14 @@ class SampleTrader implements IPreAkiLoadMod, IPostDBLoadMod { tables.traders[baseJson._id] = { assort: this.createAssortTable(), base: jsonUtil.deserialize(jsonUtil.serialize(baseJson)) as ITraderBase, - questassort: undefined + questassort: {} // Empty object as trader has no assorts unlocked by quests }; this.addTraderToLocales(tables, baseJson.name, "Cat", baseJson.nickname, baseJson.location, "This is the cat shop"); + // Add item purchase threshold value (what % durability does trader stop buying items at) + traderConfig.durabilityPurchaseThreshhold[baseJson._id] = 60; + this.logger.debug(`[${this.mod}] Delayed Loaded`); } @@ -142,6 +147,17 @@ class SampleTrader implements IPreAkiLoadMod, IPostDBLoadMod { locale[`${baseJson._id} Description`] = description; } } + + private addItemToLocales(tables: IDatabaseTables, itemTpl: string, name: string, shortName: string, Description: string) + { + // For each language, add locale for the new trader + const locales = Object.values(tables.locales.global) as Record[]; + for (const locale of locales) { + locale[`${itemTpl} Name`] = name; + locale[`${itemTpl} ShortName`] = shortName; + locale[`${itemTpl} Description`] = Description; + } + } } module.exports = { mod: new SampleTrader() } \ No newline at end of file