Struct AchievementProgress
How far a player has advanced towards a progressive achievement, plus the opaque condition
state the evaluator needs to resume counting across sessions.
Immutable value object.
Assembly: Serenity.Achievements.Domain.dll
Syntax
public readonly struct AchievementProgress : IEquatable<AchievementProgress>
Constructors
AchievementProgress(AchievementId, long, long, string, long)
Creates a new AchievementProgress with the specified data.
Declaration
public AchievementProgress(AchievementId achievement, long current, long target, string conditionState, long revision)
Parameters
| Type |
Name |
Description |
| AchievementId |
achievement |
The achievement this progress belongs to.
|
| long |
current |
The current numerator. Negative values are clamped to zero.
|
| long |
target |
The numerator that unlocks the achievement. Negative values are clamped to zero.
|
| string |
conditionState |
Opaque state serialized by the unlock condition. May be null.
|
| long |
revision |
The monotonic write stamp this row was last persisted under.
|
Fields
Achievement
The achievement this progress belongs to.
Declaration
public readonly AchievementId Achievement
Field Value
ConditionState
Opaque state serialized by the unlock condition. May be null.
Declaration
public readonly string ConditionState
Field Value
Current
The current numerator. Never negative.
Declaration
public readonly long Current
Field Value
Revision
The monotonic write stamp this row was last persisted under.
Declaration
public readonly long Revision
Field Value
Target
The numerator that unlocks the achievement. Zero means the achievement is boolean.
Declaration
public readonly long Target
Field Value
Properties
IsComplete
Whether the numerator has reached the target.
Declaration
public bool IsComplete { get; }
Property Value
Normalized
The progress expressed as a 0..1 fraction. A boolean achievement (zero target) reads as
complete once its numerator is positive.
Declaration
public double Normalized { get; }
Property Value
Methods
Equals(AchievementProgress)
Declaration
public bool Equals(AchievementProgress other)
Parameters
Returns
Equals(object)
Declaration
public override bool Equals(object obj)
Parameters
| Type |
Name |
Description |
| object |
obj |
|
Returns
Overrides
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Overrides
ToString()
Declaration
public override string ToString()
Returns
Overrides
WithConditionState(string, long)
Returns a copy of this progress carrying the given condition state and write stamp.
Declaration
public AchievementProgress WithConditionState(string conditionState, long revision)
Parameters
| Type |
Name |
Description |
| string |
conditionState |
The state serialized by the unlock condition.
|
| long |
revision |
The write stamp the next persist uses.
|
Returns
WithCurrent(long, long)
Returns a copy of this progress carrying the given numerator and write stamp.
Declaration
public AchievementProgress WithCurrent(long current, long revision)
Parameters
| Type |
Name |
Description |
| long |
current |
The new numerator.
|
| long |
revision |
The write stamp the next persist uses.
|
Returns
Operators
operator ==(AchievementProgress, AchievementProgress)
Declaration
public static bool operator ==(AchievementProgress left, AchievementProgress right)
Parameters
Returns
operator !=(AchievementProgress, AchievementProgress)
Declaration
public static bool operator !=(AchievementProgress left, AchievementProgress right)
Parameters
Returns
Implements