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