GamificationOrchestrator class final
Owns every gamification function: the play decision, skin caching and
prefetch, and the rewards fetch. The surfaces call in for a chance; the
game surface opens the game. Port of iOS GamificationOrchestrator
(presentation wiring lives in GamificationSurface / GameSurface).
Constructors
- GamificationOrchestrator({required PlayIdentity? identity(), GameOutcomeSource? outcomeSource, SkinFileCache? skinFileCache, SkinPrefetcher? prefetcher, DesignTokenCatalog designTokensOf()?, ServerTimeClock? serverClockOf()?, CampaignModel? campaignById(String campaignId)?})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- playSession → PlaySession
-
no setter
- prefetcherForTesting → SkinPrefetcher?
-
Test-only accessor for the show-time download path.
no setter
-
rewardsCampaigns
→ Map<
String, CampaignModel> -
Campaigns from the latest
getRewardsthat are paused or ended — and so not in the bundle. Keyed by server campaign id, like Android'srewardsCampaignsand iOS'srewardsCampaigns.final -
rewardsCampaignTitles
→ Map<
String, String> -
rewardsPageTitleper campaign key, from the same payloads.final - rewardsLoading ↔ bool
-
True while the first fetch is in flight (the page shows a spinner).
getter/setter pair
- rewardsResponse ↔ GameRewardsResponse?
-
The latest
getRewardsanswer, driving the rewards page and widget. Null until the first fetch; a failed fetch keeps the previous one.getter/setter pair - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- skinFileCache → SkinFileCache?
-
no setter
Methods
-
campaignForRewardsChance(
String campaignId) → ({CampaignModel campaign, GamificationConfig config})? -
The campaign and gamification config behind a rewards chance: the
rewards-only campaigns first (by server id), then the bundle (by server
id, with a campaign-key fallback), like iOS's
openGameForRewardsChancelookup and Android'srewardsCampaigns[campaignId] ?: findById. Null for an unknown campaign or a non-gamification one. Never throws. -
chanceForId(
String chanceId) → GameRewardChance? - The waiting chance with this id, or null.
-
chanceState(
String campaignKey, {String? testInvocationId, String? chanceId}) → Future< ChanceStateResult> -
The read-only
statecheck after an entry's game closes.chanceIdis the closed game's own chance, so a re-trigger cannot answer for it. Never throws. -
clearForUserChange(
) → void - Clears session entry state for a user change. Never throws.
-
clearRewardsForUserChange(
) → void - Drops the rewards state: a new user must never see the previous user's rewards, and a user-less fetch must not keep stale content around.
-
loadRewardsAsync(
) → Future< GameRewardsResponse?> -
refreshRewards as a result: the rewards screen reads
page.urlfrom it and needs the campaign designs loaded before a game can open. The load coalesces with an in-flight refresh; a caller that stops waiting does not cancel it. Null with no user or on a failed fetch. Never throws. Port of Android'sloadRewardsAsync. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
prefetchGamificationSkins(
List< CampaignSkinRef> skins) → void - Prefetches every gamification skin on campaign sync, so a later show usually hits the cache. Fire-and-forget: failures drop and retry at the next sync. Never throws.
-
refreshRewards(
{void onHealth(EngageAnalyticsEvent event)?}) → Future< void> -
Fetches
getRewardsand stores it for the page and the widget. Calls coalesce while one is in flight; a failure logs and keeps the last response, so the page degrades to previous content (or the empty message) instead of failing. With no user there is nothing to fetch: any stale response is dropped so a previous user's rewards never linger. Never throws. Port of iOSrefreshRewards. -
refreshRewardsIfLoaded(
{void onHealth(EngageAnalyticsEvent event)?}) → void -
Refreshes only when rewards were fetched before — a game close must not
pay for a fetch the app never asked for. Port of iOS
refreshRewardsIfLoaded. -
requestGameChance(
{required String campaignKey, required String triggerId, required bool direct, required bool isGameBusy(), String? testInvocationId}) → Future< PlayDecision> - One trigger's chance request. Returns the PlayDecision so the caller (the surface) can open, render, or drop. Never throws.
-
resetForTesting(
) → void - Resets the rewards state for a test teardown.
-
rewardsCampaignTitle(
String campaignKey, {String? bundleTitleOf(String campaignKey)?}) → String? - The rewards page title for a chance's campaign: the bundle first, then the paused/ended campaigns the response carried.
-
storeRewards(
Map< String, dynamic> raw) → void -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited