Interface ICharacterAbilityService
- Namespace
- FishMMO.Database.Npgsql.Services.Interfaces
- Assembly
- FishMMO-DB.dll
Service interface for managing character abilities.
public interface ICharacterAbilityService : ICountByKeyAction<long>, IPersistAction<CharacterAbilityData, long>, IPersistManyAction<CharacterAbilityData>, IPersistManyOwnedAction<CharacterAbilityData>, IDeleteByKeyVersionedAction<long>, IFetchCollectionByKeyAction<long, CharacterAbilityData>
- Inherited Members
Remarks
Ability persistence and deletion should be version-gated via the logical Version
so stale updates are rejected and newer authoritative updates win.
Methods
DeleteAbilityAsync(long, long, long, CancellationToken)
Removes one ability outright, so the character may craft the same template again.
Task<DatabaseResult> DeleteAbilityAsync(long characterId, long abilityId, long incomingVersion, CancellationToken cancellationToken = default)
Parameters
characterIdlongThe character that owns the ability. Checked, so one character cannot delete another's row.
abilityIdlongThe row identity, never the template id.
incomingVersionlongThe authoritative, monotonic version for this delete. The row is removed when its own version is at or below this.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
Remarks
Distinct from DeleteAsync(long, long, long, CancellationToken), which leaves
a tombstone. A forgotten ability is not a record of anything — it is the character no
longer having it — and the tombstone is what would stand in the way of re-crafting it.
The upsert keys on (character_id, template_id) and refuses to drop below the
surviving row's version, so a soft delete that stamped the caller's version into the row
would leave it holding a version no fresh craft could outrank, and the upsert's own
id <= 0 guard would then reject the re-craft as a stale write. Forget-then-craft
is a flow the craft panel explicitly advertises.
This mirrors ICharacterItemService.DeleteItemAsync, which removed a vacated row
outright for the same reason.
DeleteAbilityOwnedAsync(long, long, long, CharacterSessionLeaseData, bool, CancellationToken)
DeleteAbilityAsync(long, long, long, CancellationToken), admitted only while the writer still holds the character's session claim.
Task<DatabaseResult> DeleteAbilityOwnedAsync(long characterId, long abilityId, long incomingVersion, CharacterSessionLeaseData claim, bool admitReleased = false, CancellationToken cancellationToken = default)
Parameters
characterIdlongThe character that owns the ability.
abilityIdlongThe row identity, never the template id.
incomingVersionlongThe version ceiling; the row is removed when its own version is at or below this.
claimCharacterSessionLeaseDataThe claim the delete was captured under. Must name
characterId.admitReleasedboolAlso admit an unclaimed character. Only for undoing the writer's own row.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
- Task<DatabaseResult>
Success when the row is gone. Fails with Forbidden when the claim is not held (see
admitReleased).
Remarks
The forget a resident character asks for. The claim is checked, under the character's
share lock, in the delete's own transaction — see CharacterWriteGate.
admitReleased is for a delete that UNDOES a row the same writer wrote
under claim (the grant's revoke): it is then also admitted while the
character holds no claim at all, released and not yet claimed again, because the
character may have left before the revoke could run and nobody has the row loaded. It is
still refused once another session holds the character.
DeleteAsync(long, long, long, CancellationToken)
Deletes a single ability record for a character if incomingVersion is newer.
Task<DatabaseResult> DeleteAsync(long characterId, long abilityId, long incomingVersion, CancellationToken cancellationToken = default)
Parameters
characterIdlongThe character ID that owns the ability.
abilityIdlongThe ability identifier.
incomingVersionlongThe authoritative, monotonic version for this delete operation.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
- Task<DatabaseResult>
A DatabaseResult indicating success or failure.
PersistOwnedAsync(CharacterAbilityData, CharacterSessionLeaseData, CancellationToken)
Persists one ability row, and returns its identity, only while the writer still holds the character's session claim.
Task<DatabaseResult<long>> PersistOwnedAsync(CharacterAbilityData abilityData, CharacterSessionLeaseData claim, CancellationToken cancellationToken = default)
Parameters
abilityDataCharacterAbilityDataThe row.
claimCharacterSessionLeaseDataThe claim the write was captured under. Must name the row's character.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
- Task<DatabaseResult<long>>
The row's identity. Fails with Forbidden when the claim is no longer held, and with NotFound when the character is gone.
Remarks
The single-row sibling of PersistOwnedAsync(IEnumerable<TItem>, IReadOnlyCollection<CharacterSessionLeaseData>, CancellationToken),
for a grant made while the character is resident: the claim is captured with the request
and checked, under the character's share lock, in the write's own transaction — see
CharacterWriteGate. The ungated PersistAsync(TRequest, CancellationToken)
remains for writers that hold no claim by design.