using System.Threading; using System.Threading.Tasks; namespace RudderSdk.Core; /// Session of a scenario battle-pass node. public sealed class BattlePassSession { internal BattlePassSession(ScenarioNodeContext context) => Context = context; /// Underlying node context. public ScenarioNodeContext Context { get; } /// Node id. public string Id => Context.NodeId; /// Reads a typed value from the node data. public T Get(string key, T defaultValue = default!) => Context.Get(key, defaultValue); /// Advances the run through the onLevelUp handle. public Task LevelUpAsync(CancellationToken cancellationToken = default) => Context.CompleteAsync("onLevelUp", cancellationToken); /// Advances the run through the onLevelUp handle (fire-and-forget). public void LevelUp() => Context.Complete("onLevelUp"); /// Advances the run through the onMaxLevel handle. public Task MaxLevelAsync(CancellationToken cancellationToken = default) => Context.CompleteAsync("onMaxLevel", cancellationToken); /// Advances the run through the onMaxLevel handle (fire-and-forget). public void MaxLevel() => Context.Complete("onMaxLevel"); /// Advances the run through the onPremiumPurchase handle. public Task PremiumPurchaseAsync(CancellationToken cancellationToken = default) => Context.CompleteAsync("onPremiumPurchase", cancellationToken); /// Advances the run through the onPremiumPurchase handle (fire-and-forget). public void PremiumPurchase() => Context.Complete("onPremiumPurchase"); /// Advances the run through the onComplete handle. public Task CompleteAsync(CancellationToken cancellationToken = default) => Context.CompleteAsync("onComplete", cancellationToken); /// Advances the run through the onComplete handle (fire-and-forget). public void Complete() => Context.Complete("onComplete"); }