code wiki / _hdl_build / nx_rewards.nx

nx_rewards.nx

buildroot/runtime/_hdl_build/nx_rewards.nx

10752 B186 linesdepth 4pulls 5 transitivereach 5 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_rewards.nx -- LIB: REAL-REWARD gamification (operator: "we want gamification for lots of these popular activities but not dumb rewards but real rewards and real positives and real capabilities"). A GENERAL gamification substrate (works for ANY activity -- swap, garden, compost, cook, ...) where every reward is REAL, never a meaningless point or cosmetic badge. A reward is REAL iff it pays out in at least one of: VALUE -- measured money saved / value gained (cents, grounded in real data e.g. store prices). CAPABILITY -- a real unlocked ability the ecosystem HONORS (rw_can gates real features on it). PROVISION -- a real good earned (seeds, a tool), with its real worth. ANTI-DUMB BY CONSTRUCTION: rw_def_achievement REFUSES any achievement with no real backing (value<=0 AND no capability). So a "dumb reward" cannot exist in the system -- proven mechanically, not promised. Sovereign seg-store (knowledge/store/reward-*, NO TSV), integer cents. license_tier: ORIGINAL

dependencies 3 imports · 5 importers

nx_food_science.nx nx_seg_store.nx nx_syscalls.nx nx_rewards.nx nx_activities_gate.nx nx_rewards_gate.nx nx_seedlib.nx nx_seedlib_gate.nx nx_swap_reward_gate.nx

imports: nx_food_science.nxnx_seg_store.nxnx_syscalls.nx

imported by: nx_activities_gate.nxnx_rewards_gate.nxnx_seedlib.nxnx_seedlib_gate.nxnx_swap_reward_gate.nx

structs

none

consts

16const K_MAGIC_2048: i64 = 2048

functions

18func rw_put(prefix: *u8, key: *u8, val: *u8) -> i64
27func rw_money(dst: *u8, off: i64, cents: i64) -> i64
called by 1: rw_render_rewards calls 1: fd_apnum
39func rw_ach_key(aid: *u8, out: *u8) -> i64 { var o: i64 = 0; o = as_append(out, o, "reward:ach:" as *u8); o = as_append(out, o, aid); out[o] = 0 as u8; return o }
42func rw_backing_real(value_cents: i64, capability: *u8) -> i64
called by 1: rw_def_achievement calls 1: fd_streq
50func rw_def_achievement(prefix: *u8, aid: *u8, name: *u8, activity: *u8, kind: *u8, value_cents: i64, capability: *u8, cite: *u8) -> i64
63func rw_ach_defined(prefix: *u8, aid: *u8) -> i64
70func rw_ach_str(prefix: *u8, aid: *u8, f: i64, out: *u8) -> i64
77func rw_ach_int(prefix: *u8, aid: *u8, f: i64) -> i64
85func rw_earned_key(uid: *u8, aid: *u8, out: *u8) -> i64 { var o: i64 = 0; o = as_append(out, o, "reward:earned:" as *u8); o = as_append(out, o, uid); out[o] = 58 as u8; o = o + 1; o = as_append(out, o, aid); out[o] = 0 as u8; return o }
called by 2: rw_hasrw_grant calls 1: as_append
86func rw_cap_key(uid: *u8, cap: *u8, out: *u8) -> i64 { var o: i64 = 0; o = as_append(out, o, "reward:cap:" as *u8); o = as_append(out, o, uid); out[o] = 58 as u8; o = o + 1; o = as_append(out, o, cap); out[o] = 0 as u8; return o }
called by 2: rw_canrw_grant calls 1: as_append
87func rw_value_key(uid: *u8, out: *u8) -> i64 { var o: i64 = 0; o = as_append(out, o, "reward:value:" as *u8); o = as_append(out, o, uid); out[o] = 0 as u8; return o }
called by 2: rw_value_totalrw_grant calls 1: as_append
88func rw_earnedids_key(uid: *u8, out: *u8) -> i64 { var o: i64 = 0; o = as_append(out, o, "reward:earnedids:" as *u8); o = as_append(out, o, uid); out[o] = 0 as u8; return o }
called by 2: rw_grantrw_render_rewards calls 1: as_append
90func rw_has(prefix: *u8, uid: *u8, aid: *u8) -> i64
97func rw_value_total(prefix: *u8, uid: *u8) -> i64
105func rw_can(prefix: *u8, uid: *u8, cap: *u8) -> i64
115func rw_grant(prefix: *u8, uid: *u8, aid: *u8, day: i64) -> i64
148func rw_render_rewards(prefix: *u8, uid: *u8, out: *u8) -> i64