class_name DropTable extends RefCounted ## Loot drop system. Chance-based artifact drops from boss kills. ## Flat 25% drop rate for all artifacts. No rarity gating. var _drop_chance: float = 0.25 # 25% base chance per kill # Each boss has a pool of possible artifact drops. # Structure: { "boss_id": String, "pool": Array[String] (artifact IDs) } var _boss_pools: Dictionary = {} ## Registers a boss's drop pool. func register_boss_pool(boss_id: String, artifact_ids: Array[String]) -> void: _boss_pools[boss_id] = artifact_ids ## Sets the global drop chance (for testing or future tuning). func set_drop_chance(chance: float) -> void: _drop_chance = clampf(chance, 0.0, 1.0) ## Rolls for a drop from a specific boss. ## rng: Optional RandomNumberGenerator for testability. ## Returns a result dictionary: ## { "dropped": bool, "artifact_id": String (empty if no drop) } func roll_drop(boss_id: String, rng: RandomNumberGenerator = null) -> Dictionary: if rng == null: rng = RandomNumberGenerator.new() # Check if this boss has a pool if not _boss_pools.has(boss_id): return {"dropped": false, "artifact_id": ""} var pool: Array[String] = _boss_pools[boss_id] if pool.is_empty(): return {"dropped": false, "artifact_id": ""} # Roll for drop chance if rng.randf() >= _drop_chance: return {"dropped": false, "artifact_id": ""} # Drop succeeded — pick random artifact from pool var index := rng.randi_range(0, pool.size() - 1) return {"dropped": true, "artifact_id": pool[index]} ## Returns the drop pool for a boss (for UI/debugging). func get_boss_pool(boss_id: String) -> Array[String]: if _boss_pools.has(boss_id): return _boss_pools[boss_id] return [] ## Returns the current drop chance. func get_drop_chance() -> float: return _drop_chance