Unbox is a box-opening game. You spend virtual currency to open boxes. Each box contains one item. The item has a rarity. You can sell it, keep it in your vault, or watch the balance tick down toward zero and question your choices. The cheapest box costs £5 and its tagline is “Could be treasure. Could be a wet wipe.” The most expensive costs £1,000,000 and its tagline is “At this price, it had better be.”
There are thirteen box types. There are six rarity tiers. There are thirty-two upgrades. There are five curse types with sell multipliers ranging from 2x to 25x. There is a passive income system called Clout. The scope expanded significantly during the first weekend.
The Economy
The rarity ladder runs Common, Uncommon, Rare, Epic, Mythic, Secret. Each box has a rarity multiplier table that shifts the weights — the cheapest cardboard box cannot roll Mythic or Secret at all, while the top tiers make Epics routine and Mythics genuinely achievable. No box has a non-zero Secret weight. Secret items appear only when a Mythic pull is upgraded by a secondary roll: the game checks whether the pull converts to Secret-tier, with the chance scaling by box price and upgrades owned.
Items can be cursed or blessed. Curses come in five severities — Jinxed, Hexed, Cursed, Doomed, Forsaken — with sell multipliers of 2x, 4x, 7x, 12x, and 25x respectively. A Forsaken item is worth twenty-five times its base value when sold. It is also the rarest curse, weighted at one percent of the cursed pool. The correct response to pulling a Forsaken Mythic is to sell it immediately. The tempting response is to put it in the vault and watch the Clout accumulate.
Clout is passive income from displayed items. It earns per minute per item, scaled by rarity. Common items earn nothing. A Secret item earns £2 per minute. Leave a well-stocked vault running overnight and you come back to something meaningful. The Clout Amplifier upgrade chain scales that passive rate by up to two hundred percent. Getting the upgrade tree to a point where the passive income was interesting but not trivialising — not enough to bulk-buy thousands of boxes after a long sleep — took more tuning than expected.
Lua Scripts and Why They Exist
Every balance and inventory change runs as a single Lua script inside Redis. Opening a box, selling an item, buying an upgrade, collecting Clout — each is one atomic operation. No read-modify-write cycles that concurrent requests could corrupt.
The problem this solves is specific: the Clout collection script checks whether the player’s clout_collected_at timestamp matches what the client read before making the request. Two overlapping tabs polling for Clout both read the same timestamp, both try to collect, but only one can pass the compare-and-set. The second gets back a stale: true flag and no payout. No transaction needed, no pessimistic locking, no double-credit.
Testing Lua scripts outside of a live Redis instance is not obvious. The test suite uses wasmoon, an embedded Lua VM compiled to WebAssembly, with a small fake Redis object that implements HSET, HGET, ZADD, ZREM, DEL, EXISTS, SISMEMBER, and SADD. The scripts run against it in Node.js with tsx --test. It is not a perfect simulation — cjson.encode and cjson.decode needed thin shims — but it covers the branching logic without needing a live store.
The Migration
The game launched on Supabase. The ticker — the live feed of Epic and above pulls that scrolls across the bottom of the screen — originally used Supabase Realtime. Realtime is good at this. It is also a persistent WebSocket, and Vercel serverless functions do not hold connections between invocations.
The workaround was to move all state to Upstash Redis and replace Realtime with a capped list. Epic, Mythic, and Secret pulls are pushed onto the list at open time. Clients poll /api/ticker every five seconds and read the latest entries. The list is capped so it does not grow indefinitely. The result is eventually consistent rather than instant, which is fine: the ticker is ambient noise, not a critical feed.
The migration script copies the full Supabase state — loot table, profiles, inventory, upgrades, Google account links — into Redis. It preserves user IDs, so vault links keep working and Google players land on their existing profile. It is safe to re-run: profiles already in Redis are skipped. This made the cutover low-risk: run with --dry-run to verify the mapping, run for real while the old stack is still live, deploy, run once more to pick up the last few minutes of activity.
Identity
Guest sessions exist from the start. First visit creates a signed guest ID in an httpOnly cookie. All game state is attached to that ID. When the player signs in with Google, the guest ID is linked to their Google account rather than replaced. Progress carries over.
The edge case is a player who signs in with a Google account that already has its own profile. This surfaces as ?auth_error=identity_conflict on redirect. The player is offered a choice: keep the current session or switch to the Google profile, with an explicit warning that the other will be dropped. The conflict is rare enough that the error state is worth more than a silent merge that could surprise people.
The Stack
Next.js 16, React 19, Tailwind 4. Framer Motion for the reveal sequence and the cinematic anticipation animation before a high-rarity pull. canvas-confetti, as always. Upstash Redis for all persistent state via the HTTP client. next-auth v5 beta for Google sign-in. wasmoon for Lua script testing. No traditional database.
The upgrade tree has thirty-two entries, five tiers deep, culminating in Mogul Status at £5,000,000. It requires eight thousand boxes opened, one hundred thousand Clout earned, and three prerequisite upgrades. It is probably fine.
RESULT
It’s live at unbox.baudypositive.com. The box economy holds. The Lua scripts have not double-credited anyone. The Forsaken curse has appeared in the wild.
The most time was spent on the upgrade tree and the box pricing. Getting thirteen boxes to feel like a natural progression — where each tier is clearly better and the price jump feels roughly proportional — required working through the rarity multiplier tables by hand until the numbers matched the intuition. The Cardboard Box tagline has never been wrong.