Füge Logik zur Berechnung von Reputation und Ehezufriedenheit basierend auf Liebschaften hinzu: Implementiere Funktionen zur Bewertung der Standsgruppe und zur Berechnung täglicher Deltas für Reputation und Ehezufriedenheit, um die Auswirkungen von Liebschaften auf die Beziehungen zu berücksichtigen.
All checks were successful
Deploy yourpart (blue-green) / deploy (push) Successful in 1m30s
All checks were successful
Deploy yourpart (blue-green) / deploy (push) Successful in 1m30s
This commit is contained in:
@@ -251,10 +251,15 @@ impl FalukantFamilyWorker {
|
||||
}
|
||||
|
||||
conn.prepare("upd_vd", QUERY_UPDATE_LOVER_VISIBILITY_DISCRETION)?;
|
||||
conn.prepare("upd_rep", QUERY_UPDATE_CHARACTER_REPUTATION)?;
|
||||
conn.prepare("deactivate_lover", QUERY_DEACTIVATE_LOVER_RELATIONSHIP)?;
|
||||
let mut ended_rel_ids: HashSet<i32> = HashSet::new();
|
||||
let mut breakup_socket_users: HashSet<i32> = HashSet::new();
|
||||
let mut breakup_risk_notified: HashSet<(i32, i32)> = HashSet::new();
|
||||
|
||||
// Sammeln von Ehepartner-Charakteren für Ehezufriedenheits-Deltas
|
||||
let mut spouse_satisfaction_delta: HashMap<i32, i32> = HashMap::new();
|
||||
|
||||
for l in &mut lovers {
|
||||
let ehe_conflict = marriages.iter().any(|m| {
|
||||
(m.m1 == l.c1 || m.m2 == l.c1 || m.m1 == l.c2 || m.m2 == l.c2) && m.satisfaction < 40
|
||||
@@ -302,6 +307,33 @@ impl FalukantFamilyWorker {
|
||||
l.visibility = new_vis;
|
||||
l.discretion = new_disc;
|
||||
|
||||
// Standsabhängige Auswirkungen auf Reputation der Liebhaber
|
||||
let rep_delta = calculate_lover_reputation_delta(l);
|
||||
if rep_delta.abs() > 0.01 {
|
||||
// Reputation beider Liebhaber erhöhen/senken
|
||||
for cid in [l.c1, l.c2] {
|
||||
if cid > 0 {
|
||||
let rep_s = format!("{:.2}", rep_delta);
|
||||
// Nutzen des UPDATE CHARACTER ... reputation = reputation + $1 Pattern
|
||||
let _ = conn.execute("upd_rep", &[&rep_s, &cid]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Standsabhängige Auswirkungen auf Ehezufriedenheit sammeln
|
||||
let marriage_sat_delta = calculate_lover_marriage_satisfaction_delta(l);
|
||||
if marriage_sat_delta != 0 {
|
||||
// Sammeln der Ehepartnerschaften, auf die diese Liebschaft Einfluss hat
|
||||
for spouse_char_id in [l.c1, l.c2] {
|
||||
let spouse_marriage = marriages.iter().find(|m| {
|
||||
m.m1 == spouse_char_id || m.m2 == spouse_char_id
|
||||
});
|
||||
if let Some(m) = spouse_marriage {
|
||||
*spouse_satisfaction_delta.entry(m.id).or_insert(0) += marriage_sat_delta;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Je niedriger die Zuneigung, desto höher das tägliche Trennungsrisiko.
|
||||
let breakup_risk_pct = breakup_risk_percent(l);
|
||||
if breakup_risk_pct > 50.0 {
|
||||
@@ -423,6 +455,10 @@ impl FalukantFamilyWorker {
|
||||
if touching.iter().any(|l| l.min_age_years <= 15) {
|
||||
delta -= 1;
|
||||
}
|
||||
// Standsabhängige Deltas aus der Liebschaften-Verarbeitung anwenden
|
||||
if let Some(extra_delta) = spouse_satisfaction_delta.get(&m.id) {
|
||||
delta += extra_delta;
|
||||
}
|
||||
sat = clamp_i32(sat + delta, 0, 100);
|
||||
}
|
||||
|
||||
@@ -1291,6 +1327,88 @@ fn visibility_young_penalty(min_age_years: i32, visibility: i32) -> f64 {
|
||||
}
|
||||
}
|
||||
|
||||
/// Bewertet die Standsgruppe basierend auf Titeln der beiden Liebhaber.
|
||||
/// Rückgabe: 0 = niedrig (noncivil/civil), 1 = mittel (townlord/etc.), 2+ = hoch (knight/etc.).
|
||||
fn lover_status_category(title1: &str, title2: &str) -> u8 {
|
||||
let t1 = title_group(title1);
|
||||
let t2 = title_group(title2);
|
||||
let max_group = t1.max(t2);
|
||||
// Vereinfacht: 0 -> "niedrig", 1 -> "mittel", 2+ -> "hoch"
|
||||
if max_group >= 2 {
|
||||
2 // hoch (knight, baron, count, ruler, etc.)
|
||||
} else if max_group == 1 {
|
||||
1 // mittel (townlord, by, landlord)
|
||||
} else {
|
||||
0 // niedrig (noncivil, civil, sir)
|
||||
}
|
||||
}
|
||||
|
||||
/// Berechnet tägl. Reputations-Delta basierend auf Stand, Sichtbarkeit und Status der Liebschaft.
|
||||
/// Regel:
|
||||
/// - Hoher Stand: +Reputation (unabhängig von Sichtbarkeit)
|
||||
/// - Mittlerer Stand: +Reputation wenn heimlich/diskret, -Reputation wenn öffentlich
|
||||
/// - Niedriger Stand: neutral wenn heimlich, -Reputation wenn öffentlich
|
||||
fn calculate_lover_reputation_delta(l: &LoverData) -> f64 {
|
||||
let category = lover_status_category(&l.title1_tr, &l.title2_tr);
|
||||
let is_public = l.visibility >= 60; // öffentlich wenn hohe Sichtbarkeit
|
||||
|
||||
match category {
|
||||
2 => {
|
||||
// Hoher Stand: immer +0,5 pro Tag (positiv)
|
||||
0.5
|
||||
}
|
||||
1 => {
|
||||
// Mittlerer Stand: heimlich +0,3, öffentlich -0,4
|
||||
if is_public {
|
||||
-0.4
|
||||
} else {
|
||||
0.3
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
// Niedriger Stand: heimlich/diskret 0, öffentlich -0,5
|
||||
if is_public {
|
||||
-0.5
|
||||
} else {
|
||||
0.0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Berechnet tägl. Ehezufriedenheits-Delta für Ehe-Partner, wenn dieser eine Liebschaft hat.
|
||||
/// Regel:
|
||||
/// - Hoher Stand: +Zufriedenheit (sogar öffentliche Liebschaften sind akzeptabel)
|
||||
/// - Mittlerer Stand: +Zufriedenheit wenn heimlich, -Zufriedenheit wenn öffentlich
|
||||
/// - Niedriger Stand: neutral wenn heimlich, -Zufriedenheit wenn öffentlich
|
||||
fn calculate_lover_marriage_satisfaction_delta(l: &LoverData) -> i32 {
|
||||
let category = lover_status_category(&l.title1_tr, &l.title2_tr);
|
||||
let is_public = l.visibility >= 60;
|
||||
|
||||
match category {
|
||||
2 => {
|
||||
// Hoher Stand: +1 pro Tag (Liebschaft ist gesellschaftlich akzeptabel/vorteilhaft)
|
||||
1
|
||||
}
|
||||
1 => {
|
||||
// Mittlerer Stand: +0 wenn heimlich, -2 wenn öffentlich (Skandal)
|
||||
if is_public {
|
||||
-2
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
// Niedriger Stand: 0 wenn heimlich, -1 wenn öffentlich
|
||||
if is_public {
|
||||
-1
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn breakup_risk_percent(l: &LoverData) -> f64 {
|
||||
if l.affection >= 45 {
|
||||
return 0.0;
|
||||
|
||||
Reference in New Issue
Block a user