Files
toshiocn 1be0e9caf1 feat(airport): add the Hex Airport dispatch lab as a baseline snapshot
Six-side aprons, frozen levels, solver, rewards and verify scripts; the edge-runway readability work continues from here.
2026-09-21 14:25:09 +08:00

13 lines
692 B
JavaScript

// The host adapter must return a completed receipt only after its rewarded-ad
// success callback. No ad SDK or network service is bundled with this prototype.
export async function requestReward(game, provider, isCurrent = () => true) {
if (game.rewardPending || game.won || game.deadlocked || !isCurrent()) return { status: 'unavailable' };
game.rewardPending = true;
try {
const receipt = await provider({ levelId: game.level.id, steps: game.level.reward.steps });
if (!isCurrent()) return { status: 'stale' };
return { status: game.grantReward(receipt) ? 'granted' : 'cancelled' };
} catch { return { status: 'failed' }; }
finally { game.rewardPending = false; }
}