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:
28 files changed
+1618
-64
No files matched your search
@@ -68,11 +68,15 @@ public sealed class CompanyInfo : IWritable
|
||||
public byte Tier { get; init; }
|
||||
public bool Bankrupt { get; init; }
|
||||
|
||||
// blocco 1 (F4): politica di manutenzione della flotta
|
||||
public byte MaintenancePolicy { get; set; } = 1;
|
||||
|
||||
public void Write(ref SpanWriter w)
|
||||
{
|
||||
w.I32(Id); w.String(Name); w.String(Color); w.Bool(IsPlayer); w.Money(Cash); w.Money(NetWorth);
|
||||
w.String(Rating); w.U8(Tier); w.Bool(Bankrupt);
|
||||
w.Flags(0);
|
||||
w.Flags(1);
|
||||
w.U8(MaintenancePolicy);
|
||||
}
|
||||
|
||||
public static CompanyInfo Read(ref SpanReader r)
|
||||
@@ -82,7 +86,8 @@ public sealed class CompanyInfo : IWritable
|
||||
Id = r.I32(), Name = r.String(), Color = r.String(), IsPlayer = r.Bool(), Cash = r.Money(), NetWorth = r.Money(),
|
||||
Rating = r.String(), Tier = r.U8(), Bankrupt = r.Bool(),
|
||||
};
|
||||
r.Flags();
|
||||
byte flags = r.Flags();
|
||||
if ((flags & 1) != 0) m.MaintenancePolicy = r.U8();
|
||||
return m;
|
||||
}
|
||||
}
|
||||
@@ -242,16 +247,33 @@ public sealed class DepotInfo : IWritable
|
||||
public Vec2 Position { get; init; }
|
||||
public string Size { get; init; } = "";
|
||||
|
||||
// blocco 1 (F4): officina
|
||||
public int Stalls { get; set; }
|
||||
public int JobsStaff { get; set; }
|
||||
/// <summary>Personale presente in percentuale (0–100).</summary>
|
||||
public byte StaffPercent { get; set; }
|
||||
public int SpareParts { get; set; }
|
||||
public int PartsTarget { get; set; }
|
||||
/// <summary>Lavori in officina (in coda e negli stalli).</summary>
|
||||
public int Jobs { get; set; }
|
||||
public bool WaitingParts { get; set; }
|
||||
|
||||
public void Write(ref SpanWriter w)
|
||||
{
|
||||
w.I32(Id); w.I32(Owner); w.String(Name); w.I32(Node); w.Vec2(Position); w.String(Size);
|
||||
w.Flags(0);
|
||||
w.Flags(1);
|
||||
w.I32(Stalls); w.I32(JobsStaff); w.U8(StaffPercent); w.I32(SpareParts); w.I32(PartsTarget); w.I32(Jobs); w.Bool(WaitingParts);
|
||||
}
|
||||
|
||||
public static DepotInfo Read(ref SpanReader r)
|
||||
{
|
||||
var m = new DepotInfo { Id = r.I32(), Owner = r.I32(), Name = r.String(), Node = r.I32(), Position = r.Vec2(), Size = r.String() };
|
||||
r.Flags();
|
||||
byte flags = r.Flags();
|
||||
if ((flags & 1) != 0)
|
||||
{
|
||||
m.Stalls = r.I32(); m.JobsStaff = r.I32(); m.StaffPercent = r.U8(); m.SpareParts = r.I32(); m.PartsTarget = r.I32();
|
||||
m.Jobs = r.I32(); m.WaitingParts = r.Bool();
|
||||
}
|
||||
return m;
|
||||
}
|
||||
}
|
||||
@@ -264,6 +286,9 @@ public sealed class LineInfo : IWritable
|
||||
public string Color { get; init; } = "";
|
||||
public LineStop[] Stops { get; init; } = [];
|
||||
|
||||
// blocco 1 (F4): politica di manutenzione propria della linea (255 = quella della compagnia)
|
||||
public byte Policy { get; set; } = byte.MaxValue;
|
||||
|
||||
public void Write(ref SpanWriter w)
|
||||
{
|
||||
w.I32(Id); w.I32(Owner); w.String(Name); w.String(Color);
|
||||
@@ -272,7 +297,8 @@ public sealed class LineInfo : IWritable
|
||||
{
|
||||
w.I32(s.Station.Value); w.Bool(s.Load); w.Bool(s.Unload); w.Bool(s.WaitFull); w.I32(s.MaxWaitDays);
|
||||
}
|
||||
w.Flags(0);
|
||||
w.Flags(1);
|
||||
w.U8(Policy);
|
||||
}
|
||||
|
||||
public static LineInfo Read(ref SpanReader r)
|
||||
@@ -281,8 +307,10 @@ public sealed class LineInfo : IWritable
|
||||
string name = r.String(), color = r.String();
|
||||
var stops = new LineStop[r.Count()];
|
||||
for (int i = 0; i < stops.Length; i++) stops[i] = new LineStop(new StationId(r.I32()), r.Bool(), r.Bool(), r.Bool(), r.I32());
|
||||
r.Flags();
|
||||
return new LineInfo { Id = id, Owner = owner, Name = name, Color = color, Stops = stops };
|
||||
var m = new LineInfo { Id = id, Owner = owner, Name = name, Color = color, Stops = stops };
|
||||
byte flags = r.Flags();
|
||||
if ((flags & 1) != 0) m.Policy = r.U8();
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,6 +337,21 @@ public sealed class VehicleInfo : IWritable
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Stato di manutenzione di un treno nel riepilogo (blocco F4 di TrainInfo).</summary>
|
||||
public enum TrainMaintenanceStatus : byte
|
||||
{
|
||||
InService = 0,
|
||||
/// <summary>Intervento prenotato: va in officina dopo la fermata corrente.</summary>
|
||||
Booked = 1,
|
||||
InWorkshop = 2,
|
||||
/// <summary>Guasto lieve: velocità dimezzata fino al deposito.</summary>
|
||||
MinorFailure = 3,
|
||||
/// <summary>Fermo in linea in attesa del soccorso (guasto grave o deragliamento).</summary>
|
||||
Stranded = 4,
|
||||
/// <summary>Rimorchiato verso l'officina.</summary>
|
||||
Towed = 5,
|
||||
}
|
||||
|
||||
public sealed class TrainInfo : IWritable
|
||||
{
|
||||
public int Id { get; init; }
|
||||
@@ -323,13 +366,28 @@ public sealed class TrainInfo : IWritable
|
||||
public int Capacity { get; init; }
|
||||
public int Depot { get; init; } = -1;
|
||||
|
||||
// blocco 1 (F4): riepilogo di manutenzione (la cartella completa si chiede con RequestDetail)
|
||||
/// <summary>Condizione del componente più debole (0–100).</summary>
|
||||
public byte Condition { get; set; } = 100;
|
||||
public TrainMaintenanceStatus Maintenance { get; set; }
|
||||
public bool Reserve { get; set; }
|
||||
/// <summary>Politica propria del treno (255 = quella della linea o della compagnia).</summary>
|
||||
public byte Policy { get; set; } = byte.MaxValue;
|
||||
/// <summary>Prossimo intervento (id di maintenance.json) e giorni alla scadenza (negativi se scaduto).</summary>
|
||||
public string NextIntervention { get; set; } = "";
|
||||
public int NextDueDays { get; set; }
|
||||
/// <summary>Officina prenotata o in cui si trova (−1 nessuna).</summary>
|
||||
public int MaintenanceDepot { get; set; } = -1;
|
||||
|
||||
public void Write(ref SpanWriter w)
|
||||
{
|
||||
w.I32(Id); w.I32(Owner); w.String(Name); w.I32(Line); w.U8(State);
|
||||
w.Count(Vehicles.Length);
|
||||
foreach (int v in Vehicles) w.I32(v);
|
||||
w.F32(MaxSpeedKmh); w.F32(LengthM); w.I32(Load); w.I32(Capacity); w.I32(Depot);
|
||||
w.Flags(0);
|
||||
w.Flags(1);
|
||||
w.U8(Condition); w.U8((byte)Maintenance); w.Bool(Reserve); w.U8(Policy); w.String(NextIntervention); w.I32(NextDueDays);
|
||||
w.I32(MaintenanceDepot);
|
||||
}
|
||||
|
||||
public static TrainInfo Read(ref SpanReader r)
|
||||
@@ -345,7 +403,12 @@ public sealed class TrainInfo : IWritable
|
||||
Id = id, Owner = owner, Name = name, Line = line, State = state, Vehicles = vehicles,
|
||||
MaxSpeedKmh = r.F32(), LengthM = r.F32(), Load = r.I32(), Capacity = r.I32(), Depot = r.I32(),
|
||||
};
|
||||
r.Flags();
|
||||
byte flags = r.Flags();
|
||||
if ((flags & 1) != 0)
|
||||
{
|
||||
m.Condition = r.U8(); m.Maintenance = (TrainMaintenanceStatus)r.U8(); m.Reserve = r.Bool(); m.Policy = r.U8();
|
||||
m.NextIntervention = r.String(); m.NextDueDays = r.I32(); m.MaintenanceDepot = r.I32();
|
||||
}
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user