Implement political benefits management in FalukantFamilyWorker and SQL: Introduced a new structure for handling lover relationships, including political slots and reputation ticks. Updated SQL queries to support political benefits, ensuring proper handling of appointments and reputation gains. Enhanced the FalukantFamilyWorker logic to manage free political slots and maintain relationships effectively. Improved documentation for clarity on the new political benefits features and their integration into the existing system.
All checks were successful
Deploy yourpart (blue-green) / deploy (push) Successful in 2m55s

This commit is contained in:
Torsten Schulz (local)
2026-04-02 15:46:37 +02:00
parent 21525ec125
commit ac024a8d14
7 changed files with 441 additions and 11 deletions

View File

@@ -0,0 +1,43 @@
-- Daemon: Amtsvorteile (reputation_periodic Ticks, optional Ernennungs-Ablauf)
-- Voraussetzung: Backend-Seeds `falukant_predefine.political_office_benefit` + ggf. `falukant_type.political_office_benefit_type`
CREATE TABLE IF NOT EXISTS falukant_data.political_benefit_last_tick (
id SERIAL PRIMARY KEY,
character_id INTEGER NOT NULL
REFERENCES falukant_data.character (id) ON DELETE CASCADE,
political_office_benefit_id INTEGER NOT NULL,
last_tick_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
ticks_count INTEGER NOT NULL DEFAULT 0,
CONSTRAINT uq_political_benefit_last_tick UNIQUE (character_id, political_office_benefit_id)
);
CREATE INDEX IF NOT EXISTS idx_political_benefit_last_tick_character
ON falukant_data.political_benefit_last_tick (character_id);
COMMENT ON TABLE falukant_data.political_benefit_last_tick IS
'Letzter reputation_periodic-Tick pro (Charakter × Benefit-Zeile aus political_office_benefit); Daemon: YpDaemon political_benefits.rs';
-- Optional: Spieler-Ernennungen (Backend legt Zeilen an; Daemon setzt nur abgelaufen)
CREATE TABLE IF NOT EXISTS falukant_data.political_appointment (
id SERIAL PRIMARY KEY,
appointer_character_id INTEGER NOT NULL
REFERENCES falukant_data.character (id) ON DELETE CASCADE,
target_character_id INTEGER
REFERENCES falukant_data.character (id) ON DELETE SET NULL,
office_type_id INTEGER NOT NULL
REFERENCES falukant_type.political_office_type (id),
region_id INTEGER NOT NULL
REFERENCES falukant_data.region (id),
status TEXT NOT NULL DEFAULT 'pending',
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
expires_at TIMESTAMPTZ,
completed_office_id INTEGER
REFERENCES falukant_data.political_office (id) ON DELETE SET NULL
);
CREATE INDEX IF NOT EXISTS idx_political_appointment_status_expires
ON falukant_data.political_appointment (status, expires_at);
COMMENT ON TABLE falukant_data.political_appointment IS
'Ernennungen (Backend); Daemon markiert pending → expired wenn expires_at überschritten';

View File

@@ -19,3 +19,13 @@ Nur nötig, wenn **`001`** bereits mit den **alten** Spaltennamen (`consecutive_
**Backend (YourPart3):** Beim Anlegen einer `lover`-Beziehung `relationship_state` erzeugen; Ehezufriedenheit liegt auf **`relationship`** (married / engaged / wooing); Idempotenzfelder `last_daily_processed_at` / `last_monthly_processed_at` werden vom Daemon gesetzt.
Ohne passende Spalten (`last_daily_processed_at`) bleibt der Family-Worker inaktiv.
## `012_falukant_political_benefits_daemon.sql`
Tabellen **`political_benefit_last_tick`** und optional **`political_appointment`** für den **`PoliticsWorker`** / Modul `political_benefits.rs`:
- **`reputation_periodic`**: Ticks mit Persistenz (benötigt Backend-Seeds `falukant_predefine.political_office_benefit` mit JSON-Feldern `tr` oder `benefitType`, `gain`, `intervalDays`).
- **`free_lover_slots`**: Summe `count` im Liebschafts-Monatstick (Daemon), max. 5.
- **Ernennungen**: Daemon setzt nur `pending``expired`, wenn `expires_at` überschritten (Anlage durch Backend-API).
Die Join-Spalte auf `political_office_benefit` heißt im Repo **`political_office_type_id`** — falls das Sequelize-Modell abweicht, SQL in `src/worker/sql.rs` anpassen.