F2: industria servita come ultimo giorno di servizio nel trimestre
Il flag giornaliero veniva azzerato dalle stazioni prima della valutazione trimestrale; ora conta l'essere stata servita almeno un giorno nel trimestre. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0191R7vXgtbAvSV4V8tj8uzL
This commit is contained in:
7 files changed
+24
-15
No files matched your search
@@ -78,8 +78,15 @@ public sealed class Industry
|
||||
public int QuartersAtZero { get; set; }
|
||||
public double LastScore { get; set; }
|
||||
|
||||
/// <summary>Servita da un vettore (stazione con bacino che la include): solo allora cresce o regredisce (ADR 0004).</summary>
|
||||
public bool Served { get; set; }
|
||||
/// <summary>
|
||||
/// Ultimo giorno in cui era servita da un vettore (stazione fermata di una linea con treni,
|
||||
/// con l'industria nel bacino); −1 se mai. Solo le industrie servite nel trimestre crescono o
|
||||
/// regrediscono (ADR 0004).
|
||||
/// </summary>
|
||||
public long LastServedDay { get; set; } = -1;
|
||||
|
||||
/// <summary>Servita almeno una volta negli ultimi «window» giorni.</summary>
|
||||
public bool ServedWithin(long today, int window) => LastServedDay >= 0 && today - LastServedDay <= window;
|
||||
|
||||
/// <summary>Vendite e acquisti del giorno corrente (centesimi), per il margine.</summary>
|
||||
public double SalesToday { get; set; }
|
||||
|
||||
@@ -150,7 +150,7 @@ public static class WorldSerializer
|
||||
s.Write(i.QuartersAboveUpgrade);
|
||||
s.Write(i.QuartersAtZero);
|
||||
s.Write(i.LastScore);
|
||||
s.Write(i.Served);
|
||||
s.Write(i.LastServedDay);
|
||||
s.Write(i.SalesToday);
|
||||
s.Write(i.PurchasesToday);
|
||||
s.Write(i.ShippedToday);
|
||||
@@ -540,7 +540,7 @@ public static class WorldSerializer
|
||||
ind.QuartersAboveUpgrade = r.ReadInt32();
|
||||
ind.QuartersAtZero = r.ReadInt32();
|
||||
ind.LastScore = r.ReadDouble();
|
||||
ind.Served = r.ReadBool();
|
||||
ind.LastServedDay = r.ReadInt64();
|
||||
ind.SalesToday = r.ReadDouble();
|
||||
ind.PurchasesToday = r.ReadDouble();
|
||||
ind.ShippedToday = r.ReadInt32();
|
||||
|
||||
@@ -144,7 +144,7 @@ public sealed class IndustrySystem : ISimSystem
|
||||
ind.QuarterDays = 0;
|
||||
|
||||
// solo le industrie servite da un vettore crescono o regrediscono (ADR 0004)
|
||||
if (!ind.Served) continue;
|
||||
if (!ind.ServedWithin(ctx.Day, g.QuarterDays)) continue;
|
||||
|
||||
if (ind.Level == 0)
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@ public sealed class StationSystem : ISimSystem
|
||||
{
|
||||
foreach (var s in net.Stations) RailCommandHandlers.UpdateCatchment(w, s);
|
||||
}
|
||||
MarkServed(w);
|
||||
MarkServed(w, ctx.Day);
|
||||
foreach (var s in net.Stations)
|
||||
{
|
||||
if (net.Nodes[s.Node.Value].Station != s.Id) continue;
|
||||
@@ -40,13 +40,12 @@ public sealed class StationSystem : ISimSystem
|
||||
}
|
||||
|
||||
/// <summary>Un'industria è servita se sta nel bacino di una stazione fermata di una linea con treni.</summary>
|
||||
private static void MarkServed(World w)
|
||||
private static void MarkServed(World w, long day)
|
||||
{
|
||||
foreach (var i in w.Industries) i.Served = false;
|
||||
foreach (var s in w.Network.Stations)
|
||||
{
|
||||
if (!IsServedStation(w, s)) continue;
|
||||
foreach (var id in s.Industries) w.Industries[id.Value].Served = true;
|
||||
foreach (var id in s.Industries) w.Industries[id.Value].LastServedDay = day;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user