Table of Contents

Class PlotVaultFee

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

What it costs to get something back out of a house vault.

public static class PlotVaultFee
Inheritance
PlotVaultFee
Inherited Members

Remarks

The design's formula, fee = baseFee * (1 + daysStored * rate), kept in one place so the number a player is quoted and the number they are charged come from the same arithmetic. A quote that disagreed with the charge would look like the game taking more than it said.

Pure, and deliberately not a method on the vault service: the fee is shown in a UI on the client, checked before the retrieval is attempted, and taken on the server, and none of those three should be reimplementing it.

Fields

MaximumFee

Largest fee this will ever quote.

public const long MaximumFee = 1000000000

Field Value

long

Remarks

The formula grows without bound in the number of days, and nothing stops a row sitting in a vault for a year. Left uncapped it would eventually overflow the arithmetic, and long before that it would price a chair above everything the player will earn — which is not a gold sink, it is a delete button wearing one. Capping keeps retrieval a decision the player can weigh rather than an answer the game has already given for them.

Methods

Calculate(long, DateTime, DateTime, float)

What retrieving one stored thing costs.

public static long Calculate(long baseFee, DateTime storedAtUtc, DateTime nowUtc, float ratePerDay)

Parameters

baseFee long

The fee charged the moment it is stored. Zero means free, always.

storedAtUtc DateTime

When it went into the vault.

nowUtc DateTime

The moment being quoted.

ratePerDay float

How much of the base fee is added per day stored.

Returns

long

Remarks

Elapsed time is floored at zero rather than allowed to go negative. A row can be stamped slightly ahead of a reader's clock — the servers in a cluster do not agree to the millisecond — and a negative day count would quietly discount the fee, or, with a large enough rate, invert it into a payment for taking your own furniture back.

Fractional days count. Rounding up to whole days would make something stored a minute ago cost a full day's interest, and rounding down would make the first day free and reward exactly the delay the fee exists to discourage.

CalculateFromPercent(long, DateTime, DateTime, float)

The same fee, for a rate authored as a per-day percentage rather than a fraction.

public static long CalculateFromPercent(long baseFee, DateTime storedAtUtc, DateTime nowUtc, float percentPerDay)

Parameters

baseFee long
storedAtUtc DateTime
nowUtc DateTime
percentPerDay float

Returns

long

Remarks

A convenience for inspector fields, which read better as "10% a day" than as "0.1".