F4: protocollo e client per manutenzione e impieghi, ADR 0010, stato dei lavori

- Protocollo: riepilogo di manutenzione nei record (blocco 1), RequestDetail, MaintenanceCard,
  WorkshopRegister, EmploymentReport con depositi, motivi e convenzioni, MaintenanceAlert.
- Server: dettagli su richiesta, avvisi dalla manutenzione, registro dopo le convenzioni.
- Client: pannelli Officine (cartella di manutenzione, Registro officina, scorta di ricambi,
  avvisi, mappa di calore) e Impieghi (Registro degli impieghi con convenzioni); schede
  di treno, industria e città aggiornate; pilota automatico con le nuove schermate.
- ADR 0010, PROTOCOL, ARCHITECTURE e STATE aggiornati; 102 test verdi.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0191R7vXgtbAvSV4V8tj8uzL
This commit is contained in:
Claude committed 2026-10-02 01:54:58 +00:00
1 parent b6c326b79c
commit d285a38664
28 files changed
+1618 -64

No files matched your search

+35 -23
View File
@@ -3,6 +3,7 @@ using System.Diagnostics;
using System.Globalization;
using System.Security.Cryptography;
using System.Text;
using ViaFerrea.Core.Commands;
using ViaFerrea.Core.Common;
using ViaFerrea.Core.Data;
using ViaFerrea.Core.Simulation;
@@ -223,6 +224,9 @@ public sealed class GameHost : IDisposable
_slow = false;
_log.LogInformation("Velocità {Speed}×", _speed);
break;
case RequestDetail m:
SendDetail(s, m);
break;
case ListSaves:
s.Send(new SaveList { Saves = _saves.List() });
break;
@@ -362,7 +366,22 @@ public sealed class GameHost : IDisposable
{
Seq = p.ClientSeq, Type = (ushort)r.Type, Error = (ushort)r.Error, Message = r.Message, Created = r.Created, Tick = r.Tick,
});
// le convenzioni cambiano il Registro degli impieghi: lo si rimanda subito
if (r.Ok && r.Type is CommandType.AcceptAgreement or CommandType.RejectAgreement)
p.Session.Send(Projection.Employment(w, p.Session.Company));
}
foreach (var a in w.Alerts)
{
var alert = new MaintenanceAlert
{
Train = a.Train.Value, Depot = a.Depot.Value, Component = a.Component, Condition = (float)a.Condition, DueDays = a.DueDays, Text = a.Text,
};
foreach (var s in _sessions.Values)
{
if (s.Connected && s.Company == a.Company) s.Send(alert);
}
}
w.Alerts.Clear();
foreach (var e in w.Events.Drain())
{
var info = Projection.Event(e);
@@ -599,37 +618,30 @@ public sealed class GameHost : IDisposable
s.Send(Projection.Chunk(w, key.Cx, key.Cy));
}
}
if (_monthlyDue) s.Send(EmploymentReport(w, s.Company));
if (_monthlyDue) s.Send(Projection.Employment(w, s.Company));
}
_monthlyDue = false;
_dayEvents.Clear();
}
/// <summary>Registro degli impieghi della compagnia: posti serviti dai suoi treni e provenienze.</summary>
private static EmploymentReport EmploymentReport(World w, CompanyId company)
/// <summary>Dettagli su richiesta: cartella di manutenzione, registro officina, registro degli impieghi.</summary>
private void SendDetail(Session s, RequestDetail m)
{
var report = new EmploymentReport { Day = w.Clock.Day };
foreach (var ind in w.Industries)
var w = _world;
switch (m.Kind)
{
if (ind.Closed) continue;
var sources = new List<EmploymentSource>();
foreach (var c in w.Commutes)
{
if (c.Walking || c.Carrier != company || c.Workplace.Kind != Core.Economy.WorkplaceKind.Industry || c.Workplace.Index != ind.Id.Value) continue;
sources.Add(new EmploymentSource
{
Town = c.Town.Value, HomeStation = c.HomeStation.Value, Line = c.Route.Count > 0 ? c.Route[0].Value : -1,
Category = (byte)c.Category, Headcount = c.Headcount, Coverage = (float)c.Coverage,
});
}
if (sources.Count == 0) continue;
report.Rows.Add(new EmploymentRow
{
Industry = ind.Id.Value, JobsWorkers = ind.JobsWorkers, JobsStaff = ind.JobsStaff,
WorkersPresent = (float)ind.WorkersPresent, StaffPresent = (float)ind.StaffPresent, Sources = sources,
});
case DetailKind.TrainCard:
if (m.Target >= 0 && m.Target < w.Trains.Count && w.Trains[m.Target] is { Removed: false } t && t.Owner == s.Company)
s.Send(Projection.Card(w, t));
break;
case DetailKind.Workshop:
if (m.Target >= 0 && m.Target < w.Network.Depots.Count && w.Network.Depots[m.Target] is { } d && d.Owner == s.Company && w.Network.IsAlive(d))
s.Send(Projection.Workshop(w, d));
break;
case DetailKind.Employment:
s.Send(Projection.Employment(w, s.Company));
break;
}
return report;
}
private void PublishMotion()