Enhance production certificate and election result handling: Updated the logic in run_daily to improve clarity on level progression based on weighted scores, including detailed logging for cases where players meet minimum requirements but do not advance. Introduced a new function to notify players of election results, integrating SQL queries for efficient data retrieval and notification management. Enhanced documentation for the production certificate process to clarify UI vs. daemon discrepancies.
All checks were successful
Deploy yourpart (blue-green) / deploy (push) Successful in 2m54s

This commit is contained in:
Torsten Schulz (local)
2026-04-02 14:48:39 +02:00
parent 619e5e5123
commit 21525ec125
4 changed files with 230 additions and 0 deletions

View File

@@ -81,6 +81,41 @@ pub fn run_daily(base: &BaseWorker, broker: &MessageBroker) -> Result<(), DbErro
house_points,
);
// Hilfe bei „UI sagt bereit, Stufe steigt nicht“: oft Mindestwerte erfüllt, aber
// `raw_target` (gewichtete Wertung) zu niedrig — siehe `docs/FALUKANT_PRODUCTION_CERTIFICATE.md`.
if current < 5 {
let next = current + 1;
if meets_min_for_level(
next,
avg_knowledge,
completed,
office_points,
nobility_points,
reputation_points,
house_points,
) && effective_target < next
&& cert_verbose()
{
eprintln!(
"[falukant_certificate] fu_id={} bleibt auf Stufe {}: Mindestanforderungen für Stufe {} sind erfüllt, aber die gewichtete Wertung {:.3} ergibt raw_target={} (effective_target={}). avg_knowledge={:.2} completed={} kp={} pp={} office={} nob={} rep_p={} house_p={}",
fu_id,
current,
next,
certificate_score,
raw_target,
effective_target,
avg_knowledge,
completed,
knowledge_points,
production_points,
office_points,
nobility_points,
reputation_points,
house_points,
);
}
}
let new_certificate = if effective_target > current {
(current + 1).min(effective_target).min(5)
} else {
@@ -102,6 +137,13 @@ pub fn run_daily(base: &BaseWorker, broker: &MessageBroker) -> Result<(), DbErro
Ok(())
}
fn cert_verbose() -> bool {
matches!(
std::env::var("YPDAEMON_CERT_VERBOSE").map(|v| v == "1" || v.eq_ignore_ascii_case("true")),
Ok(true)
)
}
/// Nach Tod ohne gültigen Erben: Zertifikat auf Stufe 1 (Spec: Erbfolge bricht ab).
pub fn reset_certificate_on_succession_no_heir(
base: &BaseWorker,