hopefully fixes latest issues with refactor, might have to look into caching all on game start
This commit is contained in:
parent
555c17d308
commit
dac0960e7b
Binary file not shown.
Binary file not shown.
@ -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",
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
@ -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<MedKitComponent>();
|
||||
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<RepairableComponent>();
|
||||
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<DogtagComponent>();
|
||||
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<RepairKitComponent>();
|
||||
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<ResourceComponent>();
|
||||
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<FoodDrinkComponent>();
|
||||
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<KeyComponent>();
|
||||
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<SideEffectComponent>();
|
||||
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<ConfigClass>(json);
|
||||
|
||||
if (configJson != null && configJson.DebugMode)
|
||||
{
|
||||
Debug.LogError(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<Version>1.4.4</Version>
|
||||
<Version>1.4.5</Version>
|
||||
<AssemblyName>KcY-SeeItemValue</AssemblyName>
|
||||
</PropertyGroup>
|
||||
|
||||
|
@ -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",
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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",
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user