Files
gplan-2/game/core/feats_engine.gd
T

53 lines
2.1 KiB
GDScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# VERTICAL SLICE - NOT FOR PRODUCTION
# Date: 2026-10-04(双层 BD 实施批 T1——标签档位激活引擎)
# 流派成型判据机制化(整合定稿 设计工具 1——以撒套装/小骨铭文先例):
# 同流派标签 relic 计数 ≥2 → 档一(流派核心规则);≥4 → 档二(完全体);<2 = 散件(单体保底——
# 每件效果独立生效,档位只做质变不做启动,反例 B-2)。
# 纯函数零 await 零 RNG 零副作用(Attunement 求值服务同款纪律);核心层零特判延伸——引擎只读
# feat_table 行集与持有集,接线点消费 tiers/hooks 投影。
class_name FeatsEngine
extends RefCounted
## 档位求值:feat_ids 持有集 × 行集 → {archetype: tier}(tier ∈ 0/1/2;无行流派不出现)
static func tiers_for(feat_ids: Array, table: FeatTable) -> Dictionary:
var counts := {}
for rid in feat_ids:
var row: Dictionary = table.row_by_id(String(rid)) if table != null else {}
if row.is_empty():
continue
var arch := String(row.get("archetype", ""))
counts[arch] = int(counts.get(arch, 0)) + 1
var out := {}
for arch in counts.keys():
var n := int(counts[arch])
if n >= 4:
out[arch] = 2
elif n >= 2:
out[arch] = 1
else:
out[arch] = 0
return out
## 挂点投影:持有集 → [{feat_id, hook, archetype, tier, effects}](表序稳定——同集合同投影,
## MC 逐位可复放承载)
static func hooks_for(feat_ids: Array, table: FeatTable) -> Array:
var out: Array = []
for rid in feat_ids:
var row: Dictionary = table.row_by_id(String(rid)) if table != null else {}
if row.is_empty():
continue
out.append({
"feat_id": String(row.get("feat_id", "")),
"hook": String(row.get("hook", "")),
"archetype": String(row.get("archetype", "")),
"effects": (row.get("effects", {}) as Dictionary).duplicate(true),
})
return out
## 成型判读(读数面口径):流派 tier ≥1 = 成型(档一即判——任务书完成定义「标签+档位激活引擎可判成型」)
static func is_formed(tiers: Dictionary, archetype: String) -> bool:
return int(tiers.get(archetype, 0)) >= 1