# ladrilho.profile
Each player's saved Ladrilho progress on saveKit (profile mode, namespace `ladrilho`):
XP and level (40 levels, 100, 140, 180 ... XP each), the twelve tile looks unlocked by
level, best Endless score, today's Daily Board best, adventure stars per level, games
played and the tile look in use. `recordGame(mode, result)` gives the XP for a round and
answers what changed (new best, level up, looks unlocked). Called by `ladrilho.App`
and the mode definitions.
# ladrilho.duel
Ladrilho's 3-minute Duel, on Table Codes (roomsKit) rooms and blockPuzzleKit's replayable move logs.
- **Lobby.** Play a friend: roomsKit's own home screen (digit codes tapped on its keypad, a Back
button to Ladrilho). The host starts the round from the room; an empty seat is filled by a
computer player (roomsKit bot fill). Play the computer: Easy, Normal or Hard starts a private
two-seat room with the computer in seat 2 at once.
- **Same pieces.** The host deals one seed; both boards run `Duel.rules(seed)` (classic 8x8,
classic pieces, the `daily` dealer, which never reads the board, so the pieces depend on the seed
alone).
- **Clock.** `startAt` / `endAt` are `multiplayer.sessionTime()` seconds in the room state, so every
screen counts the same 3-2-1 and the same 3:00. Before `startAt` an overlay takes the taps.
- **Moves.** Each machine plays its own board locally and sends its moves `{ slot, q, r, at }` to the
host (re-sent until the host confirms them). The host checks each move by replaying it, drops one
made after 0:00, and publishes every seat's move log in the room state.
- **Opponent.** Each machine applies the opponent's log to a second, non-interactive kit board (the
mini-board: above your board in portrait, in a left column in landscape) with `game:apply(move)`;
its score is the opponent's score.
- **Computer players.** The host plays every `bot` seat (from the start, or one that took over for
someone who left) with the kit's AI (`BP.Ai.new(level)` and a time-sliced `ai:think` job) at a
person's pace (Easy 2.6-4.6 s a move, Normal 1.8-3.4 s, Hard 1.3-2.6 s). A new host after host
migration carries on from the published logs.
- **The end.** At 0:00 plus a 1.2 s grace (or as soon as both boards are out of room) the host replays
both logs and publishes `result = { scores, lines, winner }`: more points wins, tied points go to
more lines cleared, else a draw. Every screen shows that one result. A member whose host vanished
at the last second decides from the logs itself after 6 s (same replay, same answer).
- **Rematch.** In a friend room, the room's waiting screen comes back (the host starts again); against
the computer, a new match at the same level.
API: see the header of `init.luau`. Every word is in `locales/<lang>/ladrilho.json` under `duel.*`.
# ladrilho.adventure
The Adventure's 60 levels as data, and what the map, the goal card, the play HUD and the
tests ask of them. The levels live in `levels/chapter1.json` .. `levels/chapter5.json`
in this package (one chapter a file: `defaults` every level inherits, then twelve
blockPuzzleKit level tables with `goals`, `moves`, an ascii `map` and a designer `note`).
```lua
local Adventure = require("ladrilho.adventure")
local lv = Adventure.level(13) -- blockPuzzleKit level table, defaults merged
Adventure.goalLines(13) -- { "Collect 2 gems" } in the kit's language
Adventure.play(13, 42, "hard") -- the computer plays it: { won, moves, score, stars }
```
Called by `ladrilho.modes` (the adventure session), `ladrilho.app` / `ladrilho.screens`
(the map, goal card and HUD) and the `ladrilhoAdventure` test suite, which has the hard
AI beat every level. Stars come from moves to spare (the kit's rule for levels without
score thresholds). Design: `plans/ladrilho-adventure.plan`.
# ladrilho
The game's own parts for **Ladrilho: Block Puzzle**, a phone-first block-placement
puzzle in English and Brazilian Portuguese: drag pieces onto an 8x8 board of painted
tiles, fill rows and columns to clear them.
## The game shell
- **Title:** the Ladrilho wordmark (each letter on a painted tile), "N playing now",
your level and XP, Play, Progress and Settings.
- **Modes:** Endless (best score kept), Daily Board (the same pieces for everyone each
UTC day, a world leaderboard per day), Adventure (60 levels in five chapters on a
path map, three stars each, the next level opens when one is cleared) and Duel
(3 minutes, a friend by room code or the computer).
- **Results:** score, best / new best, today's rank, stars, XP gained, level up and
tile looks unlocked, then Play again / Next / Map / Modes / Home.
- **Progress:** saved per player account by saveKit and back after a reload: XP and
level (40 levels), twelve tile looks unlocked by level, best scores, stars.
- **Settings:** music and effects volume (menusKit), graphics quality (Graphics
Presets), language (Automatic / English / Português (Brasil), switched live, even
mid-round) and the tile look.
- Portrait first; landscape and desktop mouse layouts too.
## Modules
`ladrilho.app` (routing, the mode API), `ladrilho.App` (the component), `ladrilho.screens`,
`ladrilho.art`, `ladrilho.modes`, `ladrilho.profile`, `ladrilho.daily`, `ladrilho.duel`,
`ladrilho.board` (the seam to blockPuzzleKit), `ladrilho.lang`.
## A mode, and how it plugs in a blockPuzzleKit session
```lua
local Modes = require("ladrilho.modes")
Modes.register({
id = "endless", order = 1, icon = "infinity", route = "play",
title = "ladrilho.modes.endless", blurb = "ladrilho.modes.endless_desc",
session = function(ctx) return { board = "classic8", pieces = "classic", dealer = "merciful", look = ctx.look, seed = ctx.seed } end,
finish = function(ctx, result) ... return { title = ..., score = ..., buttons = { "again", "modes", "home" } } end,
})
-- the App: App.startMode("endless") -> mode.session(ctx) -> Board.mount(cfg, region, App.boardEvent)
-- the board: App.boardEvent{ type = "score", score, lines } / { type = "gameOver" } / { type = "goalDone", stars }
-- the end: App.finishRound(result) -> mode.finish(ctx, result) -> results screen
```
## Installed kits it runs on
- **blockPuzzleKit**: the board, pieces, dealers, scoring, level goals, drag-and-place tray and computer player.
- **menusKit**: pause and settings screens (it brings **controlsKit** with it for input).
- **saveKit**: the saved profile.
- **scoreKit**: best scores and the Daily world boards, one per day (it brings **MatchFlow** with it).
- **Graphics Presets**: the graphics quality setting.
- **Table Codes (roomsKit)**: Duel rooms, the code keypad and the computer seat.
- **announcerKit**: the clear and combo callouts.
- **soundstageCore**: music and sound effects.
- **playingNow**: the "N playing now" chip.
- **levelPathMap**: the Adventure's chapter map, given Ladrilho's palette, fonts, widgets, goal glyphs and words in `Screens.adventureSpec`.
## Words
`locales/en/ladrilho.json` and `locales/pt-BR/ladrilho.json`, with plural forms and
the language's number grouping. The Brazilian Portuguese has been reviewed
(`locales/pt-BR/ladrilho.review.json`, every line `ai_reviewed`, the review state the
catalog check takes for a translation checked by someone other than its writer).