Files
rudder-csharp-sdk/Services/Scenarios/Sessions/BattlePassLevelSession.cs
T
edmand46 2a8d5d4f2f
CI / check (push) Successful in 50s
CI / publish (push) Failing after 37s
0.3.0: UGC removed, battlepass context-carrying API, scenario behavior aligned with web SDK, CI publish
2026-08-19 17:48:58 +03:00

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");
}