update for AKI 3.2.5 SIV

This commit is contained in:
CWX 2022-11-09 19:30:56 +00:00
parent a2916c6233
commit ba22c1188b
10 changed files with 95 additions and 99 deletions

View File

@ -1,26 +0,0 @@
{
"name": "SeeItemValue",
"author": "KcY",
"version": "1.4.7",
"license": "NCSA Open Source",
"main": "src/mod.js",
"akiVersion": "3.2.4",
"UpdatedBy": "CWX",
"scripts": {
"setup:environment": "npm i",
"build:unzipped": "copyfiles -e \"./node_modules/**/*.*\" -e \"./dist/**/*.*\" -e \"./package-lock.json\" -e \"./tsconfig.json\" -e \"./README.txt\" -e \"./mod.code-workspace\" ./**/*.* ./dist",
"zip:files": "cd dist/ && bestzip ../mod.zip *",
"build:zip": "npm run clean:environment && npm run build:unzipped && npm run zip:files",
"clean:environment": "node -e \"require('fs').rm('mod.zip', ()=>{})\" && node -e \"require('fs').rmdir('./dist/',{recursive:true},()=>{})\""
},
"devDependencies": {
"@types/node": "^14.15.3",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"copyfiles": "2.4.1",
"eslint": "7.26.0",
"tsyringe": "4.6.0",
"typescript": "4.6.4",
"bestzip": "2.2.1"
}
}

View File

@ -0,0 +1,24 @@
{
"name": "SeeItemValue",
"author": "KcY",
"version": "1.4.8",
"license": "NCSA Open Source",
"main": "src/mod.js",
"akiVersion": "3.2.5",
"UpdatedBy": "CWX",
"scripts": {
"setup": "npm i",
"build": "node ./packageBuild.ts"
},
"devDependencies": {
"@types/node": "16.11.62",
"@typescript-eslint/eslint-plugin": "5.38.1",
"@typescript-eslint/parser": "5.38.1",
"bestzip": "2.2.1",
"eslint": "8.24.0",
"fs-extra": "10.1.0",
"glob": "8.0.3",
"tsyringe": "4.7.0",
"typescript": "4.8.4"
}
}

View File

@ -28,20 +28,20 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod
private skier: ITraderBase; private skier: ITraderBase;
private fence: ITraderBase; private fence: ITraderBase;
private tradersArr: ITraderBase[]; private tradersArr: ITraderBase[];
private cfg; private cfg: { TraderPrice: any; DebugMode: any; };
public preAkiLoad(container: DependencyContainer): void { public preAkiLoad(container: DependencyContainer): void
{
this.router = container.resolve<DynamicRouterModService>("DynamicRouterModService"); this.router = container.resolve<DynamicRouterModService>("DynamicRouterModService");
this.logger = container.resolve<ILogger>("WinstonLogger"); this.logger = container.resolve<ILogger>("WinstonLogger");
this.http = container.resolve<HttpResponseUtil>("HttpResponseUtil"); this.http = container.resolve<HttpResponseUtil>("HttpResponseUtil");
this.cfg = require("./config.json"); this.cfg = require("./config.json");
this.addRoute() this.addRoute()
} }
public postAkiLoad(container: DependencyContainer): void { public postAkiLoad(container: DependencyContainer): void
{
this.table = container.resolve<DatabaseServer>("DatabaseServer").getTables(); this.table = container.resolve<DatabaseServer>("DatabaseServer").getTables();
this.items = this.table.templates.items; this.items = this.table.templates.items;
this.livePrice = this.table.templates.prices; this.livePrice = this.table.templates.prices;
this.handbookTable = this.table.templates.handbook; this.handbookTable = this.table.templates.handbook;
@ -84,7 +84,7 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod
private getIdPrice(id: string): any private getIdPrice(id: string): any
{ {
let result = { const result = {
multiplier: 1, multiplier: 1,
price: 1, price: 1,
originalMax: 1, originalMax: 1,
@ -111,12 +111,12 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod
{ {
result.price = this.livePrice[id]; result.price = this.livePrice[id];
this.debugMode(`Config setting false for traders - returning livePrice AVG found`); this.debugMode("Config setting false for traders - returning livePrice AVG found");
return result; return result;
} }
else else
{ {
this.debugMode(`Config setting false for traders - unable to find livePrice - returning 1`); this.debugMode("Config setting false for traders - unable to find livePrice - returning 1");
return result; return result;
} }
} }
@ -125,7 +125,7 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod
if (this.cfg.TraderPrice) if (this.cfg.TraderPrice)
{ {
// search through all items in handbook // search through all items in handbook
let item = this.handbookTable.Items.find(x => x.Id === id); const item = this.handbookTable.Items.find(x => x.Id === id);
// if ID is found in handbook else returns default result object // if ID is found in handbook else returns default result object
if (item) if (item)
@ -159,7 +159,7 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod
{ {
result.multiplier = 1; result.multiplier = 1;
this.debugMode(`Unable to find ParentID in handbook for ID - ${id}`); this.debugMode(`Unable to find ParentID in handbook for ID - ${id}`);
this.debugMode(`Returning 1 for multiplier`); this.debugMode("Returning 1 for multiplier");
} }
// gets original max durability of resource type for item // gets original max durability of resource type for item
@ -170,7 +170,7 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod
} }
else else
{ {
this.debugMode(`No item found in handbook, returning default result`); this.debugMode("No item found in handbook, returning default result");
return result; return result;
} }
} }
@ -178,22 +178,22 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod
private getBestTraderMulti(parentId: string): any private getBestTraderMulti(parentId: string): any
{ {
let firstCat = this.handbookTable?.Categories?.find(x => x.Id === parentId); const firstCat = this.handbookTable?.Categories?.find(x => x.Id === parentId);
let secondCat = firstCat?.ParentId const secondCat = firstCat?.ParentId
let thirdCat = this.handbookTable?.Categories?.find(x => x.Id === secondCat)?.ParentId; const thirdCat = this.handbookTable?.Categories?.find(x => x.Id === secondCat)?.ParentId;
let result = {k1: 1, k2: "Unknown"}; const result = {k1: 1, k2: "Unknown"};
if (firstCat.Id || secondCat || thirdCat) if (firstCat.Id || secondCat || thirdCat)
{ {
for (let i in this.tradersArr) for (const i in this.tradersArr)
{ {
if (this.tradersArr[i]?.sell_category?.includes(firstCat.Id) || if (this.tradersArr[i]?.sell_category?.includes(firstCat.Id) ||
this.tradersArr[i]?.sell_category?.includes(secondCat) || this.tradersArr[i]?.sell_category?.includes(secondCat) ||
this.tradersArr[i]?.sell_category?.includes(thirdCat)) this.tradersArr[i]?.sell_category?.includes(thirdCat))
{ {
let multi = (100 - this.tradersArr[i]?.loyaltyLevels[0]?.buy_price_coef) / 100; const multi = (100 - this.tradersArr[i]?.loyaltyLevels[0]?.buy_price_coef) / 100;
let name = this.tradersArr[i]?.nickname; const name = this.tradersArr[i]?.nickname;
result.k1 = multi; result.k1 = multi;
result.k2 = name; result.k2 = name;
@ -210,7 +210,7 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod
} }
} }
private debugMode(text: string, color: string = `yellow`): void private debugMode(text: string, color = "yellow"): void
{ {
if (this.cfg.DebugMode) if (this.cfg.DebugMode)
{ {

View File

@ -1,26 +1,24 @@
{ {
"name": "SeeItemValue", "name": "SeeItemValue",
"author": "KcY", "author": "KcY",
"version": "1.4.6", "version": "1.4.8",
"license": "NCSA Open Source", "license": "NCSA Open Source",
"main": "src/mod.js", "main": "src/mod.js",
"akiVersion": "3.2.3", "akiVersion": "3.2.5",
"UpdatedBy": "CWX", "UpdatedBy": "CWX",
"scripts": { "scripts": {
"setup:environment": "npm i", "setup": "npm i",
"build:unzipped": "copyfiles -e \"./node_modules/**/*.*\" -e \"./dist/**/*.*\" -e \"./package-lock.json\" -e \"./tsconfig.json\" -e \"./README.txt\" -e \"./mod.code-workspace\" ./**/*.* ./dist", "build": "node ./packageBuild.ts"
"zip:files": "cd dist/ && bestzip ../mod.zip *",
"build:zip": "npm run clean:environment && npm run build:unzipped && npm run zip:files",
"clean:environment": "node -e \"require('fs').rm('mod.zip', ()=>{})\" && node -e \"require('fs').rmdir('./dist/',{recursive:true},()=>{})\""
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^14.15.3", "@types/node": "16.11.62",
"@typescript-eslint/eslint-plugin": "^4.33.0", "@typescript-eslint/eslint-plugin": "5.38.1",
"@typescript-eslint/parser": "^4.33.0", "@typescript-eslint/parser": "5.38.1",
"copyfiles": "2.4.1", "bestzip": "2.2.1",
"eslint": "7.26.0", "eslint": "8.24.0",
"tsyringe": "4.6.0", "fs-extra": "10.1.0",
"typescript": "4.6.4", "glob": "8.0.3",
"bestzip": "2.2.1" "tsyringe": "4.7.0",
"typescript": "4.8.4"
} }
} }

View File

@ -28,20 +28,20 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod
private skier: ITraderBase; private skier: ITraderBase;
private fence: ITraderBase; private fence: ITraderBase;
private tradersArr: ITraderBase[]; private tradersArr: ITraderBase[];
private cfg; private cfg: { TraderPrice: any; DebugMode: any; };
public preAkiLoad(container: DependencyContainer): void { public preAkiLoad(container: DependencyContainer): void
{
this.router = container.resolve<DynamicRouterModService>("DynamicRouterModService"); this.router = container.resolve<DynamicRouterModService>("DynamicRouterModService");
this.logger = container.resolve<ILogger>("WinstonLogger"); this.logger = container.resolve<ILogger>("WinstonLogger");
this.http = container.resolve<HttpResponseUtil>("HttpResponseUtil"); this.http = container.resolve<HttpResponseUtil>("HttpResponseUtil");
this.cfg = require("./config.json"); this.cfg = require("./config.json");
this.addRoute() this.addRoute()
} }
public postAkiLoad(container: DependencyContainer): void { public postAkiLoad(container: DependencyContainer): void
{
this.table = container.resolve<DatabaseServer>("DatabaseServer").getTables(); this.table = container.resolve<DatabaseServer>("DatabaseServer").getTables();
this.items = this.table.templates.items; this.items = this.table.templates.items;
this.livePrice = this.table.templates.prices; this.livePrice = this.table.templates.prices;
this.handbookTable = this.table.templates.handbook; this.handbookTable = this.table.templates.handbook;
@ -84,7 +84,7 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod
private getIdPrice(id: string): any private getIdPrice(id: string): any
{ {
let result = { const result = {
multiplier: 1, multiplier: 1,
price: 1, price: 1,
originalMax: 1, originalMax: 1,
@ -111,12 +111,12 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod
{ {
result.price = this.livePrice[id]; result.price = this.livePrice[id];
this.debugMode(`Config setting false for traders - returning livePrice AVG found`); this.debugMode("Config setting false for traders - returning livePrice AVG found");
return result; return result;
} }
else else
{ {
this.debugMode(`Config setting false for traders - unable to find livePrice - returning 1`); this.debugMode("Config setting false for traders - unable to find livePrice - returning 1");
return result; return result;
} }
} }
@ -125,7 +125,7 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod
if (this.cfg.TraderPrice) if (this.cfg.TraderPrice)
{ {
// search through all items in handbook // search through all items in handbook
let item = this.handbookTable.Items.find(x => x.Id === id); const item = this.handbookTable.Items.find(x => x.Id === id);
// if ID is found in handbook else returns default result object // if ID is found in handbook else returns default result object
if (item) if (item)
@ -159,7 +159,7 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod
{ {
result.multiplier = 1; result.multiplier = 1;
this.debugMode(`Unable to find ParentID in handbook for ID - ${id}`); this.debugMode(`Unable to find ParentID in handbook for ID - ${id}`);
this.debugMode(`Returning 1 for multiplier`); this.debugMode("Returning 1 for multiplier");
} }
// gets original max durability of resource type for item // gets original max durability of resource type for item
@ -170,7 +170,7 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod
} }
else else
{ {
this.debugMode(`No item found in handbook, returning default result`); this.debugMode("No item found in handbook, returning default result");
return result; return result;
} }
} }
@ -178,22 +178,22 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod
private getBestTraderMulti(parentId: string): any private getBestTraderMulti(parentId: string): any
{ {
let firstCat = this.handbookTable?.Categories?.find(x => x.Id === parentId); const firstCat = this.handbookTable?.Categories?.find(x => x.Id === parentId);
let secondCat = firstCat?.ParentId const secondCat = firstCat?.ParentId
let thirdCat = this.handbookTable?.Categories?.find(x => x.Id === secondCat)?.ParentId; const thirdCat = this.handbookTable?.Categories?.find(x => x.Id === secondCat)?.ParentId;
let result = {k1: 1, k2: "Unknown"}; const result = {k1: 1, k2: "Unknown"};
if (firstCat.Id || secondCat || thirdCat) if (firstCat.Id || secondCat || thirdCat)
{ {
for (let i in this.tradersArr) for (const i in this.tradersArr)
{ {
if (this.tradersArr[i]?.sell_category?.includes(firstCat.Id) || if (this.tradersArr[i]?.sell_category?.includes(firstCat.Id) ||
this.tradersArr[i]?.sell_category?.includes(secondCat) || this.tradersArr[i]?.sell_category?.includes(secondCat) ||
this.tradersArr[i]?.sell_category?.includes(thirdCat)) this.tradersArr[i]?.sell_category?.includes(thirdCat))
{ {
let multi = (100 - this.tradersArr[i]?.loyaltyLevels[0]?.buy_price_coef) / 100; const multi = (100 - this.tradersArr[i]?.loyaltyLevels[0]?.buy_price_coef) / 100;
let name = this.tradersArr[i]?.nickname; const name = this.tradersArr[i]?.nickname;
result.k1 = multi; result.k1 = multi;
result.k2 = name; result.k2 = name;
@ -210,7 +210,7 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod
} }
} }
private debugMode(text: string, color: string = `yellow`): void private debugMode(text: string, color = "yellow"): void
{ {
if (this.cfg.DebugMode) if (this.cfg.DebugMode)
{ {

View File

@ -1,7 +1,7 @@
{ {
"name": "SeeItemValue", "name": "SeeItemValue",
"author": "KcY", "author": "KcY",
"version": "1.4.6", "version": "1.4.8",
"license": "NCSA Open Source", "license": "NCSA Open Source",
"main": "src/mod.js", "main": "src/mod.js",
"akiVersion": "3.2.5", "akiVersion": "3.2.5",

View File

@ -28,20 +28,20 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod
private skier: ITraderBase; private skier: ITraderBase;
private fence: ITraderBase; private fence: ITraderBase;
private tradersArr: ITraderBase[]; private tradersArr: ITraderBase[];
private cfg; private cfg: { TraderPrice: any; DebugMode: any; };
public preAkiLoad(container: DependencyContainer): void { public preAkiLoad(container: DependencyContainer): void
{
this.router = container.resolve<DynamicRouterModService>("DynamicRouterModService"); this.router = container.resolve<DynamicRouterModService>("DynamicRouterModService");
this.logger = container.resolve<ILogger>("WinstonLogger"); this.logger = container.resolve<ILogger>("WinstonLogger");
this.http = container.resolve<HttpResponseUtil>("HttpResponseUtil"); this.http = container.resolve<HttpResponseUtil>("HttpResponseUtil");
this.cfg = require("./config.json"); this.cfg = require("./config.json");
this.addRoute() this.addRoute()
} }
public postAkiLoad(container: DependencyContainer): void { public postAkiLoad(container: DependencyContainer): void
{
this.table = container.resolve<DatabaseServer>("DatabaseServer").getTables(); this.table = container.resolve<DatabaseServer>("DatabaseServer").getTables();
this.items = this.table.templates.items; this.items = this.table.templates.items;
this.livePrice = this.table.templates.prices; this.livePrice = this.table.templates.prices;
this.handbookTable = this.table.templates.handbook; this.handbookTable = this.table.templates.handbook;
@ -84,7 +84,7 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod
private getIdPrice(id: string): any private getIdPrice(id: string): any
{ {
let result = { const result = {
multiplier: 1, multiplier: 1,
price: 1, price: 1,
originalMax: 1, originalMax: 1,
@ -111,12 +111,12 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod
{ {
result.price = this.livePrice[id]; result.price = this.livePrice[id];
this.debugMode(`Config setting false for traders - returning livePrice AVG found`); this.debugMode("Config setting false for traders - returning livePrice AVG found");
return result; return result;
} }
else else
{ {
this.debugMode(`Config setting false for traders - unable to find livePrice - returning 1`); this.debugMode("Config setting false for traders - unable to find livePrice - returning 1");
return result; return result;
} }
} }
@ -125,7 +125,7 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod
if (this.cfg.TraderPrice) if (this.cfg.TraderPrice)
{ {
// search through all items in handbook // search through all items in handbook
let item = this.handbookTable.Items.find(x => x.Id === id); const item = this.handbookTable.Items.find(x => x.Id === id);
// if ID is found in handbook else returns default result object // if ID is found in handbook else returns default result object
if (item) if (item)
@ -159,7 +159,7 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod
{ {
result.multiplier = 1; result.multiplier = 1;
this.debugMode(`Unable to find ParentID in handbook for ID - ${id}`); this.debugMode(`Unable to find ParentID in handbook for ID - ${id}`);
this.debugMode(`Returning 1 for multiplier`); this.debugMode("Returning 1 for multiplier");
} }
// gets original max durability of resource type for item // gets original max durability of resource type for item
@ -170,7 +170,7 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod
} }
else else
{ {
this.debugMode(`No item found in handbook, returning default result`); this.debugMode("No item found in handbook, returning default result");
return result; return result;
} }
} }
@ -178,22 +178,22 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod
private getBestTraderMulti(parentId: string): any private getBestTraderMulti(parentId: string): any
{ {
let firstCat = this.handbookTable?.Categories?.find(x => x.Id === parentId); const firstCat = this.handbookTable?.Categories?.find(x => x.Id === parentId);
let secondCat = firstCat?.ParentId const secondCat = firstCat?.ParentId
let thirdCat = this.handbookTable?.Categories?.find(x => x.Id === secondCat)?.ParentId; const thirdCat = this.handbookTable?.Categories?.find(x => x.Id === secondCat)?.ParentId;
let result = {k1: 1, k2: "Unknown"}; const result = {k1: 1, k2: "Unknown"};
if (firstCat.Id || secondCat || thirdCat) if (firstCat.Id || secondCat || thirdCat)
{ {
for (let i in this.tradersArr) for (const i in this.tradersArr)
{ {
if (this.tradersArr[i]?.sell_category?.includes(firstCat.Id) || if (this.tradersArr[i]?.sell_category?.includes(firstCat.Id) ||
this.tradersArr[i]?.sell_category?.includes(secondCat) || this.tradersArr[i]?.sell_category?.includes(secondCat) ||
this.tradersArr[i]?.sell_category?.includes(thirdCat)) this.tradersArr[i]?.sell_category?.includes(thirdCat))
{ {
let multi = (100 - this.tradersArr[i]?.loyaltyLevels[0]?.buy_price_coef) / 100; const multi = (100 - this.tradersArr[i]?.loyaltyLevels[0]?.buy_price_coef) / 100;
let name = this.tradersArr[i]?.nickname; const name = this.tradersArr[i]?.nickname;
result.k1 = multi; result.k1 = multi;
result.k2 = name; result.k2 = name;
@ -210,7 +210,7 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod
} }
} }
private debugMode(text: string, color: string = `yellow`): void private debugMode(text: string, color = "yellow"): void
{ {
if (this.cfg.DebugMode) if (this.cfg.DebugMode)
{ {