ludic/packages/ludic.tracks/state.ludic

76 lines
3 KiB
Text

# state.ludic - the port, the prints, the facts, and what the reader has learned
# what the tracks ask the world. Any member may be left out of the bind: the time is then 0,
# the reader can name every animal, no bearing is given, and nothing is drawn.
export port TracksWorld {
now: fn() -> float = fn tk_time_zero # game hours, counted from the start of the trip
skill: fn() -> int = fn tk_every_skill # how well the reader reads (the game's tiers)
bearing: fn(float) -> string = fn tk_no_bearing # a yaw in words ("north-west"), "" for none
placed: fn(int, int) -> void = fn tk_not_drawn # a print was put down at (kind, ring index): draw it
}
function tk_time_zero() -> float { return 0.0 }
function tk_every_skill() -> int { return 2147483647 }
function tk_no_bearing(yaw: float) -> string { return "" }
function tk_not_drawn(kind: int, i: int) -> void { }
# where a sign came from
export const TRACK_PRINT: int = 0 # a print in a ring, read with tracks_read
export const TRACK_SIGN: int = 1 # a legend's sign, told with tracks_note
export const TRACK_SCAT: int = 2 # droppings, told with tracks_note
# how old a print looks
export const TRACK_FRESH: int = 0
export const TRACK_RECENT: int = 1
export const TRACK_OLD: int = 2
export property Track {
x: float = 0.0
z: float = 0.0
yaw: float = 0.0
sp: int = 0
legend: bool = false
maker: int = -1 # the animal that left it (the game's nid), -1 not known
made: float = 0.0
read: bool = false
}
# a sign was read: `first` the first time this one was, `named` whether the reader could tell
# the animal, `bearing` the way it went in words ("" without them)
export property TrackRead {
sp: int = 0
source: int = 0
kind: int = 0
legend: bool = false
age: float = 0.0
fresh: int = 0
yaw: float = 0.0
named: bool = true
bearing: string = ""
first: bool = false
}
export state TracksState {
tk_kinds: int = 0
tk_cap: int = 0
tk_ring: []Track = null # kinds x cap, kind-major
tk_count: []int = null # per kind: how many of the ring are in use
tk_next: []int = null # per kind: where the next print goes
tk_name_at: int = 0 # the skill that tells the animal from its print
tk_fresh_h: float = 0.5
tk_recent_h: float = 2.5
tk_read_n: int = 0 # signs read for the first time, of every source
tk_yaw: float = 0.0 # the heading of the last sign read
tk_has_yaw: bool = false
tk_chain: int = -1 # the maker of the trail being followed, -1 none (chain.ludic)
tk_chain_x: float = 0.0 # the last of its signs read: where, and when it was made
tk_chain_z: float = 0.0
tk_chain_made: float = 0.0
tk_chain_h: float = 0.0 # when it was read, in game hours
tk_reads: Queue<TrackRead> = tk_reads__new()
}
# the facts: every sign read, oldest first
export function tracks_reads(tracks_st: TracksState) -> Queue<TrackRead> {
return tracks_st.tk_reads
}
function tk_reads__new() -> Queue<TrackRead> { return queue_new("tracks.reads") }