Files
windroost/p2_godot_sample/scripts/commission_board.gd
T
wushenghua 6eaebc3cb5 feat: migrate invented numbers to real CH source formulas (numeric provenance)
User: "数值应参考 CH 迁移,不要自己写." Contract 2.2 requires inheriting CH's
formula families and magnitude. Previously relic strength (0.06+tier*0.008),
commission targets/rewards, and partner coefficients were invented. Now:

- cf_formulas.py/.gd: implements CH's real formula families (linear10=0.10*L,
  diminishingReturns, exponential/polynomial1_5 costs) and reads CF source
  tables copied to data/cf_reference/numeric_tables.json (27 relics/30 ancients/
  10 outsiders/6 daily tasks/9 skills). check_cf_formulas_parity PASS 25 cases.
- Relics: strength = CH linear10 @level=tier (0.1..6.0, genuine CH magnitude);
  effect TYPE from CH relic effectDescription keyword (idle->shield, click->
  damage, chest->summon...). 56 combat relic signatures unique.
- Commissions: target steps from CH daily_tasks (kills=50/boss=3/upgrades=5/
  quests=2), reward = CH rubies=5 (crystal) for all.
- Partners: P01=0.10 (CH linear10), P03=0.15 (linear15), P05=0.25 (linear25).
- PRODUCTION/52-cf-numeric-provenance.md documents every number's CH source
  and honestly flags the few remaining new-game tuning parameters.
- Full P2_CHECKS_PASS (93 gates), identity preserved.

Numbers now trace to CH source tables instead of being invented. Owner gates
(human feel/device/release) remain open. prototype/ untracked.
2026-11-19 18:07:26 +08:00

74 lines
2.9 KiB
GDScript

class_name CommissionBoard
extends RefCounted
## GDScript mirror of tools/fullgame/commission_board.py (4 distinct task types).
const TYPES := {
"kill": {"label": "清剿委托", "metric": "battle_wins", "step": 50, "reward": {"crystal": 5}},
"clear": {"label": "推进委托", "metric": "completed_nodes", "step": 3, "reward": {"crystal": 5}},
"build": {"label": "成长委托", "metric": "talent_count", "step": 5, "reward": {"crystal": 5}},
"ascend": {"label": "远征委托", "metric": "prestige_count", "step": 2, "reward": {"crystal": 5}},
}
const ORDER := ["kill", "clear", "build", "ascend"]
const CLAIM_KEY := "commission_board_claims"
static func _num(v) -> int:
if v is int:
return maxi(0, v)
if v is float:
return maxi(0, int(v))
return 0
static func metric_value(profile: Dictionary, metric: String) -> int:
if metric == "talent_count":
var t = profile.get("talents", {})
return (t as Dictionary).size() if t is Dictionary else 0
if metric == "prestige_count":
return _num(profile.get("rebuild_count", 0)) + _num(profile.get("new_sky_count", 0))
if metric == "completed_nodes":
var v = profile.get("completed_nodes", [])
return (v as Array).size() if v is Array else ((v as Dictionary).size() if v is Dictionary else 0)
return _num(profile.get(metric, 0))
static func status(profile: Dictionary) -> Array:
var claims = profile.get(CLAIM_KEY, {})
var out: Array = []
for tid in ORDER:
var spec: Dictionary = TYPES[tid]
var value := metric_value(profile, str(spec["metric"]))
var taken := _num((claims as Dictionary).get(tid, 0)) if claims is Dictionary else 0
var available := maxi(0, value / int(spec["step"]) - taken)
out.append({"type": tid, "label": spec["label"], "metric": spec["metric"],
"step": int(spec["step"]), "progress": value, "tier": taken + 1,
"available": available, "reward": (spec["reward"] as Dictionary).duplicate()})
return out
static func claim(profile: Dictionary, tid: String) -> Dictionary:
var row := {}
for r in status(profile):
if str((r as Dictionary).get("type", "")) == tid:
row = r
break
if row.is_empty() or int(row.get("available", 0)) <= 0:
return {"ok": false, "reason": "no_commission"}
var claims: Dictionary = profile.get(CLAIM_KEY, {})
claims[tid] = _num(claims.get(tid, 0)) + 1
profile[CLAIM_KEY] = claims
var granted := {}
var reward: Dictionary = row["reward"]
for k in reward.keys():
var v := int(reward[k])
if k == "gold":
profile["gold"] = _num(profile.get("gold", 0)) + v; granted["gold"] = v
elif k == "crystal":
profile["crystal"] = _num(profile.get("crystal", 0)) + v; granted["crystal"] = v
elif k == "fragments":
profile["star_fragments"] = _num(profile.get("star_fragments", 0)) + v; granted["fragments"] = v
elif k == "sky_marks":
profile["sky_marks"] = _num(profile.get("sky_marks", 0)) + v; granted["sky_marks"] = v
return {"ok": true, "type": tid, "reward": granted}