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
@@ -202,7 +202,8 @@ public sealed class WarehouseInfo
|
||||
|
||||
/// <summary>
|
||||
/// Quadro del mercato globale per la compagnia della sessione (F6): indice materie prime, beni con
|
||||
/// storico mensile e previsione, hub, evento in corso e avanzamento verso la compravendita in proprio.
|
||||
/// storico mensile e previsione, hub, evento in corso (shock mondiale ed eventi del mondo sulla domanda
|
||||
/// di un bene) e avanzamento verso la compravendita in proprio.
|
||||
/// </summary>
|
||||
public sealed class MarketReport : IMessage
|
||||
{
|
||||
@@ -231,6 +232,8 @@ public sealed class MarketReport : IMessage
|
||||
public bool RatingMet { get; init; }
|
||||
/// <summary>Blocco 1: magazzini della compagnia nelle sue stazioni vive (ADR 0016).</summary>
|
||||
public List<WarehouseInfo> Warehouses { get; init; } = [];
|
||||
/// <summary>Blocco 2 (ADR 0017): eventi del mondo in corso sulla domanda di un bene (boom o crollo in una zona).</summary>
|
||||
public List<WorldEventInfo> GoodEvents { get; init; } = [];
|
||||
|
||||
public void Write(ref SpanWriter w)
|
||||
{
|
||||
@@ -242,10 +245,17 @@ public sealed class MarketReport : IMessage
|
||||
w.I32(EventGood); w.F32(EventShock); w.F32(EventMonths);
|
||||
w.Bool(TradingUnlocked); w.U8(TradingTier); w.F32(TradingProgress); w.Money(NetWorth); w.Money(NetWorthRequired);
|
||||
w.I32(TownsConnected); w.I32(TownsRequired); w.I32(TownPopulation); w.String(Rating); w.String(RatingRequired); w.Bool(RatingMet);
|
||||
w.Flags(Warehouses.Count > 0 ? (byte)1 : (byte)0);
|
||||
if (Warehouses.Count == 0) return;
|
||||
w.Count(Warehouses.Count);
|
||||
foreach (var h in Warehouses) h.Write(ref w);
|
||||
w.Flags((byte)((Warehouses.Count > 0 ? 1 : 0) | (GoodEvents.Count > 0 ? 2 : 0)));
|
||||
if (Warehouses.Count > 0)
|
||||
{
|
||||
w.Count(Warehouses.Count);
|
||||
foreach (var h in Warehouses) h.Write(ref w);
|
||||
}
|
||||
if (GoodEvents.Count > 0)
|
||||
{
|
||||
w.Count(GoodEvents.Count);
|
||||
foreach (var e in GoodEvents) e.Write(ref w);
|
||||
}
|
||||
}
|
||||
|
||||
public static MarketReport Read(ref SpanReader r)
|
||||
@@ -268,6 +278,10 @@ public sealed class MarketReport : IMessage
|
||||
{
|
||||
for (int n = r.Count(), i = 0; i < n; i++) m.Warehouses.Add(WarehouseInfo.Read(ref r));
|
||||
}
|
||||
if ((flags & 2) != 0)
|
||||
{
|
||||
for (int n = r.Count(), i = 0; i < n; i++) m.GoodEvents.Add(WorldEventInfo.Read(ref r));
|
||||
}
|
||||
return m;
|
||||
}
|
||||
}
|
||||
@@ -542,6 +542,49 @@ public sealed class EventInfo : IWritable
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Evento del mondo in corso (F6, ADR 0017): tipo del catalogo (id di events.json), bersaglio
|
||||
/// (entità come in <see cref="EventInfo"/>), bene (−1 se nessuno), giorni d'inizio e di fine
|
||||
/// (escluso) e valori dei moltiplicatori nell'ordine degli effetti del catalogo.
|
||||
/// </summary>
|
||||
public sealed class WorldEventInfo : IWritable
|
||||
{
|
||||
public int Id { get; init; }
|
||||
public string Type { get; init; } = "";
|
||||
public byte Entity { get; init; }
|
||||
public int EntityIndex { get; init; } = -1;
|
||||
public int Good { get; init; } = -1;
|
||||
public long StartDay { get; init; }
|
||||
public long EndDay { get; init; }
|
||||
public byte Severity { get; init; }
|
||||
public float[] Effects { get; init; } = [];
|
||||
|
||||
public void Write(ref SpanWriter w)
|
||||
{
|
||||
w.I32(Id); w.String(Type); w.U8(Entity); w.I32(EntityIndex); w.I32(Good); w.I64(StartDay); w.I64(EndDay); w.U8(Severity);
|
||||
w.Count(Effects.Length);
|
||||
foreach (float f in Effects) w.F32(f);
|
||||
w.Flags(0);
|
||||
}
|
||||
|
||||
public static WorldEventInfo Read(ref SpanReader r)
|
||||
{
|
||||
int id = r.I32();
|
||||
string type = r.String();
|
||||
byte entity = r.U8();
|
||||
int index = r.I32(), good = r.I32();
|
||||
long start = r.I64(), end = r.I64();
|
||||
byte severity = r.U8();
|
||||
var effects = new float[r.Count()];
|
||||
for (int i = 0; i < effects.Length; i++) effects[i] = r.F32();
|
||||
r.Flags();
|
||||
return new WorldEventInfo
|
||||
{
|
||||
Id = id, Type = type, Entity = entity, EntityIndex = index, Good = good, StartDay = start, EndDay = end, Severity = severity, Effects = effects,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Tratto di moto di un treno: arco percorso nel verso indicato tra due progressive.</summary>
|
||||
public readonly record struct MotionSegment(int Edge, bool Forward, double FromS, double ToS)
|
||||
{
|
||||
|
||||
@@ -320,6 +320,8 @@ public sealed class DailyDigest : IMessage
|
||||
public bool Slow { get; init; }
|
||||
public byte Speed { get; init; }
|
||||
public float TickMs { get; init; }
|
||||
/// <summary>Blocco 1 (F6, ADR 0017): eventi del mondo in corso su tutta la mappa.</summary>
|
||||
public List<WorldEventInfo> WorldEvents { get; init; } = [];
|
||||
|
||||
public void Write(ref SpanWriter w)
|
||||
{
|
||||
@@ -329,7 +331,10 @@ public sealed class DailyDigest : IMessage
|
||||
w.Count(Events.Count);
|
||||
foreach (var e in Events) e.Write(ref w);
|
||||
w.U64(StateHash); w.Bool(Slow); w.U8(Speed); w.F32(TickMs);
|
||||
w.Flags(0);
|
||||
w.Flags(WorldEvents.Count > 0 ? (byte)1 : (byte)0);
|
||||
if (WorldEvents.Count == 0) return;
|
||||
w.Count(WorldEvents.Count);
|
||||
foreach (var e in WorldEvents) e.Write(ref w);
|
||||
}
|
||||
|
||||
public static DailyDigest Read(ref SpanReader r)
|
||||
@@ -348,7 +353,11 @@ public sealed class DailyDigest : IMessage
|
||||
Day = day, Tick = tick, Date = date, Cash = cash, NetWorth = worth, Rating = rating, Prices = prices, Events = events,
|
||||
StateHash = r.U64(), Slow = r.Bool(), Speed = r.U8(), TickMs = r.F32(),
|
||||
};
|
||||
r.Flags();
|
||||
byte flags = r.Flags();
|
||||
if ((flags & 1) != 0)
|
||||
{
|
||||
for (int n = r.Count(), i = 0; i < n; i++) m.WorldEvents.Add(WorldEventInfo.Read(ref r));
|
||||
}
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user