From dac0960e7bf65a77a9248d42d96d77d2fc5f96fc Mon Sep 17 00:00:00 2001 From: CWX Date: Mon, 19 Sep 2022 00:13:32 +0100 Subject: [PATCH] hopefully fixes latest issues with refactor, might have to look into caching all on game start --- .../bepInEx/plugins/KcY-SeeItemValue.dll | Bin 10240 -> 0 bytes .../bepInEx/plugins/KcY-SeeItemValue.dll | Bin 0 -> 13824 bytes .../mods/KcY-SeeItemValue 1.4.6}/LICENSE.txt | 0 .../mods/KcY-SeeItemValue 1.4.6}/package.json | 2 +- .../KcY-SeeItemValue 1.4.6}/src/config.json | 0 .../mods/KcY-SeeItemValue 1.4.6}/src/mod.ts | 30 ++++--- KcY-SeeItemValue/itemValue/itemGetter.cs | 15 ++-- KcY-SeeItemValue/itemValue/itemValueMod.cs | 80 +++++++++++++++--- .../itemValue/itemValueMod.csproj | 2 +- .../itemValue/server/dist/package.json | 2 +- .../itemValue/server/dist/src/mod.ts | 30 ++++--- .../itemValue/server/package.json | 2 +- KcY-SeeItemValue/itemValue/server/src/mod.ts | 30 ++++--- 13 files changed, 142 insertions(+), 51 deletions(-) delete mode 100644 KcY-SeeItemValue/itemValue/Built/KcY-SeeItemValue 1.4.4/bepInEx/plugins/KcY-SeeItemValue.dll create mode 100644 KcY-SeeItemValue/itemValue/Built/KcY-SeeItemValue 1.4.6/bepInEx/plugins/KcY-SeeItemValue.dll rename KcY-SeeItemValue/itemValue/Built/{KcY-SeeItemValue 1.4.4/user/mods/KcY-SeeItemValue 1.4.4 => KcY-SeeItemValue 1.4.6/user/mods/KcY-SeeItemValue 1.4.6}/LICENSE.txt (100%) rename KcY-SeeItemValue/itemValue/Built/{KcY-SeeItemValue 1.4.4/user/mods/KcY-SeeItemValue 1.4.4 => KcY-SeeItemValue 1.4.6/user/mods/KcY-SeeItemValue 1.4.6}/package.json (97%) rename KcY-SeeItemValue/itemValue/Built/{KcY-SeeItemValue 1.4.4/user/mods/KcY-SeeItemValue 1.4.4 => KcY-SeeItemValue 1.4.6/user/mods/KcY-SeeItemValue 1.4.6}/src/config.json (100%) rename KcY-SeeItemValue/itemValue/Built/{KcY-SeeItemValue 1.4.4/user/mods/KcY-SeeItemValue 1.4.4 => KcY-SeeItemValue 1.4.6/user/mods/KcY-SeeItemValue 1.4.6}/src/mod.ts (89%) diff --git a/KcY-SeeItemValue/itemValue/Built/KcY-SeeItemValue 1.4.4/bepInEx/plugins/KcY-SeeItemValue.dll b/KcY-SeeItemValue/itemValue/Built/KcY-SeeItemValue 1.4.4/bepInEx/plugins/KcY-SeeItemValue.dll deleted file mode 100644 index cfe2eaa1d96220a9467040a331db6fda3ed7f038..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10240 zcmeHNeQ;dWbwBs*?%UN$yWY1e$u<~!{RN99uVq{K1B}tPCH#pb8;nilC+S&!cz56O z-mWd7+7W3Wr2!@$N*d3U#*l#_ZAgI$B@mZ})&qeK2}ziyp$#8RGsV-=mPtK8rZN4U z``&&?vPt=)Gnr2B>YaDax#ygF?z!iF>|JfY`Ag&@B0rvwKPLJ%-dx%w{A4hN>gb~9 zqV%nrR~LUL%JIeDsa|&pl9T?QL3;tQ9RpNpMt`yW~2&nQp^F6qC5(`ppbajA#l3_*{H+;7%6h zzslPqnT7J|W}=;pv=L=E5HrgGqB`)-TuU@Kv+k4VBvGiUJ_NeAicS}d@dD`7A^_Bt z`U9+7l0*m6wquWgBYkTF!UMGgPgQAy_i5Y6SP*1i=>Q&%!R2_WN*hr}6)91{aYbR@ z6bjJkE8uq{k&xU^4-zeYIt?}GYvdsC;jpUQ24^n4hry%Dz18r*^8q0tb(GG z0KUAc_PmNdt4=-G#~NnU1k zl7bDjmgvpsQYy-Kuyp>f~q$s{IcGqW(vtF%|DZ^`BUgzI1!46QcaAgO{A&ZUxBC+&7rIND9UN1 z0Ka}OVL;qijN^^r{B*I1)LbMIwWUb--&`ugz(JcChM*NiKNEhq=wDItZ^IUwDSeqg>_2+$wTCKKuHPuXF8n{NzD~UR-t~o}k z%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/KcY-SeeItemValue/itemValue/Built/KcY-SeeItemValue 1.4.6/bepInEx/plugins/KcY-SeeItemValue.dll b/KcY-SeeItemValue/itemValue/Built/KcY-SeeItemValue 1.4.6/bepInEx/plugins/KcY-SeeItemValue.dll new file mode 100644 index 0000000000000000000000000000000000000000..83538d503439183bc1c780571e15a3d9fbea2067 GIT binary patch literal 13824 zcmeHN3v3+cah`wgZtp?fiF?O~B+JrKFViA*rrwq;%c965MLlVfdc_i`Be|s3y1PB? z-brK_8B_wRvE!t1ia1Gwq;?Xgc2c-W;KH%nAXeKL2ok4u9>}Y8tpr756n5jLNb97P z`^~?54<0FsX;2_2vgFRr%s>D9GxN{?xPSNHJ3dGrBJ$#X`)#5xWOeTwAxkO zmn1qMJk&7Ie6`rxtF$s+Bie});HVBaasbab?$fx5>Lji>b~D2jBYG4B_azLhI8mUYJOFxc1)a$26M4|}Z2%~f zzPfgUl2;s7B`n(-0VQoa4TL)ip{cxfqq`E8o;D%Kw$e0i*0mXT#kHGgPX#H_*Wo{3 zY@0$pnqCL>aU#LY|HZXjnL<_Xx|NFOqC~)eDGtL$TF@UMT1T;VFZ~tTfSg9Q24+ZA z&Ozv=hZsyn!7*bjTftQ?GJ8ejAp}9#^}yFulwMPV$OXFr?2C=F%0i{GCN8tkaPHz_ zM(XhZD%EvT-BDd;yNK;9AaYTlL>REPzm!IoPYQCmq< z*9ioSXbJ5Ypc+I~D8PG86JqW7Hi0LMul8+zkHWzl`Qv?MmGp;QpY0DaM2&f2pVzf- z5#8QXv~Lk52Oayk-+lz+d~BabMj;*Yn8-CXU1NO_aZ?}K2A^8cQK1%$G8I8aC%4uH z+7<_t(R#unECzawy3R>tjD<-r(~AbucK_X*RFKg?K`}4 zx_uGsISj)>)EZMYwXIoG%?(9^5;0I4i{yzD{2Z2IzG~&EhkG`r#kRkXhm{s^EcZ|MLjmjeVw4#&2j<})!Hshr(B3WB7x?12=T zTzAy&1U8LguZ?9UG>s|3yAB%!3}$D8AQ3QNox_j_7)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tdkEmc~(bFZfLJb)n$d zvbp;^Js$~w>$88^IQ@s@iIecgg$Vcnv<5~a61`K6dqgA>3Hg9bJ0R{GI}vOeMxbz==A+c zbov3-9F}G*^R)}Snqw<;MXiOd0OJOOjG{{791{f;)iN^agE`Z$1>;ckdPJLk6Tw}! zj7#wCjR*&Pz@{%P^7|vv>G$7^8;%7OoGC{9alv#1ViDKX`2L(3$F}U$X7yktC$6Wkz z;7@v5NWmS(9l#y&3M6AdxZjvA=a-s;O5-srl{;i+OTRkt106>&0&+Om$8``dlM;uL zgQYW)Huo3#op|rQEwK?wBK4(0_c(};mg>1yyi^jG(hYb8I_uzoLOA%A=Q%jsM!Opl zn-g0SSa_H(328T5gD*`5)sL8&1hgb7j~`~Kl{N8glDs~+{Krp_IM}Cv`T%b4e%$!z zu6VJl_$+|#%DzE;5u7RhX`_{Ry{rH>vF0b)_bZFa(G1k$!1#w}aPHR!>jL2$YyH1WMtPaUVX&h#_xR0O4xN=_SFbg=3)}vT+hXDD^U;w|_57Qygy@1`$SNHT4@4sGi z-c#|2 x.Id === parentId); - let secondCat = firstCat.ParentId - let thirdCat = this.handbookTable.Categories.find(x => x.Id === secondCat).ParentId; + let firstCat = this.handbookTable?.Categories?.find(x => x.Id === parentId); + let secondCat = firstCat?.ParentId + let thirdCat = this.handbookTable?.Categories?.find(x => x.Id === secondCat)?.ParentId; + + let result = {k1: 1, k2: "Unknown"}; if (firstCat.Id || secondCat || thirdCat) { for (let i in this.tradersArr) { - if (this.tradersArr[i].sell_category.includes(firstCat.Id) || - this.tradersArr[i].sell_category.includes(secondCat) || - this.tradersArr[i].sell_category.includes(thirdCat)) + if (this.tradersArr[i]?.sell_category?.includes(firstCat.Id) || + this.tradersArr[i]?.sell_category?.includes(secondCat) || + this.tradersArr[i]?.sell_category?.includes(thirdCat)) { - let multi = (100 - this.tradersArr[i].loyaltyLevels[0].buy_price_coef) / 100; - let name = this.tradersArr[i].nickname; + let multi = (100 - this.tradersArr[i]?.loyaltyLevels[0]?.buy_price_coef) / 100; + let name = this.tradersArr[i]?.nickname; - return {k1: multi, k2: name}; + result.k1 = multi; + result.k2 = name; + + return result; } } + + return result; } else { - return 1; + return result; } } diff --git a/KcY-SeeItemValue/itemValue/itemGetter.cs b/KcY-SeeItemValue/itemValue/itemGetter.cs index 0f1ae7d..d3b0aa6 100644 --- a/KcY-SeeItemValue/itemValue/itemGetter.cs +++ b/KcY-SeeItemValue/itemValue/itemGetter.cs @@ -1,7 +1,8 @@ -//namespace itemValueMod -//{ -// public struct itemGetter -// { -// public double sPrice { get; set; } -// } -//} +namespace itemValueMod +{ + public class ConfigClass + { + public bool TraderPrice { get; set; } + public bool DebugMode { get; set; } + } +} diff --git a/KcY-SeeItemValue/itemValue/itemValueMod.cs b/KcY-SeeItemValue/itemValue/itemValueMod.cs index 823ab92..d09c49f 100644 --- a/KcY-SeeItemValue/itemValue/itemValueMod.cs +++ b/KcY-SeeItemValue/itemValue/itemValueMod.cs @@ -8,6 +8,7 @@ using ItemAttribute = GClass2197; using System.Net; using System.Threading; using UnityEngine; +using System.IO; namespace itemValueMod { @@ -51,6 +52,7 @@ namespace itemValueMod string itemId = item.Template._id; JsonClass jsonClass; bool lockWasTaken = false; + double alteredPrice = 1; try { @@ -73,16 +75,13 @@ namespace itemValueMod } } - - double alteredPrice = DurabilityCheck(item, jsonClass); - - Debug.LogError($"price: {alteredPrice}"); + if (jsonClass.price != 1) + { + alteredPrice = DurabilityCheck(item, jsonClass); + } double _price = alteredPrice * jsonClass.multiplier; - Debug.LogError($"price: {jsonClass.multiplier}"); - Debug.LogError($"price: {_price}"); - return Math.Round(_price).ToString(); } @@ -121,62 +120,93 @@ namespace itemValueMod double editedPrice = jsonClass.price; double originalMax = jsonClass.originalMax; - Debug.LogError($"price: {jsonClass.price}"); - + DebugMode($" Entered DurabilityCheck() - starting price is: {editedPrice}"); var medKit = item.GetItemComponent(); if (medKit != null && medKit.HpResource != 0 && medKit.MaxHpResource != 0) { + DebugMode($" Medkit Check - HpResource is: {medKit.HpResource}"); + DebugMode($" Medkit Check - MaxHpResource is: {medKit.MaxHpResource}"); + editedPrice *= medKit.HpResource / medKit.MaxHpResource; } + DebugMode($" After Medkit Check - price is: {editedPrice}"); + var repair = item.GetItemComponent(); if (repair != null) { if (repair.Durability > 0) { + DebugMode($" repairable Check - Durability is: {repair.Durability}"); + DebugMode($" Medkit Check - originalMax is: {originalMax}"); + editedPrice *= repair.Durability / originalMax; } else { + DebugMode($" repairable Check - Durability is 0"); + editedPrice = 1; } } + DebugMode($" After repairable Check - price is: {editedPrice}"); + var dogtag = item.GetItemComponent(); if (dogtag != null && dogtag.Level != 0) { + DebugMode($" dogtag Check - level is: {dogtag.Level}"); + editedPrice *= dogtag.Level; } + DebugMode($" After dogtag Check - price is: {editedPrice}"); + var repairKit = item.GetItemComponent(); if (repairKit != null) { if (repairKit.Resource > 0) { + DebugMode($" repairkit Check - Resource is: {repairKit.Resource}"); + DebugMode($" repairkit Check - originalMax is: {originalMax}"); + editedPrice *= repairKit.Resource / originalMax; } else { + DebugMode($" repairkit Check - Resource is 0"); + editedPrice = 1; } } + DebugMode($" After repairkit Check - price is: {editedPrice}"); + var resource = item.GetItemComponent(); if (resource != null && resource.Value != 0 && resource.MaxResource != 0) { + DebugMode($" resource Check - Resource is: {resource.Value}"); + DebugMode($" resource Check - MaxResource is: {resource.MaxResource}"); editedPrice *= resource.Value / resource.MaxResource; } + DebugMode($" After resource Check - price is: {editedPrice}"); + var foodDrink = item.GetItemComponent(); if (foodDrink != null && foodDrink.HpPercent != 0) { GInterface208 ginterface208_0 = (GInterface208)foodDrink.GetType().GetField("ginterface208_0", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(foodDrink); + DebugMode($" foodDrink Check - HpPercent is: {foodDrink.HpPercent}"); + DebugMode($" foodDrink Check - MaxResource is: {ginterface208_0.MaxResource}"); + editedPrice *= foodDrink.HpPercent / ginterface208_0.MaxResource; } + DebugMode($" After foodDrink Check - price is: {editedPrice}"); + var keys = item.GetItemComponent(); if (keys != null) { @@ -187,19 +217,49 @@ namespace itemValueMod double totalMinusUsed = Convert.ToDouble(ginterface212_0.MaximumNumberOfUsage - keys.NumberOfUsages); double multi = totalMinusUsed / ginterface212_0.MaximumNumberOfUsage; + DebugMode($" foodDrink Check - totalMinusUsed is: {totalMinusUsed}"); + DebugMode($" foodDrink Check - multi is: {multi}"); + editedPrice *= multi; } } + DebugMode($" After keys Check - price is: {editedPrice}"); + var sideEffect = item.GetItemComponent(); if (sideEffect != null && sideEffect.Value != 0) { + DebugMode($" sideEffect Check - resource is: {sideEffect.Value}"); + DebugMode($" sideEffect Check - MaxResource is: {sideEffect.MaxResource}"); + editedPrice *= sideEffect.Value / sideEffect.MaxResource; } - Debug.LogError($"price: {jsonClass.price}"); + DebugMode($" After sideEffect Check - price is: {editedPrice}"); + + DebugMode($"Ending price: {editedPrice}"); return editedPrice; } + + public static void DebugMode(String str) + { + var directory = Directory.GetCurrentDirectory(); + + var modDirectory = new DirectoryInfo(directory + "/user/mods/"); + DirectoryInfo[] dirsInDir = modDirectory.GetDirectories("*" + "SeeItemValue" + "*.*"); + + if (dirsInDir.Length == 1) + { + var json = File.ReadAllText(dirsInDir[0].ToString() + "/src/config.json"); + + var configJson = Json.Deserialize(json); + + if (configJson != null && configJson.DebugMode) + { + Debug.LogError(str); + } + } + } } } \ No newline at end of file diff --git a/KcY-SeeItemValue/itemValue/itemValueMod.csproj b/KcY-SeeItemValue/itemValue/itemValueMod.csproj index 4d65b13..f2ed16c 100644 --- a/KcY-SeeItemValue/itemValue/itemValueMod.csproj +++ b/KcY-SeeItemValue/itemValue/itemValueMod.csproj @@ -2,7 +2,7 @@ net472 - 1.4.4 + 1.4.5 KcY-SeeItemValue diff --git a/KcY-SeeItemValue/itemValue/server/dist/package.json b/KcY-SeeItemValue/itemValue/server/dist/package.json index 2315f8e..3a96035 100644 --- a/KcY-SeeItemValue/itemValue/server/dist/package.json +++ b/KcY-SeeItemValue/itemValue/server/dist/package.json @@ -1,7 +1,7 @@ { "name": "SeeItemValue", "author": "KcY", - "version": "1.4.4", + "version": "1.4.6", "license": "NCSA Open Source", "main": "src/mod.js", "akiVersion": "3.2.3", diff --git a/KcY-SeeItemValue/itemValue/server/dist/src/mod.ts b/KcY-SeeItemValue/itemValue/server/dist/src/mod.ts index 95d43ef..9585c7d 100644 --- a/KcY-SeeItemValue/itemValue/server/dist/src/mod.ts +++ b/KcY-SeeItemValue/itemValue/server/dist/src/mod.ts @@ -103,6 +103,9 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod { result.traderName = "Flea"; + result.originalMax = this.getOrigiDura(id); + this.debugMode(`Original max is ${result.originalMax}`); + // return price if it exists else return 1 if (this.livePrice[id]) { @@ -175,28 +178,35 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod private getBestTraderMulti(parentId: string): any { - let firstCat = this.handbookTable.Categories.find(x => x.Id === parentId); - let secondCat = firstCat.ParentId - let thirdCat = this.handbookTable.Categories.find(x => x.Id === secondCat).ParentId; + let firstCat = this.handbookTable?.Categories?.find(x => x.Id === parentId); + let secondCat = firstCat?.ParentId + let thirdCat = this.handbookTable?.Categories?.find(x => x.Id === secondCat)?.ParentId; + + let result = {k1: 1, k2: "Unknown"}; if (firstCat.Id || secondCat || thirdCat) { for (let i in this.tradersArr) { - if (this.tradersArr[i].sell_category.includes(firstCat.Id) || - this.tradersArr[i].sell_category.includes(secondCat) || - this.tradersArr[i].sell_category.includes(thirdCat)) + if (this.tradersArr[i]?.sell_category?.includes(firstCat.Id) || + this.tradersArr[i]?.sell_category?.includes(secondCat) || + this.tradersArr[i]?.sell_category?.includes(thirdCat)) { - let multi = (100 - this.tradersArr[i].loyaltyLevels[0].buy_price_coef) / 100; - let name = this.tradersArr[i].nickname; + let multi = (100 - this.tradersArr[i]?.loyaltyLevels[0]?.buy_price_coef) / 100; + let name = this.tradersArr[i]?.nickname; - return {k1: multi, k2: name}; + result.k1 = multi; + result.k2 = name; + + return result; } } + + return result; } else { - return 1; + return result; } } diff --git a/KcY-SeeItemValue/itemValue/server/package.json b/KcY-SeeItemValue/itemValue/server/package.json index 2315f8e..3a96035 100644 --- a/KcY-SeeItemValue/itemValue/server/package.json +++ b/KcY-SeeItemValue/itemValue/server/package.json @@ -1,7 +1,7 @@ { "name": "SeeItemValue", "author": "KcY", - "version": "1.4.4", + "version": "1.4.6", "license": "NCSA Open Source", "main": "src/mod.js", "akiVersion": "3.2.3", diff --git a/KcY-SeeItemValue/itemValue/server/src/mod.ts b/KcY-SeeItemValue/itemValue/server/src/mod.ts index 95d43ef..9585c7d 100644 --- a/KcY-SeeItemValue/itemValue/server/src/mod.ts +++ b/KcY-SeeItemValue/itemValue/server/src/mod.ts @@ -103,6 +103,9 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod { result.traderName = "Flea"; + result.originalMax = this.getOrigiDura(id); + this.debugMode(`Original max is ${result.originalMax}`); + // return price if it exists else return 1 if (this.livePrice[id]) { @@ -175,28 +178,35 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod private getBestTraderMulti(parentId: string): any { - let firstCat = this.handbookTable.Categories.find(x => x.Id === parentId); - let secondCat = firstCat.ParentId - let thirdCat = this.handbookTable.Categories.find(x => x.Id === secondCat).ParentId; + let firstCat = this.handbookTable?.Categories?.find(x => x.Id === parentId); + let secondCat = firstCat?.ParentId + let thirdCat = this.handbookTable?.Categories?.find(x => x.Id === secondCat)?.ParentId; + + let result = {k1: 1, k2: "Unknown"}; if (firstCat.Id || secondCat || thirdCat) { for (let i in this.tradersArr) { - if (this.tradersArr[i].sell_category.includes(firstCat.Id) || - this.tradersArr[i].sell_category.includes(secondCat) || - this.tradersArr[i].sell_category.includes(thirdCat)) + if (this.tradersArr[i]?.sell_category?.includes(firstCat.Id) || + this.tradersArr[i]?.sell_category?.includes(secondCat) || + this.tradersArr[i]?.sell_category?.includes(thirdCat)) { - let multi = (100 - this.tradersArr[i].loyaltyLevels[0].buy_price_coef) / 100; - let name = this.tradersArr[i].nickname; + let multi = (100 - this.tradersArr[i]?.loyaltyLevels[0]?.buy_price_coef) / 100; + let name = this.tradersArr[i]?.nickname; - return {k1: multi, k2: name}; + result.k1 = multi; + result.k2 = name; + + return result; } } + + return result; } else { - return 1; + return result; } }