Added code to reduce the accuracy of values deemed too accurate
This commit is contained in:
parent
5eebd817b4
commit
e7813b48dd
@ -296,7 +296,13 @@ namespace Generator.Helpers.Gear
|
|||||||
foreach (var cartridge in botToUpdate.inventory.Ammo.Keys)
|
foreach (var cartridge in botToUpdate.inventory.Ammo.Keys)
|
||||||
{
|
{
|
||||||
var cartridgeWithWeights = botToUpdate.inventory.Ammo[cartridge];
|
var cartridgeWithWeights = botToUpdate.inventory.Ammo[cartridge];
|
||||||
|
foreach (var cartridgeKvP in cartridgeWithWeights)
|
||||||
|
{
|
||||||
|
cartridgeWithWeights[cartridgeKvP.Key] = ReduceValueAccuracy(cartridgeKvP.Value);
|
||||||
|
}
|
||||||
|
|
||||||
var weights = cartridgeWithWeights.Values.Select(x => x).ToList();
|
var weights = cartridgeWithWeights.Values.Select(x => x).ToList();
|
||||||
|
|
||||||
var commonAmmoDivisor = CommonDivisor(weights);
|
var commonAmmoDivisor = CommonDivisor(weights);
|
||||||
|
|
||||||
foreach (var cartridgeWeightKvP in cartridgeWithWeights)
|
foreach (var cartridgeWeightKvP in cartridgeWithWeights)
|
||||||
@ -341,6 +347,11 @@ namespace Generator.Helpers.Gear
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (var itemWeightKvp in equipmentDict)
|
||||||
|
{
|
||||||
|
equipmentDict[itemWeightKvp.Key] = ReduceValueAccuracy(itemWeightKvp.Value, 4);
|
||||||
|
}
|
||||||
|
|
||||||
var weights = equipmentDict.Values.Select(x => x).ToList();
|
var weights = equipmentDict.Values.Select(x => x).ToList();
|
||||||
var commonAmmoDivisor = CommonDivisor(weights);
|
var commonAmmoDivisor = CommonDivisor(weights);
|
||||||
|
|
||||||
@ -355,5 +366,13 @@ namespace Generator.Helpers.Gear
|
|||||||
equipmentDict[itemTplWithWeight.Key] /= commonAmmoDivisor;
|
equipmentDict[itemTplWithWeight.Key] /= commonAmmoDivisor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int ReduceValueAccuracy(long x, int digits = 3)
|
||||||
|
{
|
||||||
|
int i = (int)Math.Log10(x);
|
||||||
|
i = Math.Max(0, i - (digits - 1));
|
||||||
|
i = (int)Math.Pow(10, i);
|
||||||
|
return (int)(x / i * i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user