ludic/examples/games/chronorift/rules.ludic
Orkuncakilkaya fb728bbefe chore(repo): DX cleanup — categorise examples, text-diffable golden, build/ output (#27 #28 #30)
Repository-cleanup / DX pass folding three tracker items into one coherent
change, verified green end to end (`bin/x test` 49/0, `bin/x selfhost-test`
29/0, `bin/x test-tools` 29/0).

#28 — curate & categorise examples/
- 42 flat entries regrouped into intent-revealing subdirs: games/, rendering/,
  ecs/, events/, networking/, lang/, library/ (was lib/).
- chronorift dir-vs-file duplication resolved: the entry file and its import
  modules now live together under games/chronorift(.ludic).
- Every path reference updated repo-wide (test runner, editor-tool drivers,
  docs/site, design docs).
- New examples/README.md indexes the whole set with run commands.
- Showcase examples without a self-asserting entry (hello, events, net_rt) now
  get a compile-only rot guard in `bin/x test`, so nothing here rots silently.

#30 — text-diffable golden baseline
- The 4 binary selfhost/golden/*.ppm blobs are replaced by a single
  selfhost/golden/renders.sha256 manifest (SHA-256 per render). Hashes are
  byte-identical to the old PPMs, so the baseline is unchanged — only its form.
- game_case now compares framebuffer hashes; a regression shows as a changed
  hex line in review, not "binary files differ".
- New `bin/x golden` regenerates the manifest deliberately (review with
  `git diff selfhost/golden/renders.sha256`).

#27 — PPM & asset handling
- Headless renders now write build/out.ppm, never the repo root; `x app`,
  `x clean`, messaging and .gitignore updated to match. Nothing is written to
  the working root any more.
- Redundant local Kenney .zip archives removed (the art ships extracted;
  .gitignore already excludes *.zip). CC0 License.txt files retained.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-30 18:54:21 +03:00

86 lines
3.2 KiB
Text

# rules.ludic — pure game rules & map data (functions only, no systems).
function tile_sprite(c: int) -> int {
match c {
'T', '#' => return SPR_TREE
'H' => return SPR_HOUSE
'D' => return SPR_DOOR
'r', 'h' => return SPR_PATH
',', 'S', 'B' => return SPR_FLOOR
'=' => return SPR_WALL
}
return SPR_GRASS
}
function walkable(x: int, y: int) -> bool {
let c = Map.tile(x, y)
return c == '.' or c == 'D' or c == 'r' or c == ',' or c == 'S' or c == 'B' or c == 'h'
}
function is_confirm(k: int) -> bool { return k == 32 or k == 10 or k == 13 }
function enemy_name(et: int) -> string {
if et == 0 { return "SLIME" }
if et == 1 { return "SKELETON" }
return "RIFT WARDEN"
}
function build_field(x: int) -> int {
Map.size(40, 18)
Map.row(0, "########################################")
Map.row(1, "#......................................#")
Map.row(2, "#...TT.........................TT.....D#")
Map.row(3, "#..TT.......................TT.........#")
Map.row(4, "#..T.........................T.........#")
Map.row(5, "#....................................T.#")
Map.row(6, "#.....TT....................TT.......T.#")
Map.row(7, "#....TT.....................T..........#")
Map.row(8, "#...........rrrrrrrr........HH.........#")
Map.row(9, "#..........r........r.......HH.........#")
Map.row(10, "#......TT...r........rrrrrrrrhr......T.#")
Map.row(11, "#.....TT...r.................r.......T.#")
Map.row(12, "#..........r.......TT.......r..........#")
Map.row(13, "#..........rrrrrrrrrrrrrrrrr.........T.#")
Map.row(14, "#.........TT.........................T.#")
Map.row(15, "#........TT..........................T.#")
Map.row(16, "#....................................T.#")
Map.row(17, "########################################")
return 0
}
function build_dungeon(x: int) -> int {
Map.size(40, 18)
Map.row(0, "========================================")
Map.row(1, "=,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,=")
Map.row(2, "=,S,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,=")
Map.row(3, "=,,,,,====,,,,,,,,,,,,,,,====,,,,,,,,,,=")
Map.row(4, "=,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,=")
Map.row(5, "=,,,,,,,,,,,,,====,,,,,,,,,,,,,,,,,,,,,=")
Map.row(6, "=,,,,,,,,,,,,,,,,,,,,,,,,,,,,,====,,,,,=")
Map.row(7, "=,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,=")
Map.row(8, "=,,,====,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,=")
Map.row(9, "=,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,=")
Map.row(10, "=,,,,,,,,,,,,,,,,,,====,,,,,,,,,,,,,,,,=")
Map.row(11, "=,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,=")
Map.row(12, "=,,,,,,,,,,,,,,,,,,,,,,,,,,,====,,,,,,,=")
Map.row(13, "=,,,,,,,,,====,,,,,,,,,,,,,,,,,,,,,,,,,=")
Map.row(14, "=,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,=")
Map.row(15, "=,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,B,,=")
Map.row(16, "=,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,=")
Map.row(17, "========================================")
return 0
}
function grant_xp(amount: int) -> int {
for (t) in query [Stats, {Party}] {
if t.hp > 0 {
t.xp = t.xp + amount
while t.xp >= t.lvl * 20 {
t.xp = t.xp - t.lvl * 20
t.lvl = t.lvl + 1
t.maxhp = t.maxhp + 8
t.hp = t.maxhp
t.maxmp = t.maxmp + 2
t.atk = t.atk + 2
t.def = t.def + 1
}
}
}
return 0
}