Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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<int>();
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<long> targetEids, out Dictionary<string, object> result)
{
var ec = ErrorCodes.NoError;
Expand Down