refactor(packages): 0.R5 - the rest of the lazy starts are defaults - hints' rail (sized by hints_config), lab's CRC table, rpg's crafting / items / inventory / quests / dialog, shooter's weapons, prefs, and npc's and gameplay's empty ensures gone; gameplay's faction table sits beside its state, since a default names only what is declared before it; --tighten over their tests and examples
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
9e4f4edb92
commit
f516148e46
15 changed files with 73 additions and 169 deletions
|
|
@ -23,10 +23,14 @@ event Died { e: int = 0, src: int = 0 }
|
|||
event Healed { e: int = 0, amount: int = 0 }
|
||||
event Crit { target: int = 0, src: int = 0 } # the attacker's crit_pct fired
|
||||
|
||||
# the faction table: FAC_MAX ids square, every pair unset (faction.ludic)
|
||||
const FAC_MAX: int = 32
|
||||
function fac_table() -> words { return words(FAC_MAX * FAC_MAX) }
|
||||
|
||||
state GameplayState {
|
||||
combat_reflecting: bool = false # thorns never reflect thorns
|
||||
combat_pending: int = 0
|
||||
fac_tbl: words = words(FAC_MAX * FAC_MAX)
|
||||
fac_tbl: words = fac_table()
|
||||
}
|
||||
|
||||
# the mutable channel for lever 6: listeners rewrite the pending damage here.
|
||||
|
|
|
|||
|
|
@ -9,20 +9,14 @@
|
|||
|
||||
property Faction { id: int = 0 }
|
||||
|
||||
const FAC_MAX: int = 32
|
||||
const REL_FRIEND: int = 0
|
||||
const REL_NEUTRAL: int = 1
|
||||
const REL_HOSTILE: int = 2
|
||||
|
||||
# relationships stored as (rel + 1); a zero slot means "unset -> use the default".
|
||||
# A global var initialiser must be a literal, so it is allocated lazily.
|
||||
|
||||
function fac_ensure(gameplay_st: mut GameplayState) -> void {
|
||||
}
|
||||
# relationships stored as (rel + 1); a zero slot means "unset -> use the default"
|
||||
|
||||
# Faction.set(a, b, rel) — record a symmetric relationship between two factions.
|
||||
@Namespace(Faction) function faction_set(gameplay_st: mut GameplayState, a: int, b: int, rel: int) -> void {
|
||||
fac_ensure(gameplay_st)
|
||||
if (a < 0) or (a >= FAC_MAX) { return }
|
||||
if (b < 0) or (b >= FAC_MAX) { return }
|
||||
gameplay_st.fac_tbl[a * FAC_MAX + b] = rel + 1
|
||||
|
|
@ -31,7 +25,6 @@ function fac_ensure(gameplay_st: mut GameplayState) -> void {
|
|||
|
||||
# Faction.rel(a, b) — the relationship code (0 friend, 1 neutral, 2 hostile).
|
||||
@Namespace(Faction) function faction_rel(gameplay_st: mut GameplayState, a: int, b: int) -> int {
|
||||
fac_ensure(gameplay_st)
|
||||
if (a >= 0) and (a < FAC_MAX) and (b >= 0) and (b < FAC_MAX) {
|
||||
let v = gameplay_st.fac_tbl[a * FAC_MAX + b]
|
||||
if v != 0 { return v - 1 }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue