ludic migrate state packages <every example program> packages/ludic.lab/example/plate.ludic 1804 vars into 126 states, 64 into lets; 23498 edits in 460 files Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
79 lines
3.2 KiB
Text
79 lines
3.2 KiB
Text
# species.ludic - what a kind of animal IS, as far as its day goes: the game hands the table in,
|
|
# one entry per species, and the entry's place in it is the species' number
|
|
export const WILD_MEADOW: int = 0
|
|
export const WILD_FOREST: int = 1
|
|
export const WILD_SHORE: int = 2
|
|
export const WILD_CLIFF: int = 3
|
|
|
|
# what it eats, and so what food and which lures it comes to
|
|
export const WILD_PLANTS: int = 0
|
|
export const WILD_FISH: int = 1
|
|
export const WILD_HAY: int = 2
|
|
export const WILD_SEED: int = 3
|
|
|
|
export property WildSpecies {
|
|
key: string = ""
|
|
walk: float = 1.0 # m/s
|
|
run: float = 1.0 # m/s
|
|
flee: float = 30.0 # its nerve: how far off a player starts to reach it, m
|
|
home: float = 60.0 # how far it roams about its home, m
|
|
habitat: int = 0 # WILD_MEADOW .. WILD_CLIFF
|
|
tracks: bool = false # a walker that leaves prints (and droppings, and beds)
|
|
size: int = 0 # 0 small (a snare holds it), 1 medium, 2 large
|
|
diet: int = 0 # WILD_PLANTS .. WILD_SEED
|
|
flies: bool = false # a bird: it circles, lands and lifts off
|
|
tame: bool = false # minds nobody (a horse)
|
|
charges: bool = false # comes at a player who gets too close (a bear)
|
|
forget: float = 2.5 # alert points a second it lets go of
|
|
land_shy: float = 80.0 # a bird: how close it comes down with somebody about, m
|
|
land_chance: float = 0.1 # and how readily it comes down at all
|
|
keep_away: float = 60.0 # how far its ranges keep from where the valley starts, m
|
|
range: float = 100.0 # how wide one of its ranges is, m
|
|
scale: float = 1.0 # its size, times
|
|
}
|
|
|
|
export state WildlifeState {
|
|
wl_facts: Queue<WildFact> = null
|
|
wl_own: []WildAnimal = null
|
|
wl_px: float = 0.0
|
|
wl_pz: float = 0.0
|
|
wl_ask: WildLure = null
|
|
wl_best: WildLure = null
|
|
wl_seed_any: bool = false
|
|
wl_seed_t: float = 0.0
|
|
wl_ids: int = 0
|
|
wl_ranges: []WildRange = null
|
|
wl_found: []int = null # found flags a load brought before the ranges were set out
|
|
wl_seen: int = 0
|
|
wl_fed: int = 0
|
|
wl_fed_any: bool = false
|
|
wl_near_i: int = 0
|
|
wl_species: []WildSpecies = null
|
|
wl_list: []WildAnimal = null
|
|
wl_keys: int = 0
|
|
wl_dice: Rng = null
|
|
wl_hold: bool = false # staged: nobody thinks, everybody keeps their speed
|
|
wl_spot_ask: WildSpot = null
|
|
}
|
|
|
|
function wl_sp_all(wildlife_st: mut WildlifeState) -> []WildSpecies {
|
|
if wildlife_st.wl_species == null { wildlife_st.wl_species = new []WildSpecies }
|
|
return wildlife_st.wl_species
|
|
}
|
|
|
|
export function wildlife_species_clear(wildlife_st: mut WildlifeState) -> void { wildlife_st.wl_species = new []WildSpecies }
|
|
|
|
# the next species; returns its number
|
|
export function wildlife_species_add(wildlife_st: mut WildlifeState, s: WildSpecies) -> int {
|
|
push(wl_sp_all(wildlife_st), s)
|
|
return len(wl_sp_all(wildlife_st)) - 1
|
|
}
|
|
|
|
export function wildlife_species_count(wildlife_st: mut WildlifeState) -> int { return len(wl_sp_all(wildlife_st)) }
|
|
|
|
export function wildlife_species(wildlife_st: mut WildlifeState, sp: int) -> WildSpecies {
|
|
if sp < 0 or sp >= len(wl_sp_all(wildlife_st)) { return null }
|
|
return wl_sp_all(wildlife_st)[sp]
|
|
}
|
|
|
|
function wl_sp(wildlife_st: mut WildlifeState, sp: int) -> WildSpecies { return wl_sp_all(wildlife_st)[sp] }
|