Class PlotVaultService
Holds what was standing on a plot when its owner lost it.
public sealed class PlotVaultService : BaseService<PlotVaultEntity>, IPlotVaultService
- Inheritance
-
PlotVaultService
- Implements
- Inherited Members
Constructors
PlotVaultService(INpgsqlDbContextFactory)
public PlotVaultService(INpgsqlDbContextFactory dbContextFactory)
Parameters
dbContextFactoryINpgsqlDbContextFactory
Methods
FetchByCharacterAsync(long, CancellationToken)
Everything one character is owed.
public Task<DatabaseResult<List<PlotVaultData>>> FetchByCharacterAsync(long characterID, CancellationToken cancellationToken = default)
Parameters
characterIDlongcancellationTokenCancellationToken
Returns
FetchEntryAsync(long, long, CancellationToken)
Reads one vault row, pinned to the character who owns it.
public Task<DatabaseResult<PlotVaultData?>> FetchEntryAsync(long vaultID, long characterID, CancellationToken cancellationToken = default)
Parameters
vaultIDlongcharacterIDlongcancellationTokenCancellationToken
Returns
Remarks
The owner is part of the query rather than checked afterwards, so a request naming somebody else's row finds nothing instead of finding something the caller then has to remember to reject.
ForfeitAllAsync(long, CancellationToken)
Empties a character's vault.
public Task<DatabaseResult<int>> ForfeitAllAsync(long characterID, CancellationToken cancellationToken = default)
Parameters
characterIDlongcancellationTokenCancellationToken
Returns
StorePlotContentsAsync(long, long, long, float, CancellationToken)
Moves everything built on a plot into its owner's vault, and clears the plot.
public Task<DatabaseResult<int>> StorePlotContentsAsync(long plotID, long characterID, long baseFeePerEntry, float feeRatePerDay, CancellationToken cancellationToken = default)
Parameters
plotIDlongcharacterIDlongbaseFeePerEntrylongfeeRatePerDayfloatcancellationTokenCancellationToken
Returns
- Task<DatabaseResult<int>>
How many vault rows the move produced.
Remarks
One transaction, deliberately. Storing and clearing as two writes has two failure modes and both are bad: stop after the store and the owner has their furniture in the vault and still standing on land somebody else is about to buy; stop before it and the house is gone with nothing to show for it. Neither is recoverable by retrying, because the retry cannot tell which half already happened.
TryRemoveEntryAsync(long, long, CancellationToken)
Takes one entry out of the vault, pinned to the character who owns it.
public Task<DatabaseResult<int>> TryRemoveEntryAsync(long vaultID, long characterID, CancellationToken cancellationToken = default)
Parameters
vaultIDlongcharacterIDlongcancellationTokenCancellationToken
Returns
- Task<DatabaseResult<int>>
One when the entry was removed, zero when it was already gone.
Remarks
The single atomic step in both retrieval and forfeiting. Retrieval charges first and then calls this: whoever gets the 1 back is the one who removed it, so a player clicking twice pays once and a row cannot be handed out to two requests at the same moment.