F6: ere e obsolescenza, correzioni della revisione
Due revisori hanno trovato 12 rilievi. I principali: - Il rinnovo si ricontrolla all'avvio dei lavori: piano, spesa e cassa possono cambiare tra prenotazione e avvio. Se la cassa non basta il rinnovo si annulla senza pagare e con un avviso, così non va mai in scoperto. - La cassa impegnata dai rinnovi prenotati e non ancora avviati (Obsolescence.Committed) conta per il giocatore e per le IA, così la stessa cassa non si spende due volte nello stesso mese. - Le IA comprano il successore solo se non peggiora il treno, e rinnovano solo se le prestazioni restano almeno quelle di oggi. - Dopo un deragliamento la ricostruzione non ringiovanisce nel patrimonio un modello fuori produzione. - Quadro della flotta e pannelli mostrano un rinnovo già prenotato e la spesa netta al netto degli altri rinnovi. Suite completa 210 su 210, client senza avvisi. Refs #41. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f7c286bf1d
commit
b7737455c6
18 files changed
+447
-96
No files matched your search
@@ -489,7 +489,13 @@ public sealed class FleetMaintenanceSystem : ISimSystem
|
||||
waitingParts = true;
|
||||
continue;
|
||||
}
|
||||
Start(ctx, d, job, t, rate);
|
||||
if (!Start(ctx, d, job, t, rate))
|
||||
{
|
||||
// rinnovo annullato all'avvio: il treno esce dall'officina senza lavori
|
||||
d.Jobs.RemoveAt(i--);
|
||||
inStall--;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
job.Progress += rate;
|
||||
if (job.Progress + 1e-9 < job.Days) continue;
|
||||
@@ -507,19 +513,50 @@ public sealed class FleetMaintenanceSystem : ISimSystem
|
||||
else if (!waitingParts) d.PartsAlerted = false;
|
||||
}
|
||||
|
||||
private static void Start(WorldContext ctx, Depot d, WorkshopJob job, Train t, double rate)
|
||||
/// <summary>Avvia il lavoro: preleva i ricambi e paga l'intervento. Falso se un rinnovo si annulla.</summary>
|
||||
private static bool Start(WorldContext ctx, Depot d, WorkshopJob job, Train t, double rate)
|
||||
{
|
||||
var w = ctx.World;
|
||||
var m = w.Data.Maintenance;
|
||||
var def = m.Interventions[job.Intervention];
|
||||
var cost = Fleet.CostOf(w, t, def, Fleet.PolicyOf(w, t));
|
||||
List<RenewalItem>? plan = null;
|
||||
if (def.Effect == InterventionEffect.Renew)
|
||||
{
|
||||
// rinnovo (ADR 0020): piano, spesa e cassa si controllano qui, quando si paga, non solo alla
|
||||
// prenotazione: tra le due l'anno può cambiare il piano e la cassa può essersi spesa altrove
|
||||
plan = Obsolescence.RenewalPlan(w, t);
|
||||
var total = Obsolescence.NetCost(plan) + cost;
|
||||
var company = w.Companies[t.Owner.Value];
|
||||
string? why = plan.Count == 0 ? "nessun veicolo superato con un successore in produzione"
|
||||
: total.IsPositive && company.Cash < total ? $"cassa insufficiente per la spesa netta di {total}" : null;
|
||||
if (why is not null)
|
||||
{
|
||||
t.InWorkshop = false;
|
||||
t.MaintenanceDepot = DepotId.None;
|
||||
t.PlannedIntervention = -1;
|
||||
w.Events.Add(new GameEvent(ctx.Day, EventKind.Maintenance, EventSeverity.Warning,
|
||||
$"{t.Name}: rinnovo annullato a {d.Name}, {why}", EntityKind.Train, t.Id.Value, t.Owner));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
d.SpareParts -= job.Parts;
|
||||
w.Goods.Consumed[w.Data.SparePartsGood] += job.Parts;
|
||||
var cost = Fleet.CostOf(w, t, def, Fleet.PolicyOf(w, t));
|
||||
if (cost.IsPositive) w.Money.Transfer(Account.Of(t.Owner), Account.External, cost, LedgerEntry.FleetMaintenance);
|
||||
job.CostCents = cost.Cents;
|
||||
job.Started = true;
|
||||
t.MaintenanceThisYear += cost.Cents;
|
||||
if (plan is not null)
|
||||
{
|
||||
// i veicoli si sostituiscono all'avvio, con il piano appena pagato; i giorni d'officina sono la messa in servizio
|
||||
var net = Obsolescence.NetCost(plan);
|
||||
int renewed = Obsolescence.Renew(w, t, plan);
|
||||
string what = renewed == 1 ? "1 veicolo sostituito" : $"{renewed} veicoli sostituiti";
|
||||
w.Events.Add(new GameEvent(ctx.Day, EventKind.Maintenance, EventSeverity.Info,
|
||||
$"{t.Name}: rinnovo avviato a {d.Name}, {what} (spesa netta {net + cost})", EntityKind.Train, t.Id.Value, t.Owner));
|
||||
}
|
||||
if (job.Days / rate >= m.Planner.ReserveMinDays) Cover(ctx, t, d);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void Complete(WorldContext ctx, Depot d, WorkshopJob job, Train t)
|
||||
@@ -527,7 +564,6 @@ public sealed class FleetMaintenanceSystem : ISimSystem
|
||||
var w = ctx.World;
|
||||
var m = w.Data.Maintenance;
|
||||
var def = m.Interventions[job.Intervention];
|
||||
int renewed = def.Effect == InterventionEffect.Renew ? Obsolescence.RenewalPlan(w, t).Count : 0;
|
||||
Fleet.Apply(w, t, def, Fleet.PolicyOf(w, t));
|
||||
bool repair = def.Effect is InterventionEffect.Repair or InterventionEffect.Replace;
|
||||
if (def.Effect != InterventionEffect.Inspection)
|
||||
@@ -552,9 +588,8 @@ public sealed class FleetMaintenanceSystem : ISimSystem
|
||||
}
|
||||
else if (def.Effect == InterventionEffect.Renew)
|
||||
{
|
||||
string what = renewed == 1 ? "1 veicolo sostituito" : $"{renewed} veicoli sostituiti";
|
||||
w.Events.Add(new GameEvent(ctx.Day, EventKind.Maintenance, EventSeverity.Info,
|
||||
$"{t.Name}: rinnovo completato a {d.Name}, {what}", EntityKind.Train, t.Id.Value, t.Owner));
|
||||
$"{t.Name}: rinnovo completato a {d.Name}", EntityKind.Train, t.Id.Value, t.Owner));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user