Release v1.14.0 — monetization launch (E5-E8) #237

Merged
developer merged 54 commits from development into master 2026-07-10 10:11:02 +00:00
2 changed files with 42 additions and 6 deletions
Showing only changes of commit 2ce80c241d - Show all commits
+27
View File
@@ -48,6 +48,33 @@ test('placing a tile and confirming via ✅ commits the move', async ({ page })
await expect(page.locator('.make')).toBeHidden();
});
// Regression: taking a hint must NOT fire the post-move interstitial. Firing on the hint interrupted
// placing the preview and reverted the board on the ad's close while the hint stayed spent (the
// reported bug). In mock mode the ad stub shows an "ad fired" toast, standing in for a real VK ad.
test('taking a hint does not fire the interstitial', async ({ page }) => {
await openGame(page);
// Take a hint (the control confirms on a second tap). It produces a legal preview, so the ✅
// control appears — proof the hint fired.
const hint = page.getByRole('button', { name: 'Hint' });
await hint.click();
await hint.click();
await expect(page.locator('.make')).toBeVisible();
// A spurious ad would have toasted by now; none may.
await page.waitForTimeout(400);
await expect(page.getByText('ad fired')).toHaveCount(0);
});
// The interstitial fires once the move is CONFIRMED (never on the hint / pass / exchange / resign).
test('confirming a move fires the interstitial', async ({ page }) => {
await openGame(page);
await page.locator('.rack .tile').first().click();
await page.locator('[data-cell]:not(.filled)').nth(30).click();
await expect(page.locator('[data-cell].pending')).toHaveCount(1);
await page.locator('.make').click();
await expect(page.getByText('ad fired')).toBeVisible();
});
test('a placed tile is saved as a draft and restored on reopening the game', async ({ page }) => {
await openGame(page);
await page.locator('.rack .tile').first().click();
+15 -6
View File
@@ -94,6 +94,11 @@
let exchangeOpen = $state(false);
let exchangeSel = $state<number[]>([]);
let resignOpen = $state(false);
// hintUsedThisTurn marks that a hint was applied on the current turn, so a confirmed play earns
// the hint-kind interstitial (its own 1-min cooldown) instead of the plain move one. Set in
// doHint when the hint's tiles land, read in commit, and cleared on any turn boundary
// (applyMoveResult) so a hint-then-pass does not leak into the next turn's move.
let hintUsedThisTurn = $state(false);
let drag = $state<{ letter: string; blank: boolean; x: number; y: number; touch: boolean } | null>(null);
// Landscape (wide) layout: when the viewport is wider than tall the game switches to a
// two-column layout — the board fills the right side as a square fitted to the height (no
@@ -820,6 +825,9 @@
// applyMoveResult renders the actor's own just-committed move from the response — the move, the
// post-move game and the refilled rack — without a follow-up game.state + game.history.
function applyMoveResult(r: MoveResult) {
// A turn boundary (play / pass / exchange / resign): clear the hint marker so it never leaks
// into the next turn. commit captures it before this runs.
hintUsedThisTurn = false;
view = {
game: r.game,
seat: r.move.player,
@@ -942,6 +950,9 @@
const sub = toSubmit(placement);
if (!sub) return;
busy = true;
// Capture the hint marker before applyMoveResult clears it: a move played off a hint earns the
// hint-kind interstitial (own cooldown), a plain move the move-kind one.
const usedHint = hintUsedThisTurn;
try {
applyMoveResult(await source.submitPlay(id, sub.tiles, variant));
if (view?.game.hotseat) await advanceHotseat();
@@ -949,7 +960,7 @@
zoomed = false;
// A confirmed move may trigger a post-move interstitial (VK, frequency-gated, client-mirrored).
// Only submitPlay earns one — never a pass / exchange / resign. Fire-and-forget.
void maybeShowInterstitial(app.profile?.ads, 'move', {
void maybeShowInterstitial(app.profile?.ads, usedHint ? 'hint' : 'move', {
vsAi: !!view?.game.vsAi,
online: connection.online && !offlineMode.active,
});
@@ -1014,13 +1025,11 @@
}
try {
const h = await source.hint(id);
// Applying a hint triggers its own post-move interstitial, independent of the move cooldown.
void maybeShowInterstitial(app.profile?.ads, 'hint', {
vsAi: !!view?.game.vsAi,
online: connection.online && !offlineMode.active,
});
if (h.move.tiles.length && view) {
placement = placementFromHint(h.move.tiles, view.rack);
// Mark the turn as hinted: the interstitial fires when the player CONFIRMS the move (commit),
// not now — showing it here would interrupt placing the preview and revert the board on close.
hintUsedThisTurn = true;
// Scroll the (zoomed) board to the hint's placement rather than the top-left:
// focus the centre of the laid tiles' bounding box.
const p = placement.pending;