Class AchievementRecordMapping
Maps between the achievement value objects and the generic StructuredRecord shape, and builds the field-name-driven scope filters and schemas StructuredStoreAchievementAdapter needs. The single place that knows the two achievement tables' column names.
Inherited Members
Namespace: Serenity.Achievements.Infrastructure
Assembly: Serenity.Achievements.Infrastructure.dll
Syntax
public static class AchievementRecordMapping
Remarks
Both tables are partitioned by PlayerIdField and keyed by
KeyFieldsPlayerAndAchievement: achievements are account-level, so every read
and every write is already scoped to one player, which is exactly the shape a key-value
backed IStructuredStore can answer (it only serves queries scoped to a single
partition — see KeyValueStructuredStore's remarks).
RevisionField is the upsert-if-better comparison field on both tables: a write carrying an older revision than the stored row loses, which is what stops a late screenshot attachment from overwriting a newer state.
Fields
AchievementIdField
Field name storing the achievement a row belongs to.
Declaration
public const string AchievementIdField = "achievement_id"
Field Value
| Type | Description |
|---|---|
| string |
ConditionStateField
Field name storing ConditionState.
Declaration
public const string ConditionStateField = "condition_state"
Field Value
| Type | Description |
|---|---|
| string |
CurrentField
Field name storing Current.
Declaration
public const string CurrentField = "current"
Field Value
| Type | Description |
|---|---|
| string |
DefaultProgressTableName
The default progress table or collection name used when the settings leave it blank.
Declaration
public const string DefaultProgressTableName = "serenity_achievement_progress"
Field Value
| Type | Description |
|---|---|
| string |
DefaultUnlocksTableName
The default unlocks table or collection name used when the settings leave it blank.
Declaration
public const string DefaultUnlocksTableName = "serenity_achievement_unlocks"
Field Value
| Type | Description |
|---|---|
| string |
KeyFieldsPlayerAndAchievement
The key identifying one achievement's row for a player, for upsert-if-better.
Declaration
public static readonly IReadOnlyList<string> KeyFieldsPlayerAndAchievement
Field Value
| Type | Description |
|---|---|
| IReadOnlyList<string> |
PlatformSyncedField
Field name storing PlatformSynced.
Declaration
public const string PlatformSyncedField = "platform_synced"
Field Value
| Type | Description |
|---|---|
| string |
PlayerIdField
Field name storing the player both tables are partitioned by.
Declaration
public const string PlayerIdField = "player_id"
Field Value
| Type | Description |
|---|---|
| string |
PointsAwardedField
Field name storing PointsAwarded.
Declaration
public const string PointsAwardedField = "points_awarded"
Field Value
| Type | Description |
|---|---|
| string |
RevisionField
Field name storing the monotonic write stamp both tables order writes by.
Declaration
public const string RevisionField = "revision"
Field Value
| Type | Description |
|---|---|
| string |
ScreenshotKeyField
Field name storing ScreenshotKey.
Declaration
public const string ScreenshotKeyField = "screenshot_key"
Field Value
| Type | Description |
|---|---|
| string |
TargetField
Field name storing Target.
Declaration
public const string TargetField = "target"
Field Value
| Type | Description |
|---|---|
| string |
UnlockedAtTicksField
Field name storing UnlockedAtUtcTicks.
Declaration
public const string UnlockedAtTicksField = "unlocked_at_ticks"
Field Value
| Type | Description |
|---|---|
| string |
Methods
BuildPlayerScopeFilters(PlayerId)
Builds the player_id = player scope filter every player-scoped operation shares.
Declaration
public static IReadOnlyList<FieldFilter> BuildPlayerScopeFilters(PlayerId player)
Parameters
| Type | Name | Description |
|---|---|---|
| PlayerId | player | The player the operation is scoped to. |
Returns
| Type | Description |
|---|---|
| IReadOnlyList<FieldFilter> |
BuildProgressSchema(StoreTable)
Builds the progress table schema: fields, identity column, and the player/achievement index.
Declaration
public static StructuredTableSchema BuildProgressSchema(StoreTable table)
Parameters
| Type | Name | Description |
|---|---|---|
| StoreTable | table | The table or collection progress rows are stored in. |
Returns
| Type | Description |
|---|---|
| StructuredTableSchema |
BuildRowScopeFilters(PlayerId, AchievementId)
Builds the player_id = player AND achievement_id = achievement single-row scope filter.
Declaration
public static IReadOnlyList<FieldFilter> BuildRowScopeFilters(PlayerId player, AchievementId achievement)
Parameters
| Type | Name | Description |
|---|---|---|
| PlayerId | player | The player the row belongs to. |
| AchievementId | achievement | The achievement the row belongs to. |
Returns
| Type | Description |
|---|---|
| IReadOnlyList<FieldFilter> |
BuildUnlocksSchema(StoreTable)
Builds the unlocks table schema: fields, identity column, and the player/achievement index.
Declaration
public static StructuredTableSchema BuildUnlocksSchema(StoreTable table)
Parameters
| Type | Name | Description |
|---|---|---|
| StoreTable | table | The table or collection unlocks are stored in. |
Returns
| Type | Description |
|---|---|
| StructuredTableSchema |
ToProgress(StructuredRecord, ILogService)
Maps a StructuredRecord back to a progress row.
Declaration
public static AchievementProgress ToProgress(StructuredRecord record, ILogService logService = null)
Parameters
| Type | Name | Description |
|---|---|---|
| StructuredRecord | record | The stored row. |
| ILogService | logService | Logging service used to report a mistyped column. May be |
Returns
| Type | Description |
|---|---|
| AchievementProgress |
ToProgressRecord(PlayerId, AchievementProgress)
Maps a progress row to its StructuredRecord field representation.
Declaration
public static StructuredRecord ToProgressRecord(PlayerId player, AchievementProgress progress)
Parameters
| Type | Name | Description |
|---|---|---|
| PlayerId | player | The player the progress belongs to. |
| AchievementProgress | progress | The progress row to persist. |
Returns
| Type | Description |
|---|---|
| StructuredRecord |
ToProgressRows(IReadOnlyList<StructuredRecord>, ILogService)
Maps stored rows back to progress rows, preserving order.
Declaration
public static IReadOnlyList<AchievementProgress> ToProgressRows(IReadOnlyList<StructuredRecord> records, ILogService logService = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyList<StructuredRecord> | records | The stored rows. |
| ILogService | logService | Logging service used to report a mistyped column. May be |
Returns
| Type | Description |
|---|---|
| IReadOnlyList<AchievementProgress> |
ToUnlock(StructuredRecord, ILogService)
Maps a StructuredRecord back to an unlock record.
Declaration
public static AchievementUnlockRecord ToUnlock(StructuredRecord record, ILogService logService = null)
Parameters
| Type | Name | Description |
|---|---|---|
| StructuredRecord | record | The stored row. |
| ILogService | logService | Logging service used to report a mistyped column. May be |
Returns
| Type | Description |
|---|---|
| AchievementUnlockRecord |
ToUnlockRecord(AchievementUnlockRecord)
Maps an unlock record to its StructuredRecord field representation.
Declaration
public static StructuredRecord ToUnlockRecord(AchievementUnlockRecord record)
Parameters
| Type | Name | Description |
|---|---|---|
| AchievementUnlockRecord | record | The unlock record to persist. |
Returns
| Type | Description |
|---|---|
| StructuredRecord |
ToUnlocks(IReadOnlyList<StructuredRecord>, ILogService)
Maps stored rows back to unlock records, preserving order.
Declaration
public static IReadOnlyList<AchievementUnlockRecord> ToUnlocks(IReadOnlyList<StructuredRecord> records, ILogService logService = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyList<StructuredRecord> | records | The stored rows. |
| ILogService | logService | Logging service used to report a mistyped column. May be |
Returns
| Type | Description |
|---|---|
| IReadOnlyList<AchievementUnlockRecord> |