From 9310fbfdd4dbce4d80d36542ef67ad941a8da2ac Mon Sep 17 00:00:00 2001 From: Radjax Date: Fri, 29 Oct 2021 20:00:58 -0700 Subject: [PATCH] Inital stub out of Insurance payout scaling using hardcoded SERVER_DESIRED_EP_LEVEL value that we use for the EP boost calculations, those who have 750k EP will get the normal insurace payout, and it scales up to almost double value for new accounts. From what I can tell every subsequent call dealing with insurance will call back to this table instead of InsurancePrices, so it shouldnt require any table changes. --- .../Facilities/InsuraceFacility.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Perpetuum/Services/ProductionEngine/Facilities/InsuraceFacility.cs b/src/Perpetuum/Services/ProductionEngine/Facilities/InsuraceFacility.cs index 0efe2f0ad..98e7be358 100644 --- a/src/Perpetuum/Services/ProductionEngine/Facilities/InsuraceFacility.cs +++ b/src/Perpetuum/Services/ProductionEngine/Facilities/InsuraceFacility.cs @@ -3,6 +3,7 @@ using System.Linq; using Perpetuum.Accounting.Characters; using Perpetuum.Common.Loggers.Transaction; +using Perpetuum.Data; using Perpetuum.ExportedTypes; using Perpetuum.Groups.Corporations; using Perpetuum.Items; @@ -116,6 +117,7 @@ public void InsuranceBuy(Character character, Robot robot, ref int currentInsura double insuranceFee, payOut; GetInsurancePrice(robot, out insuranceFee, out payOut).ThrowIfError(); + payOut = GetBoostedInsurancePayout(character, payOut); wallet.Balance -= insuranceFee; @@ -147,6 +149,26 @@ public void InsuranceBuy(Character character, Robot robot, ref int currentInsura currentInsurances++; } + private const double SERVER_DESIRED_EP_LEVEL = 750000; + public double GetBoostedInsurancePayout(Character character, double payOut) { + Accounting.Account account = character.GetAccount(); + var collectedEp = Db.Query().CommandText("SELECT dbo.extensionPointsCollected(@accountID)") + .SetParameter("@accountID", account.Id) + .ExecuteScalar(); + double modifier = GetInsurancePayoutModifier(collectedEp); + + return Math.Round(payOut * (1 + modifier)); + } + + private static double GetInsurancePayoutModifier(int collectedEpSum) { + + var linearRatio = collectedEpSum / SERVER_DESIRED_EP_LEVEL; + var result = 1.0 - linearRatio; + result = result.Clamp(); + + return result; + } + public ErrorCodes InsuranceQuery(Character character, IEnumerable targetEids, out Dictionary result) { var ec = ErrorCodes.NoError;