Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insurance payout-scaling Issue #397 #422

Draft
wants to merge 1 commit into
base: Development
Choose a base branch
from
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