# lanternDuel.rules
The Lantern Duel rules for a cardsKit table and the one-call setup. `LD.Table{...}` spawns a two-seat duel table (glow 20, energy 3, hand 5, play freely then End turn), `LD.install(name)` registers the rules on every peer, `LD.winner(game)` names the winning seat, `LD.result(name)` reads the result text on any screen.
# gameNight.results
The end-of-game screen both Game Night tables share: MatchFlow's winner banner with Rematch and Stand up buttons. `Results.show(name, data, rematchCb, standCb, look)`, `Results.hide(name)`.
# gameNight.progress
Each player's Game Night record in their own saveKit profile: XP for cards played (3), dice rolled (2), finishing a duel or race (40) and winning (100 more); stats `duelsPlayed`, `duelsWon`, `racesPlayed`, `racesWon`, `cardsPlayed`, `diceRolled`; a rank title per level (Newcomer, Regular, Card Sharp, Dice Whisperer, Table Captain, Lantern Keeper, Game Night Legend). Calls act on the local player only.
# lanternDuel
**An original two-player card duel for cardsKit: a painted 25-card deck and the rules that pick a winner.** Each player tends a lantern with 20 glow. On your turn you play any cards your energy pays for (creatures and spells dim the other lantern, wards shield yours, charms restore glow, draw cards or brew energy), then press End turn. The first lantern to go dark loses. Every card is original, with storybook gouache art of a night garden and a painted lantern back.
Version **1.0.11** (`LD.VERSION`). Needs **cardsKit 1.0.12** or later (installed with it).
## Quick start
1. Install `lanternDuel.package` from ZeroMind (search "lantern duel card deck"). cardsKit and gridKit come with it.
2. A card table scene (see cardsKit's quick start: `"player": "none"` and a camera), then in `build.luau`:
```lua
local LD = require("lanternDuel.rules")
function content()
local cam = entity.spawn("TableCamera")
cam.component.add("Camera", {})
cam.localPosition = { 0, 3, 6 }
LD.Table { name = "Duel", style = "fantasy" }
end
```
3. In the scene's `entrypoint.luau` register the rules on every peer:
```lua
local LD = require("lanternDuel.rules")
function onLoad() LD.install("Duel") end
```
4. Press play with a friend. Each of you is dealt 5 cards nobody else sees; drag a card onto the felt to play it, press End turn, and play until one lantern goes out. `CK.table("Duel").restart()` deals a rematch.
Change one word for another look: `style = "pixel"`, `"cartoon"`, `"scifi"`, `"classic"`, `"minimal"` (every cardsKit frame style shows the painted art).
## The deck
| card | type | cost | does | copies |
|---|---|---|---|---|
| Moth Swarm | Creature | 1 | Deal 3. | 3 |
| Owl Dive | Creature | 2 | Deal 6. | 2 |
| Firefly Spark | Creature | 0 | Deal 2. | 2 |
| Fox Feint | Trick | 1 | Deal 2. Draw 1. | 2 |
| Toad Guard | Ward | 1 | Gain 4 shield. | 3 |
| Hedgehog Curl | Ward | 2 | Gain 8 shield. | 2 |
| Moonwell Sip | Charm | 1 | Restore 4 glow. | 2 |
| Starlit Map | Charm | 1 | Draw 2. | 2 |
| Ember Tea | Charm | 0 | Gain 2 energy. | 2 |
| Comet Fall | Spell | 3 | Deal 10. | 1 |
| Lantern Flare | Spell | 2 | Deal 4. Gain 4 shield. | 2 |
| Willow Hush | Charm | 1 | Restore 2 glow. Draw 1. | 2 |
Glow is cardsKit's `hp` stat, shield its `block` stat. Damage hits shield first.
## Guides
- **Example:** [How to make a two-player card duel, step by step](lanternDuel.package/guides/how-to-make-a-two-player-card-duel-step-by-step): from an empty world to a duel played to a winner, with a rematch.
- **How-to:** [How to make a custom card deck with your own art and rules](lanternDuel.package/guides/how-to-make-a-custom-card-deck-with-your-own-art-and-rules): cards as data, effects, painted art and a card back, tuning the rules, styles, winners, and putting the duel in a walking 3D room.
## Rules and defaults
| setting | default | what it does |
|---|---|---|
| glow (`LD.GLOW`) | 20 | each lantern's starting and maximum glow |
| energy (`LD.ENERGY`) | 3 | refilled at the start of each of your turns |
| hand (`LD.HAND`) | 5 | cards dealt when you sit down |
| hand limit (`LD.HAND_MAX`) | 7 | you draw one card at the start of your turn while under it |
| plays per turn | any | `actions = 0`: play what your energy pays for, then End turn |
`LD.Table(opts)` takes any cardsKit table setting as an override (`style`, `layout`, `seed`, `title`, `autoSeat`, ...). Older played cards move to the discard pile so the felt shows the latest four plays, and an empty draw pile is refilled from the discard pile.
## API
| call | does |
|---|---|
| `LD.Table(opts?) -> entity` | spawns the duel table (build.luau) |
| `LD.settings(opts?) -> table` | the cardsKit settings it uses, for `CK.Table` yourself |
| `LD.install(name?)` | registers the rules for a table (every peer, in `onLoad`) |
| `LD.rules() -> hooks` | the cardsKit rule hooks, to wrap with your own |
| `LD.winner(game) -> seat?` | the winning seat once a lantern is dark |
| `LD.result(name?) -> string` | the result text on any screen, `""` while the duel runs |
| `LD.Deck` | the deck module: `ID`, `LIST`, `ART`, `size()` |
## Tests
`zero tests run lanternDuel`: the deck and its art, card conservation through a duel, shield and glow under damage and the winner, and the table settings.
## Where it is used
The Game Night world puts this duel on a felt table in a cosy room, where two players sit down, play to a winner, see a results screen and take a rematch.
## Versions
- **1.0.11**: the duel table clears itself. Once more than four cards lie on the felt, each play sends the oldest one (by play order) to the discard pile, so the felt shows the latest plays and the duel flows on to a winner with no Clear table button. It used to pick the first card in slot order, which after the first clear was the card just played, so the table filled and every play was refused. Checked with two players over 14 turns: never more than four cards on the felt, no refusal.
- **1.0.10**: the winner check installs once however often `LD.install` runs (a keyed `CK.on`), built against cardsKit 1.0.11 (a player can no longer restart a duel in progress).
- **1.0.9**: built against cardsKit 1.0.10 (its card sounds carry their descriptions).
- **1.0.8**: built against cardsKit 1.0.8: cards slap onto the felt with a sound, draws swish, the deck riffles when it shuffles, and every card name reads in the fanned hand.
- **1.0.7**: built against cardsKit 1.0.7, whose table fits phones and tablets beside other kits (screen margins, clear of the touch buttons).
- **1.0.6**: two guides: an example, "How to make a two-player card duel, step by step", and a how-to, "How to make a custom card deck with your own art and rules" (they replace the one combined guide). 1.0.5 was published without the how-to's text, so use 1.0.6.
- **1.0.5** (do not use): two guides: an example, "How to make a two-player card duel, step by step", and a how-to, "How to make a custom card deck with your own art and rules" (they replace the one combined guide).
- **1.0.4**: the winner reaches every screen the moment a lantern goes dark. A win found while a card's damage resolves is now published at once; before, it waited on the dealer until the next action (found in a two-client test in Game Night, where the losing player saw no result).
- **1.0.3**: card art and the card back are passed to cardsKit as texture guids (the form its frame styles draw), so every face shows its painting and the table shows the lantern back (with cardsKit 1.0.6). The deck test checks every card's art is a texture guid.
- **1.0.2**: the card duel guide.
- **1.0.1**: first release: the deck, rules, tests and README.
# gameNight
The game glue of the **Game Night** world: a cosy room where friends sit down at tables and play a card duel and a dice race, plus a gallery of every style the kits offer. Everything the games are made of comes from installable kits; this package only joins them up, so it is also a worked example of combining them.
| part | what it does |
|---|---|
| `DuelStation` component | Joins the felt table (tableKit) to the Lantern Duel (cardsKit + lanternDuel): sitting in a chair takes that card seat and opens the card screen for you alone (`setLocalUi`), the table machine moves the turn indicator and writes glow, shield and card count on the nameplates, and a finished duel shows the results screen with Rematch. |
| `RaceStation` component | Joins the tavern table (tableKit) to the race board (boardKit) and the dice tray (diceKit): your chair is your pawn, only the seat whose turn it is may roll (R, pad A, tap or drag on the tray, or the Roll button), the dice total moves the pawn, board events show as a line at the top, the turn ring follows the board, first pawn home wins, and the results screen offers a rematch. |
| `Gallery` component | The gallery kiosk: one panel (Dice, Boards, Pawns, Tables, Cards) listing every entry of the four kits' catalogs, applying a pick live to the try-out table or either game table. Mouse, touch, keyboard and gamepad. |
| `results` module | The shared end screen: MatchFlow's winner banner with Rematch and Stand up. |
| guide | [How to make a board game with dice and turns, at a table with seats](gameNight.package/guides/how-to-make-a-board-game-with-dice-and-turns-at-a-table-with-seats) |
## Quick start
The Game Night world's `scenes/main.scene/build.luau` places everything; the parts that matter:
```lua
local TK = require("tableKit.api")
local LD = require("lanternDuel.rules")
local BK = require("boardKit.api")
local DK = require("diceKit.api")
-- the duel
TK.Table { name = "Duel", position = { -3.6, 0, 0 }, yaw = 90, style = "felt", shape = "round", seats = 2, hud = "top" }
LD.Table { name = "DuelCards", style = "fantasy", autoSeat = false }
entity.spawn("DuelStation").component.add("gameNight.DuelStation", { tableName = "Duel", cardsName = "DuelCards" })
-- the race
TK.Table { name = "Race", position = { 3.6, 0, 0 }, yaw = -90, style = "tavern", shape = "long", seats = 4, hud = "top" }
BK.Board { name = "RaceBoard", position = { 3.6, 0.76, -0.42 }, size = 0.82, track = "loop", spaces = 30, autoSeat = false }
DK.Tray { name = "RaceDice", position = { 3.6, 0.76, 0.6 }, dice = { "d6" }, look = "wooden", showUi = false, input = false }
entity.spawn("RaceStation").component.add("gameNight.RaceStation", { tableName = "Race", boardName = "RaceBoard", trayName = "RaceDice" })
-- the gallery kiosk
entity.spawn("GalleryKiosk").component.add("gameNight.Gallery", {})
```
Defaults: the duel is two players, 20 glow, 3 energy, 5 cards; the race is up to four players on a 30-space loop with a d6, overshoot finish and fortune cards. Change any look or rule with one setting on the kit it belongs to (see each kit's README, or open the gallery kiosk in play).
## How to play
- Walk up to a chair and press **E** (pad **A**, or tap the prompt) to sit; **Esc** (pad **B**, or Stand up) to stand. **C** (pad **Y**) changes the camera view.
- **Card duel**: drag a card from your hand onto the felt (or tap it, then tap the felt), play what your energy pays for, press End turn. Damage hits shield first; the first lantern to reach 0 glow loses.
- **Dice race**: on your turn press **R**, tap or click the tray, press pad **A**, or drag across the tray to aim a throw. Your pawn hops the total; spaces push you on, send you back, skip your next turn, warp you or draw a fortune card. First home wins.
- **Gallery**: walk to the lectern in the north alcove and press **E**. Pick a tab, a target table, and an entry; it changes on every screen at once.
## Tests
The kits carry the tests (cardsKit, lanternDuel, tableKit, boardKit, diceKit test suites). This package is checked by playing: two clients seated at each table, a full duel and a full race to a winner, rematch, and the gallery applying entries to each target.