Enhance Falukant family dynamics: Updated the FalukantFamilyWorker to incorporate marriage buffs and detailed age rules for relationships. Added new WebSocket events for real-time updates and expanded SQL queries to support marriage state and buff management, improving overall family interaction and satisfaction tracking.
This commit is contained in:
@@ -2041,7 +2041,11 @@ pub const QUERY_GET_ACTIVE_LOVER_ROWS_FOR_DAILY: &str = r#"
|
||||
COALESCE(c1.reputation, 50)::float8 AS rep1,
|
||||
COALESCE(c2.reputation, 50)::float8 AS rep2,
|
||||
fu1.id AS user1_id,
|
||||
fu2.id AS user2_id
|
||||
fu2.id AS user2_id,
|
||||
LEAST(
|
||||
((CURRENT_DATE - c1.birthdate::date) / 365),
|
||||
((CURRENT_DATE - c2.birthdate::date) / 365)
|
||||
)::int AS min_age_years
|
||||
FROM falukant_data.relationship r
|
||||
JOIN falukant_type.relationship rt
|
||||
ON rt.id = r.relationship_type_id AND rt.tr = 'lover'
|
||||
@@ -2080,7 +2084,11 @@ pub const QUERY_GET_ACTIVE_LOVER_ROWS_FOR_MONTHLY: &str = r#"
|
||||
COALESCE(c1.reputation, 50)::float8 AS rep1,
|
||||
COALESCE(c2.reputation, 50)::float8 AS rep2,
|
||||
fu1.id AS user1_id,
|
||||
fu2.id AS user2_id
|
||||
fu2.id AS user2_id,
|
||||
LEAST(
|
||||
((CURRENT_DATE - c1.birthdate::date) / 365),
|
||||
((CURRENT_DATE - c2.birthdate::date) / 365)
|
||||
)::int AS min_age_years
|
||||
FROM falukant_data.relationship r
|
||||
JOIN falukant_type.relationship rt
|
||||
ON rt.id = r.relationship_type_id AND rt.tr = 'lover'
|
||||
@@ -2124,16 +2132,25 @@ pub const QUERY_GET_MARRIAGE_ROWS: &str = r#"
|
||||
r.marriage_drift_high,
|
||||
r.marriage_drift_low,
|
||||
COALESCE(t1.tr, '') AS title1_tr,
|
||||
COALESCE(t2.tr, '') AS title2_tr
|
||||
COALESCE(t2.tr, '') AS title2_tr,
|
||||
fu1.id AS user1_id,
|
||||
fu2.id AS user2_id,
|
||||
COALESCE(r.marriage_gift_buff_days_remaining, 0)::int AS marriage_gift_buff_days_remaining,
|
||||
COALESCE(r.marriage_pending_feast_bonus, 0)::int AS marriage_pending_feast_bonus,
|
||||
COALESCE(r.marriage_house_supply, 50)::int AS marriage_house_supply,
|
||||
COALESCE(r.marriage_no_lover_bonus_counter, 0)::int AS marriage_no_lover_bonus_counter
|
||||
FROM falukant_data.relationship r
|
||||
JOIN falukant_type.relationship rt ON rt.id = r.relationship_type_id
|
||||
AND rt.tr IN ('married', 'engaged', 'wooing')
|
||||
JOIN falukant_data.character c1 ON c1.id = r.character1_id
|
||||
JOIN falukant_data.character c2 ON c2.id = r.character2_id
|
||||
LEFT JOIN falukant_type.title t1 ON t1.id = c1.title_of_nobility
|
||||
LEFT JOIN falukant_type.title t2 ON t2.id = c2.title_of_nobility;
|
||||
LEFT JOIN falukant_type.title t2 ON t2.id = c2.title_of_nobility
|
||||
LEFT JOIN falukant_data.falukant_user fu1 ON fu1.id = c1.user_id
|
||||
LEFT JOIN falukant_data.falukant_user fu2 ON fu2.id = c2.user_id;
|
||||
"#;
|
||||
|
||||
#[allow(dead_code)] // Einfaches Update ohne Buff-Spalten; Daemon nutzt QUERY_UPDATE_MARRIAGE_STATE_AND_BUFFS.
|
||||
pub const QUERY_UPDATE_MARRIAGE_STATE: &str = r#"
|
||||
UPDATE falukant_data.relationship
|
||||
SET marriage_satisfaction = $1::smallint,
|
||||
@@ -2142,6 +2159,18 @@ pub const QUERY_UPDATE_MARRIAGE_STATE: &str = r#"
|
||||
WHERE id = $4::int;
|
||||
"#;
|
||||
|
||||
/// Inkl. Geschenk-/Fest-/Haus-Zähler (Migration `003_falukant_family_marriage_buffs.sql`).
|
||||
pub const QUERY_UPDATE_MARRIAGE_STATE_AND_BUFFS: &str = r#"
|
||||
UPDATE falukant_data.relationship
|
||||
SET marriage_satisfaction = $1::smallint,
|
||||
marriage_drift_high = $2::smallint,
|
||||
marriage_drift_low = $3::smallint,
|
||||
marriage_gift_buff_days_remaining = $4::smallint,
|
||||
marriage_pending_feast_bonus = $5::smallint,
|
||||
marriage_no_lover_bonus_counter = $6::smallint
|
||||
WHERE id = $7::int;
|
||||
"#;
|
||||
|
||||
pub const QUERY_MARRIAGE_SUBTRACT_SATISFACTION: &str = r#"
|
||||
UPDATE falukant_data.relationship r
|
||||
SET marriage_satisfaction = GREATEST(0, r.marriage_satisfaction - $2::int)
|
||||
|
||||
Reference in New Issue
Block a user