Refactor EventsWorker: Move EVENT_RATE_SCALE constant to the struct for better encapsulation and clarity in event probability calculations.
This commit is contained in:
@@ -83,9 +83,6 @@ struct StorageDamageInfo {
|
||||
}
|
||||
|
||||
impl EventsWorker {
|
||||
// Globaler Skalierungsfaktor für Ereignisfrequenz (1.0 = unverändert).
|
||||
// Setze auf 0.05, um Ereignisse auf 1/20 der ursprünglichen Häufigkeit zu reduzieren.
|
||||
const EVENT_RATE_SCALE: f64 = 0.05;
|
||||
pub fn new(pool: ConnectionPool, broker: MessageBroker) -> Self {
|
||||
Self {
|
||||
base: BaseWorker::new("EventsWorker", pool, broker),
|
||||
@@ -385,7 +382,7 @@ impl EventsWorker {
|
||||
for event in events {
|
||||
// Zufällige Prüfung basierend auf Wahrscheinlichkeit
|
||||
let roll = rng.gen_range(0.0..=1.0);
|
||||
let effective_prob = event.probability_per_minute * EVENT_RATE_SCALE;
|
||||
let effective_prob = event.probability_per_minute * Self::EVENT_RATE_SCALE;
|
||||
if roll < effective_prob {
|
||||
eprintln!(
|
||||
"[EventsWorker] Ereignis '{}' wurde ausgelöst (Wahrscheinlichkeit: {:.4}% -> skaliert {:.4}%)",
|
||||
|
||||
Reference in New Issue
Block a user