F6: eventi del mondo con effetti temporanei e notizie
Aggiunge gli eventi della F6: fatti del mondo che cambiano il gioco per un periodo limitato, leggibili nel notiziario e reversibili. - Catalogo data/events.json con schema e validazione: incidente e boom di un'industria, fiera ed epidemia, boom e crollo della domanda di un bene in una zona, maltempo su un'area, sciopero di città o deposito. - Effetti come moltiplicatori letti da un'unica sorgente (World.WorldEvents) dai sistemi esistenti: capacità delle industrie, consumi delle città, presenze dei pendolari, velocità dei treni e usura del binario. A evento finito il moltiplicatore torna 1. - EventSystem tra le IA e l'hash, con flusso Rng dedicato «events», bersaglio in ordine di id, frequenza per mappa scalata dalla difficoltà (eventFrequencyMultiplier), tetto di 6, niente doppioni, notizie di inizio e fine in italiano (EventKind.World). - Salvataggio corpo versione 5 con gli eventi nell'hash; le versioni 1-4 si caricano senza eventi e con la frequenza del preset. - Protocollo: eventi in corso nel DailyDigest e nel MarketReport; client con il riquadro «Eventi in corso», avvisi nelle schede e «evento in corso» nel Mercato globale. - Lo scenario Valdoria disattiva gli eventi: con gli eventi attivi la flotta F4 senza linea dei ricambi non scendeva più sotto 40, e l'accettazione deve misurare la manutenzione, non la fortuna (ADR 0017). Accettazione F4 invariata: 35 / 20 guasti senza linea, 75 / 2 con. Decisioni in docs/adr/0017-eventi-del-mondo.md; 17 test nuovi. Refs #33. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b258e0858a
commit
1f8da87e51
41 files changed
+1892
-41
No files matched your search
@@ -14,7 +14,7 @@ namespace RailEnterprise.Core.Persistence;
|
||||
public static class WorldSerializer
|
||||
{
|
||||
/// <summary>Versione del corpo del salvataggio (migrazioni in <see cref="Read"/>).</summary>
|
||||
public const int BodyVersion = 4;
|
||||
public const int BodyVersion = 5;
|
||||
|
||||
/// <summary>Scrive l'intero mondo (impostazioni, terreno, stato dinamico, eventi).</summary>
|
||||
public static void Write(World w, SaveWriter s) => Write(w, s, BodyVersion);
|
||||
@@ -28,7 +28,7 @@ public static class WorldSerializer
|
||||
if (bodyVersion < 1 || bodyVersion > BodyVersion) throw new ArgumentOutOfRangeException(nameof(bodyVersion));
|
||||
s.Write(bodyVersion);
|
||||
WriteDictionary(w.Data, s);
|
||||
WriteSettings(w.Settings, s);
|
||||
WriteSettings(w.Settings, s, bodyVersion);
|
||||
WriteTerrain(w.Terrain, w.SeaSide, s);
|
||||
WriteDynamic(w, s, bodyVersion);
|
||||
s.Write(w.LastStateHash);
|
||||
@@ -246,6 +246,7 @@ public static class WorldSerializer
|
||||
if (version >= 2) MaintenanceSerializer.Write(w, s);
|
||||
if (version >= 3) CorporateSerializer.Write(w, s);
|
||||
if (version >= 4) TradingSerializer.Write(w, s);
|
||||
if (version >= 5) EventSerializer.Write(w, s);
|
||||
}
|
||||
|
||||
private static void WriteRecipeStock(List<RecipeItemDef> items, int[] stock, SaveWriter s)
|
||||
@@ -265,7 +266,7 @@ public static class WorldSerializer
|
||||
foreach (var g in data.Goods) s.Write(g.Id);
|
||||
}
|
||||
|
||||
private static void WriteSettings(WorldSettings st, SaveWriter s)
|
||||
private static void WriteSettings(WorldSettings st, SaveWriter s, int version)
|
||||
{
|
||||
s.Write(st.Seed);
|
||||
s.Write(st.SizeKm);
|
||||
@@ -293,6 +294,8 @@ public static class WorldSerializer
|
||||
s.Write(d.PlayerShareAtStart);
|
||||
s.Write((byte)d.Ironman);
|
||||
s.Write((byte)d.Depletion);
|
||||
// versione 5 (F6): frequenza degli eventi del mondo
|
||||
if (version >= 5) s.Write(d.EventFrequencyMultiplier);
|
||||
}
|
||||
|
||||
private static void WriteTerrain(Terrain t, MapSide seaSide, SaveWriter s)
|
||||
@@ -340,7 +343,7 @@ public static class WorldSerializer
|
||||
goodMap[g] = data.TryGoodIndex(id, out int idx) ? idx : -1;
|
||||
}
|
||||
|
||||
var settings = ReadSettings(r);
|
||||
var settings = ReadSettings(data, r, version);
|
||||
var (terrain, seaSide) = ReadTerrain(r);
|
||||
var w = new World(data, settings, terrain, seaSide);
|
||||
ReadDynamic(w, r, goodMap, version);
|
||||
@@ -350,7 +353,7 @@ public static class WorldSerializer
|
||||
return w;
|
||||
}
|
||||
|
||||
private static WorldSettings ReadSettings(SaveReader r)
|
||||
private static WorldSettings ReadSettings(GameData data, SaveReader r, int version)
|
||||
{
|
||||
ulong seed = r.ReadUInt64();
|
||||
int size = r.ReadInt32();
|
||||
@@ -379,6 +382,15 @@ public static class WorldSerializer
|
||||
PlayerShareAtStart = r.ReadDouble(),
|
||||
Ironman = (IronmanRule)r.ReadByte(),
|
||||
Depletion = (DepletionRate)r.ReadByte(),
|
||||
EventFrequencyMultiplier = 0,
|
||||
};
|
||||
// le versioni 1–4 non hanno la frequenza degli eventi: si prende quella del preset con lo
|
||||
// stesso id nei dati correnti (1 per una difficoltà personalizzata sconosciuta)
|
||||
d = d with
|
||||
{
|
||||
EventFrequencyMultiplier = version >= 5
|
||||
? r.ReadDouble()
|
||||
: data.Difficulty.Presets.FirstOrDefault(p => p.Id == d.Id)?.EventFrequencyMultiplier ?? 1.0,
|
||||
};
|
||||
return new WorldSettings { Seed = seed, SizeKm = size, StartYear = startYear, RegionId = region, Endless = endless, Difficulty = d };
|
||||
}
|
||||
@@ -693,6 +705,8 @@ public static class WorldSerializer
|
||||
// versione 4 (F6): magazzini della compagnia e merce propria in viaggio
|
||||
if (version >= 4) TradingSerializer.Read(w, r);
|
||||
else TradingSerializer.Migrate(w);
|
||||
// versione 5 (F6): eventi del mondo in corso; prima nessun evento attivo
|
||||
if (version >= 5) EventSerializer.Read(w, r);
|
||||
}
|
||||
|
||||
private static void ReadRecipeStock(List<RecipeItemDef> items, int[] stock, SaveReader r)
|
||||
|
||||
Reference in new issue
Block a user