F6: tooltip perché sui valori calcolati dal server

Ogni valore importante dei pannelli spiega al passaggio del mouse da dove
viene: formula, termini con i valori di oggi e note, calcolati dal Core e
mandati dal server, perché il client non deve rifare né ricomporre formule.

- Core: modello comune Explanation ed Explanations, pure funzioni che
  chiamano le stesse funzioni del motore; estratte senza cambiare
  l'aritmetica (hash invariati) Market.NextPrice e LocalPriceTerms,
  Tariffs.FreightTerms e PassengerTerms, TownSystem.GrowthOf,
  Fleet.DailyHazard, GameClock.YearsAt; Industry.LastEfficiency
  transitorio (né salvato né nell'hash).
- Protocollo: RequestDetail kind 11 con un blocco 1 (subject, arg) ed
  ExplanationReport 137; il server risponde sempre, anche con available
  falso. Nessun campo nei delta, formato dei salvataggi invariato.
- Client: WhyTooltip comune (palette 05, apertura dopo 0,45 s, «in
  arrivo…» finché la spiegazione manca) su barra superiore, Mercato,
  Scalata, Finanze, scheda industria, Treni e Officine; testi in
  strings.csv.
- ADR 0024, PROTOCOL.md, ARCHITECTURE.md, STATE.md; 10 test nuovi in
  Economy/ExplanationTests.cs con uguaglianza esatta ai valori del motore.

Refs #44.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-08 15:14:57 +01:00
1 parent 767661957b
commit 19a3dd3af1
33 files changed
+2089 -64

No files matched your search

+4
View File
@@ -692,6 +692,10 @@ public sealed class GameHost : IDisposable
case DetailKind.Fleet:
if (s.Company.IsValid && s.Company.Value < w.Companies.Count) s.Send(Projection.FleetRenewal(w, s.Company));
break;
case DetailKind.Explain:
// risponde sempre, anche per un bersaglio che non c'è (Available = false): il tooltip smette di aspettare
s.Send(Projection.Explanation(w, s.Company, m.Subject, m.Target, m.Arg));
break;
}
}
+13
View File
@@ -690,6 +690,19 @@ public static class Projection
};
}
/// <summary>Spiegazione «perché» di un valore per la compagnia della sessione (Explanations, ADR 0024).</summary>
public static ExplanationReport Explanation(World w, CompanyId company, byte subject, int target, int arg)
{
var e = Explanations.Build(w, company, new ExplainTarget((ExplainSubject)subject, target, arg));
return new ExplanationReport
{
Day = e.Day, Subject = subject, Target = target, Arg = arg, Available = e.Available, Title = e.Title, Name = e.Name,
Value = e.Value, Unit = (byte)e.Unit, ValueText = e.ValueText, Formula = e.Formula,
Terms = e.Terms.Select(t => new ExplanationTermInfo { Symbol = t.Symbol, Label = t.Label, Value = t.Value, Unit = (byte)t.Unit, Text = t.Text }).ToList(),
Notes = e.Notes,
};
}
/// <summary>Evento del mondo in corso → record del protocollo (ADR 0017).</summary>
public static WorldEventInfo WorldEvent(ActiveWorldEvent e) => new()
{