feat(packages): ludic.crafting - recipes as an open registry, can / take / refund / make through a pack port, stations through a port, the hold-to-make, a Crafted fact
A recipe is `def CraftRecipes key { out, n, ins: [...], ns: [...], station, minutes, hold,
group, learned }`. The pack is the CraftPack port (count, take, add, room, and `leaves`: what
an item leaves once used, so water gives back its bottle); stations are CraftStations (ready,
start), unbound meaning hands only. craft_make hands a click recipe over or starts a timed one
at its station, refunding when the station refuses; the hold runs from the screen that shows it.
Uses ludic.base only; ten tests with a fake pack and fake stations.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
7f8a7ea7ed
commit
cc9cec922a
9 changed files with 475 additions and 0 deletions
20
packages/ludic.crafting/ports.ludic
Normal file
20
packages/ludic.crafting/ports.ludic
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# ports.ludic - what crafting asks the game: the pack, and the stations
|
||||
# the pack. `leaves` is what an item leaves behind once used (water leaves its bottle), -1 nothing.
|
||||
export port CraftPack {
|
||||
count: fn(int) -> int
|
||||
take: fn(int, int) -> bool
|
||||
add: fn(int, int) -> int
|
||||
room: fn(int) -> int = fn cr_no_limit
|
||||
leaves: fn(int) -> int = fn cr_leaves_nothing
|
||||
}
|
||||
function cr_no_limit(it: int) -> int { return 2147483647 }
|
||||
function cr_leaves_nothing(it: int) -> int { return -1 }
|
||||
|
||||
# the stations. Unbound, there are none: only the hands are ready, and nothing can be started.
|
||||
# `start(station, recipe)` puts a timed recipe in; false gives the makings back.
|
||||
export port CraftStations {
|
||||
ready: fn(int) -> bool = fn cr_hands_only
|
||||
start: fn(int, int) -> bool = fn cr_no_start
|
||||
}
|
||||
function cr_hands_only(station: int) -> bool { return station == CRAFT_HANDS }
|
||||
function cr_no_start(station: int, recipe: int) -> bool { return false }
|
||||
Loading…
Add table
Add a link
Reference in a new issue