33 lines
1.3 KiB
C#
33 lines
1.3 KiB
C#
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace RudderSdk.Core;
|
|
|
|
/// <summary>
|
|
/// Session of a scenario battle-pass-level node — a single claimable tier.
|
|
/// <see cref="ClaimAsync"/> crosses onComplete, which the server accepts only
|
|
/// once the player has reached the node's configured level.
|
|
/// </summary>
|
|
public sealed class BattlePassLevelSession
|
|
{
|
|
internal BattlePassLevelSession(ScenarioNodeContext context) => Context = context;
|
|
|
|
/// <summary>Underlying node context.</summary>
|
|
public ScenarioNodeContext Context { get; }
|
|
|
|
/// <summary>Node id.</summary>
|
|
public string Id => Context.NodeId;
|
|
|
|
/// <summary>The tier level this node claims.</summary>
|
|
public int Level => Context.Get("levelNumber", 0);
|
|
|
|
/// <summary>Reads a typed value from the node data.</summary>
|
|
public T Get<T>(string key, T defaultValue = default!) => Context.Get(key, defaultValue);
|
|
|
|
/// <summary>Claims this tier; crosses onComplete (the server checks the level was reached).</summary>
|
|
public Task ClaimAsync(CancellationToken cancellationToken = default) => Context.CompleteAsync("onComplete", cancellationToken);
|
|
|
|
/// <summary>Claims this tier (fire-and-forget).</summary>
|
|
public void Claim() => Context.Complete("onComplete");
|
|
}
|