multiple fixes
Some checks failed
Deploy yourpart (blue-green) / deploy (push) Has been cancelled

This commit is contained in:
Torsten Schulz (local)
2026-06-22 16:17:20 +02:00
parent 41c0e5a6f2
commit 6ed88f7ad7
2 changed files with 31 additions and 135 deletions

View File

@@ -266,6 +266,9 @@ impl FalukantFamilyWorker {
}); });
let mut v_net = 0i32; let mut v_net = 0i32;
if l.min_age_years <= 12 {
v_net += 3;
}
if l.maintenance_level < 35 { if l.maintenance_level < 35 {
v_net += 1; v_net += 1;
} }
@@ -289,6 +292,9 @@ impl FalukantFamilyWorker {
let new_vis = clamp_i32(l.visibility + v_net, 0, 100); let new_vis = clamp_i32(l.visibility + v_net, 0, 100);
let mut d_net = 0i32; let mut d_net = 0i32;
if l.min_age_years <= 12 {
d_net -= 3;
}
if l.maintenance_level >= 70 { if l.maintenance_level >= 70 {
d_net += 1; d_net += 1;
} }
@@ -452,8 +458,8 @@ impl FalukantFamilyWorker {
{ {
delta -= 1; delta -= 1;
} }
if touching.iter().any(|l| l.min_age_years <= 15) { if touching.iter().any(|l| l.min_age_years <= 12) {
delta -= 1; delta -= 4;
} }
// Standsabhängige Deltas aus der Liebschaften-Verarbeitung anwenden // Standsabhängige Deltas aus der Liebschaften-Verarbeitung anwenden
if let Some(extra_delta) = spouse_satisfaction_delta.get(&m.id) { if let Some(extra_delta) = spouse_satisfaction_delta.get(&m.id) {
@@ -499,8 +505,8 @@ impl FalukantFamilyWorker {
if (g1 as i32 - g2 as i32).abs() >= 2 { if (g1 as i32 - g2 as i32).abs() >= 2 {
pst -= 1; pst -= 1;
} }
if touching.iter().any(|l| l.min_age_years <= 15) { if touching.iter().any(|l| l.min_age_years <= 12) {
pst -= 2; pst -= 4;
} }
let ho_avg = (m.household_order_1 + m.household_order_2) / 2; let ho_avg = (m.household_order_1 + m.household_order_2) / 2;
if ho_avg < 35 { if ho_avg < 35 {
@@ -1307,12 +1313,10 @@ fn rank_rep_modifier(g: u8, scandal: bool, order_ok: bool) -> f64 {
/// Spec 5a: Altersmalus (jüngeres Alter der Beteiligten), zusätzlich zur Basis-Reputation. /// Spec 5a: Altersmalus (jüngeres Alter der Beteiligten), zusätzlich zur Basis-Reputation.
fn age_reputation_delta(min_age_years: i32) -> f64 { fn age_reputation_delta(min_age_years: i32) -> f64 {
if min_age_years <= 13 { if min_age_years <= 10 {
-1.5 -6.0
} else if min_age_years <= 15 { } else if min_age_years <= 12 {
-0.8 -3.0
} else if min_age_years <= 17 {
-0.3
} else { } else {
0.0 0.0
} }
@@ -1320,8 +1324,10 @@ fn age_reputation_delta(min_age_years: i32) -> f64 {
/// Spec 5a: minAge <= 15 und hohe Sichtbarkeit. /// Spec 5a: minAge <= 15 und hohe Sichtbarkeit.
fn visibility_young_penalty(min_age_years: i32, visibility: i32) -> f64 { fn visibility_young_penalty(min_age_years: i32, visibility: i32) -> f64 {
if min_age_years <= 15 && visibility >= 50 { if min_age_years <= 10 && visibility >= 20 {
-0.5 -4.0
} else if min_age_years <= 12 && visibility >= 25 {
-2.0
} else { } else {
0.0 0.0
} }
@@ -1414,12 +1420,10 @@ fn breakup_risk_percent(l: &LoverData) -> f64 {
/// Spec Skandalrisiko: stufenweise Zusatz (exklusiv). /// Spec Skandalrisiko: stufenweise Zusatz (exklusiv).
fn scandal_age_extra_pct(min_age_years: i32) -> f64 { fn scandal_age_extra_pct(min_age_years: i32) -> f64 {
if min_age_years <= 13 { if min_age_years <= 10 {
6.0 12.0
} else if min_age_years <= 15 { } else if min_age_years <= 12 {
3.0 8.0
} else if min_age_years <= 17 {
1.0
} else { } else {
0.0 0.0
} }

View File

@@ -2161,13 +2161,7 @@ pub const QUERY_TRY_MARRIAGE_CONCEPTION_UPDATE: &str = r#"
CASE WHEN c1.gender = 'male' THEN c1.region_id ELSE c2.region_id END AS region_id, CASE WHEN c1.gender = 'male' THEN c1.region_id ELSE c2.region_id END AS region_id,
CASE WHEN c1.gender = 'male' THEN fu1.id ELSE fu2.id END AS father_uid, CASE WHEN c1.gender = 'male' THEN fu1.id ELSE fu2.id END AS father_uid,
CASE WHEN c1.gender = 'female' THEN fu1.id ELSE fu2.id END AS mother_uid, CASE WHEN c1.gender = 'female' THEN fu1.id ELSE fu2.id END AS mother_uid,
(CURRENT_DATE - c_female.birthdate::date)::int AS mother_age_days, (CURRENT_DATE - c_female.birthdate::date)::int AS mother_age_days
(
SELECT COUNT(*)::int
FROM falukant_data.child_relation cr
WHERE cr.father_character_id = (CASE WHEN c1.gender = 'male' THEN c1.id ELSE c2.id END)
AND cr.mother_character_id = (CASE WHEN c1.gender = 'female' THEN c1.id ELSE c2.id END)
) AS shared_children_count
FROM falukant_data.relationship r FROM falukant_data.relationship r
JOIN falukant_type.relationship r2 JOIN falukant_type.relationship r2
ON r2.id = r.relationship_type_id AND r2.tr = 'married' ON r2.id = r.relationship_type_id AND r2.tr = 'married'
@@ -2194,58 +2188,13 @@ pub const QUERY_TRY_MARRIAGE_CONCEPTION_UPDATE: &str = r#"
p.father_uid, p.father_uid,
p.mother_uid, p.mother_uid,
p.mother_age_days, p.mother_age_days,
p.shared_children_count, 0.72::float AS prob_year
CASE
WHEN p.mother_age_days < 4380 THEN 0.005
WHEN p.mother_age_days < 4745 THEN 0.30
WHEN p.mother_age_days < 5110 THEN 0.45
WHEN p.mother_age_days < 5475 THEN 0.55
WHEN p.mother_age_days < 5840 THEN 0.60
WHEN p.mother_age_days < 6205 THEN 0.725
WHEN p.mother_age_days < 6570 THEN 0.80
WHEN p.mother_age_days < 7305 THEN 0.855
WHEN p.mother_age_days < 9125 THEN 0.875
WHEN p.mother_age_days < 10950 THEN 0.84
WHEN p.mother_age_days < 11315 THEN 0.785
WHEN p.mother_age_days < 11680 THEN 0.765
WHEN p.mother_age_days < 12045 THEN 0.74
WHEN p.mother_age_days < 12410 THEN 0.72
WHEN p.mother_age_days < 12775 THEN 0.695
WHEN p.mother_age_days < 13140 THEN 0.65
WHEN p.mother_age_days < 13505 THEN 0.63
WHEN p.mother_age_days < 13870 THEN 0.60
WHEN p.mother_age_days < 14235 THEN 0.55
WHEN p.mother_age_days < 14600 THEN 0.50
WHEN p.mother_age_days < 14965 THEN 0.45
WHEN p.mother_age_days < 15330 THEN 0.35
WHEN p.mother_age_days < 15695 THEN 0.25
WHEN p.mother_age_days < 16060 THEN 0.15
WHEN p.mother_age_days < 16425 THEN 0.075
WHEN p.mother_age_days < 16790 THEN 0.03
WHEN p.mother_age_days < 17155 THEN 0.02
WHEN p.mother_age_days < 17520 THEN 0.015
WHEN p.mother_age_days < 18250 THEN 0.005
ELSE 0.001
END AS prob_year_raw
FROM paired p FROM paired p
), ),
mother_age_final AS (
SELECT
ma.*,
CASE
WHEN ma.shared_children_count = 0
AND ma.mother_age_days >= 6570
AND ma.mother_age_days < 16000
THEN GREATEST(ma.prob_year_raw, 1.0)
ELSE ma.prob_year_raw
END AS prob_year
FROM mother_age ma
),
conceivable AS ( conceivable AS (
SELECT ma.relationship_id SELECT ma.relationship_id
FROM mother_age_final ma FROM mother_age ma
WHERE ma.mother_age_days >= 4380 WHERE ma.mother_age_days >= 5110
AND ma.mother_age_days < 18993
AND random() < ma.prob_year AND random() < ma.prob_year
) )
UPDATE falukant_data.relationship r UPDATE falukant_data.relationship r
@@ -2275,13 +2224,7 @@ pub const QUERY_GET_LEGACY_MARRIAGE_INSTANT_PREGNANCY_CANDIDATES: &str = r#"
CASE WHEN c1.gender = 'male' THEN c1.region_id ELSE c2.region_id END AS region_id, CASE WHEN c1.gender = 'male' THEN c1.region_id ELSE c2.region_id END AS region_id,
CASE WHEN c1.gender = 'male' THEN fu1.id ELSE fu2.id END AS father_uid, CASE WHEN c1.gender = 'male' THEN fu1.id ELSE fu2.id END AS father_uid,
CASE WHEN c1.gender = 'female' THEN fu1.id ELSE fu2.id END AS mother_uid, CASE WHEN c1.gender = 'female' THEN fu1.id ELSE fu2.id END AS mother_uid,
(CURRENT_DATE - c_female.birthdate::date)::int AS mother_age_days, (CURRENT_DATE - c_female.birthdate::date)::int AS mother_age_days
(
SELECT COUNT(*)::int
FROM falukant_data.child_relation cr
WHERE cr.father_character_id = (CASE WHEN c1.gender = 'male' THEN c1.id ELSE c2.id END)
AND cr.mother_character_id = (CASE WHEN c1.gender = 'female' THEN c1.id ELSE c2.id END)
) AS shared_children_count
FROM falukant_data.relationship r FROM falukant_data.relationship r
JOIN falukant_type.relationship r2 JOIN falukant_type.relationship r2
ON r2.id = r.relationship_type_id AND r2.tr = 'married' ON r2.id = r.relationship_type_id AND r2.tr = 'married'
@@ -2312,52 +2255,8 @@ pub const QUERY_GET_LEGACY_MARRIAGE_INSTANT_PREGNANCY_CANDIDATES: &str = r#"
p.father_uid, p.father_uid,
p.mother_uid, p.mother_uid,
p.mother_age_days, p.mother_age_days,
p.shared_children_count, 0.72::float AS prob_year
CASE
WHEN p.mother_age_days < 4380 THEN 0.005
WHEN p.mother_age_days < 4745 THEN 0.30
WHEN p.mother_age_days < 5110 THEN 0.45
WHEN p.mother_age_days < 5475 THEN 0.55
WHEN p.mother_age_days < 5840 THEN 0.60
WHEN p.mother_age_days < 6205 THEN 0.725
WHEN p.mother_age_days < 6570 THEN 0.80
WHEN p.mother_age_days < 7305 THEN 0.855
WHEN p.mother_age_days < 9125 THEN 0.875
WHEN p.mother_age_days < 10950 THEN 0.84
WHEN p.mother_age_days < 11315 THEN 0.785
WHEN p.mother_age_days < 11680 THEN 0.765
WHEN p.mother_age_days < 12045 THEN 0.74
WHEN p.mother_age_days < 12410 THEN 0.72
WHEN p.mother_age_days < 12775 THEN 0.695
WHEN p.mother_age_days < 13140 THEN 0.65
WHEN p.mother_age_days < 13505 THEN 0.63
WHEN p.mother_age_days < 13870 THEN 0.60
WHEN p.mother_age_days < 14235 THEN 0.55
WHEN p.mother_age_days < 14600 THEN 0.50
WHEN p.mother_age_days < 14965 THEN 0.45
WHEN p.mother_age_days < 15330 THEN 0.35
WHEN p.mother_age_days < 15695 THEN 0.25
WHEN p.mother_age_days < 16060 THEN 0.15
WHEN p.mother_age_days < 16425 THEN 0.075
WHEN p.mother_age_days < 16790 THEN 0.03
WHEN p.mother_age_days < 17155 THEN 0.02
WHEN p.mother_age_days < 17520 THEN 0.015
WHEN p.mother_age_days < 18250 THEN 0.005
ELSE 0.001
END AS prob_year_raw
FROM paired p FROM paired p
),
mother_age_final AS (
SELECT
ma.*,
CASE
WHEN ma.shared_children_count = 0
AND ma.mother_age_days >= 6570
AND ma.mother_age_days < 16000
THEN GREATEST(ma.prob_year_raw, 1.0)
ELSE ma.prob_year_raw
END AS prob_year
FROM mother_age ma
) )
SELECT SELECT
father_cid, father_cid,
@@ -2369,9 +2268,8 @@ pub const QUERY_GET_LEGACY_MARRIAGE_INSTANT_PREGNANCY_CANDIDATES: &str = r#"
mother_uid, mother_uid,
mother_age_days, mother_age_days,
prob_year * 100.0 AS prob_pct prob_year * 100.0 AS prob_pct
FROM mother_age_final FROM mother_age
WHERE mother_age_days >= 4380 WHERE mother_age_days >= 5110
AND mother_age_days < 18993
AND random() < prob_year; AND random() < prob_year;
"#; "#;
@@ -3927,8 +3825,7 @@ pub const QUERY_GET_LOVER_PREGNANCY_CANDIDATES: &str = r#"
WHERE cr.mother_character_id = c_female.id WHERE cr.mother_character_id = c_female.id
AND cr.created_at::date = CURRENT_DATE AND cr.created_at::date = CURRENT_DATE
) )
AND (CURRENT_DATE - c_female.birthdate::date) >= 4380 AND (CURRENT_DATE - c_female.birthdate::date) >= 5110
AND (CURRENT_DATE - c_female.birthdate::date) < 18993
AND random() * 100.0 < ( AND random() * 100.0 < (
LEAST(12.0, GREATEST(0.0, LEAST(12.0, GREATEST(0.0,
CASE rs.lover_role CASE rs.lover_role
@@ -3939,11 +3836,6 @@ pub const QUERY_GET_LOVER_PREGNANCY_CANDIDATES: &str = r#"
END END
+ CASE WHEN rs.affection >= 75 THEN 2.0 ELSE 0.0 END + CASE WHEN rs.affection >= 75 THEN 2.0 ELSE 0.0 END
+ CASE WHEN rs.visibility >= 70 AND rs.affection < 50 THEN -2.0 ELSE 0.0 END + CASE WHEN rs.visibility >= 70 AND rs.affection < 50 THEN -2.0 ELSE 0.0 END
+ CASE
WHEN (CURRENT_DATE - c_female.birthdate::date) > 14600
THEN -3.0
ELSE 0.0
END
)) ))
); );
"#; "#;