refactor(runtime,packages,examples): named constants, package enums, idiom sweep
- runtime: HEADLESS_FRAME_PATH, STICK_DEADZONE / STICK_LEFT_X/Y, key and byte codes as char literals throughout (`k == 'w'`, `fill(rt_map, ' ', …)`) - ludic.gameplay/stats: drop the duplicate `stat_field` (it answered "atk" for every build stat); Stats.base uses stats_field_name - ludic.shooter: compare aim modes and fire patterns with AimMode.* and WeaponPattern.* instead of raw ints; STICK_RIGHT_X/Y - ludic.npcai: DecisionMade / brain_set_state use AiState.* - examples/games/menu.ludic uses Font.load / Ui.* with FONT_PATH and BACKDROP named; strings.ludic header says what it prints - whole tree: `x = x + 1` → `x += 1` (single-term right-hand sides only), `0 - x` → `-x`, ASCII codes → char literals; every .ludic and every ```ludic fence reformatted with the fixed formatter (whitespace only) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
e3e1bc7784
commit
bf36bc8a8f
103 changed files with 1256 additions and 1252 deletions
|
|
@ -32,14 +32,14 @@ event CraftCompleted { e: int = 0, recipe: int = 0 }
|
|||
# Craft.recipe(name, out_item, out_qty) — declare a recipe; returns its id.
|
||||
@Namespace(Craft) function craft_recipe(name: pointer, out_item: pointer, out_qty: int) -> int {
|
||||
craft_ensure()
|
||||
if recipe_n >= CRAFT_MAX { return 0 - 1 }
|
||||
if recipe_n >= CRAFT_MAX { return -1 }
|
||||
let id = recipe_n
|
||||
recipe_out[id] = out_item; recipe_outqty[id] = out_qty
|
||||
recipe_n = recipe_n + 1
|
||||
recipe_n += 1
|
||||
Dict.set(recipe_reg, name, id)
|
||||
return id
|
||||
}
|
||||
@Namespace(Craft) function craft_id(name: pointer) -> int { craft_ensure(); return Dict.get_or(recipe_reg, name, 0 - 1) }
|
||||
@Namespace(Craft) function craft_id(name: pointer) -> int { craft_ensure(); return Dict.get_or(recipe_reg, name, -1) }
|
||||
# Craft.ingredient(recipe_name, item, qty) — add an ingredient requirement.
|
||||
@Namespace(Craft) function craft_ingredient(recipe_name: pointer, item: pointer, qty: int) -> void {
|
||||
craft_ensure()
|
||||
|
|
@ -47,7 +47,7 @@ event CraftCompleted { e: int = 0, recipe: int = 0 }
|
|||
if rid < 0 { return }
|
||||
if ing_n >= CRAFT_ING_MAX { return }
|
||||
ing_rid[ing_n] = rid; ing_name[ing_n] = item; ing_qty[ing_n] = qty
|
||||
ing_n = ing_n + 1
|
||||
ing_n += 1
|
||||
}
|
||||
|
||||
# Craft.can(e, recipe_name) — does the owner hold every ingredient?
|
||||
|
|
@ -60,7 +60,7 @@ event CraftCompleted { e: int = 0, recipe: int = 0 }
|
|||
if ing_rid[i] == rid {
|
||||
if Inventory.count(e, ing_name[i]) < ing_qty[i] { return 0 }
|
||||
}
|
||||
i = i + 1
|
||||
i += 1
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
|
@ -75,7 +75,7 @@ event CraftCompleted { e: int = 0, recipe: int = 0 }
|
|||
var i = 0
|
||||
while i < ing_n {
|
||||
if ing_rid[i] == rid { Inventory.remove(e, ing_name[i], ing_qty[i]) }
|
||||
i = i + 1
|
||||
i += 1
|
||||
}
|
||||
Inventory.add(e, recipe_out[rid], recipe_outqty[rid])
|
||||
emit CraftCompleted(e: e, recipe: rid)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue