refactor(packages): the mechanic packages use ludic_base only, and ask through ports
ludic.clock, .effects, .inventory, .wallet, .weather and .tracks say 'uses ludic_base' (ludic.base uses nothing). ClockWorld, PackRules, WeatherWorld and TracksWorld are export ports whose defaults are the old fallbacks; clock_bind, inv_bind, weather_bind and tracks_bind are gone, and the tests bind their fakes. The base README's toy does the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
f4062010e9
commit
63e29f024c
31 changed files with 130 additions and 149 deletions
|
|
@ -1,8 +1,9 @@
|
|||
# state.ludic - the pack's port, its facts, and its counts
|
||||
# what the pack asks the game: how many of a kind fit (unbound: no limit)
|
||||
export property PackRules {
|
||||
stack_limit: fn(int) -> int = null
|
||||
export port PackRules {
|
||||
stack_limit: fn(int) -> int = fn iv_no_limit
|
||||
}
|
||||
function iv_no_limit(it: int) -> int { return 2147483647 }
|
||||
|
||||
# a count changed, however: added, taken, or set outright
|
||||
export property ItemChanged {
|
||||
|
|
@ -11,13 +12,10 @@ export property ItemChanged {
|
|||
after: int = 0
|
||||
}
|
||||
|
||||
var iv_rules: PackRules = null
|
||||
var iv_keys: []string = null
|
||||
var iv_counts: []int = null
|
||||
var iv_changes: Queue<ItemChanged> = null
|
||||
|
||||
export function inv_bind(r: PackRules) -> void { iv_rules = r }
|
||||
|
||||
# the kinds, by the name each is saved under; the pack starts empty
|
||||
export function inv_config(keys: []string) -> void {
|
||||
iv_keys = keys
|
||||
|
|
@ -42,8 +40,7 @@ export function inv_count(it: int) -> int {
|
|||
}
|
||||
|
||||
export function inv_limit(it: int) -> int {
|
||||
if iv_rules == null or iv_rules.stack_limit == null { return 2147483647 }
|
||||
return iv_rules.stack_limit(it)
|
||||
return PackRules.stack_limit(it)
|
||||
}
|
||||
|
||||
# how many more fit
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue