F6: livelli e sblocchi visibili, pannello La tua scalata
I livelli esistevano dalla F5 ma il giocatore li vedeva solo come distintivo e come rifiuti con nomi scritti a mano. Ora il motore espone un quadro della scalata e il client lo mostra come l'immagine di riferimento 08. - ClimbOutlook (Core, sola lettura): livelli con gli sblocchi letti dai dati, giorno in cui sono stati raggiunti, requisiti del prossimo livello con valore, soglia, frazione e avanzamento (media delle tre frazioni, ora anche nel Mercato globale), stato patrimoniale, conto economico, prestiti, storico del patrimonio dalla Cronaca. - Stato patrimoniale con una sola fonte: FinanceSystem.BookValues scompone il valore contabile per voce e AssetBookValue ne e' la somma, cosi' il pannello somma al centesimo al patrimonio netto del motore. Le industrie possedute entrano nel patrimonio (impianti piu' cassa, senza avviamento): prima comprarle bruciava patrimonio. - Notizia di promozione con gli sblocchi ottenuti; rifiuti dei comandi bloccati con il livello che serve e il suo nome dai dati (compravendita, industrie, quotazione, scalate, concessioni, fido). - Salvataggio versione 6 (BalanceSheetSerializer) con voci e giorni dei livelli nell'hash; le versioni 1-5 si migrano con lo stesso patrimonio. - Protocollo: DetailKind.Climb (8) e ClimbReport (134), su richiesta. - Client: pannello ClimbPanel a tutto schermo, pulsante Scalata, livello e avanzamento nella barra superiore, schermata nel pilota automatico. - Test: Economy/ClimbTests.cs e quadro via WebSocket (170 test verdi). Decisioni in docs/adr/0018-scalata-e-livelli.md. Refs #38. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a61bf1dc27
commit
d473e21708
37 files changed
+2060
-70
No files matched your search
@@ -50,6 +50,9 @@ public sealed class ClientWorld(GameData data)
|
||||
/// <summary>Quadro del mercato globale (F6), su richiesta.</summary>
|
||||
public MarketReport? Market { get; private set; }
|
||||
|
||||
/// <summary>Quadro della scalata (F6), su richiesta: lo usano il pannello «La tua scalata» e la barra superiore.</summary>
|
||||
public ClimbReport? Climb { get; private set; }
|
||||
|
||||
/// <summary>Contatore dei listini ricevuti (per aggiornare il pannello della borsa).</summary>
|
||||
public int TapeVersion { get; private set; }
|
||||
|
||||
@@ -134,6 +137,10 @@ public sealed class ClientWorld(GameData data)
|
||||
Market = m;
|
||||
DetailVersion++;
|
||||
return true;
|
||||
case ClimbReport m:
|
||||
Climb = m;
|
||||
DetailVersion++;
|
||||
return true;
|
||||
case MaintenanceAlert m:
|
||||
Alerts.Insert(0, m);
|
||||
if (Alerts.Count > AlertCapacity) Alerts.RemoveAt(Alerts.Count - 1);
|
||||
@@ -154,6 +161,7 @@ public sealed class ClientWorld(GameData data)
|
||||
IndustryCards.Clear();
|
||||
Chronicle = null;
|
||||
Market = null;
|
||||
Climb = null;
|
||||
Alerts.Clear();
|
||||
Summary = m.Summary;
|
||||
SessionId = m.SessionId;
|
||||
|
||||
@@ -43,6 +43,8 @@ public enum MessageId : ushort
|
||||
Notification = 131,
|
||||
Newspaper = 132,
|
||||
SaveList = 133,
|
||||
/// <summary>Quadro della scalata: livelli, sblocchi, requisiti, stato patrimoniale (F6).</summary>
|
||||
ClimbReport = 134,
|
||||
}
|
||||
|
||||
/// <summary>Messaggio del protocollo: si serializza a mano, campo per campo.</summary>
|
||||
|
||||
@@ -239,6 +239,8 @@ public enum DetailKind : byte
|
||||
Chronicle = 6,
|
||||
/// <summary>Quadro del mercato globale (risposta MarketReport, F6; Id ignorato).</summary>
|
||||
Market = 7,
|
||||
/// <summary>Quadro della scalata (risposta ClimbReport, F6; Id ignorato).</summary>
|
||||
Climb = 8,
|
||||
}
|
||||
|
||||
/// <summary>Chiede al server un dettaglio che non viaggia con le entità (aggiunto in F4).</summary>
|
||||
|
||||
@@ -0,0 +1,276 @@
|
||||
using RailEnterprise.Core.Common;
|
||||
|
||||
namespace RailEnterprise.Protocol.Messages;
|
||||
|
||||
// Messaggi della fase F6: pannello «La tua scalata» (immagine di riferimento 08). Il quadro arriva su
|
||||
// richiesta (RequestDetail con DetailKind.Climb) ed è calcolato dal server con ClimbOutlook (ADR 0018):
|
||||
// il client lo mostra com'è, senza logica di gioco.
|
||||
|
||||
/// <summary>Sblocco di un livello: Kind come UnlockKind del Core (0 fido, 1 squadre, 2 compravendita, 3 acquisto di industrie, 4 quotazione, 5 scalate ostili, 6 concessioni).</summary>
|
||||
public sealed class UnlockInfo
|
||||
{
|
||||
public const byte LoanLimit = 0, Crews = 1, Trading = 2, BuyIndustry = 3, Ipo = 4, HostileTakeover = 5, Concessions = 6;
|
||||
|
||||
public byte Kind { get; init; }
|
||||
/// <summary>Fido in centesimi (LoanLimit) o numero di squadre (Crews); 0 per gli altri.</summary>
|
||||
public long Value { get; init; }
|
||||
|
||||
public void Write(ref SpanWriter w)
|
||||
{
|
||||
w.U8(Kind); w.I64(Value);
|
||||
w.Flags(0);
|
||||
}
|
||||
|
||||
public static UnlockInfo Read(ref SpanReader r)
|
||||
{
|
||||
var m = new UnlockInfo { Kind = r.U8(), Value = r.I64() };
|
||||
r.Flags();
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Livello di tiers.json visto dalla compagnia: requisiti, raggiunto e quando, sblocchi che aggiunge.</summary>
|
||||
public sealed class TierInfo
|
||||
{
|
||||
public byte Level { get; init; }
|
||||
public string NameIt { get; init; } = "";
|
||||
public string NameEn { get; init; } = "";
|
||||
public Money NetWorthRequired { get; init; }
|
||||
public int TownsRequired { get; init; }
|
||||
public int TownPopulation { get; init; }
|
||||
public string RatingRequired { get; init; } = "";
|
||||
public bool Reached { get; init; }
|
||||
/// <summary>Giorno in cui è stato raggiunto (fondazione per il livello 1; −1 se non raggiunto o sconosciuto).</summary>
|
||||
public long ReachedDay { get; init; } = -1;
|
||||
public List<UnlockInfo> Unlocks { get; init; } = [];
|
||||
|
||||
public void Write(ref SpanWriter w)
|
||||
{
|
||||
w.U8(Level); w.String(NameIt); w.String(NameEn); w.Money(NetWorthRequired); w.I32(TownsRequired); w.I32(TownPopulation);
|
||||
w.String(RatingRequired); w.Bool(Reached); w.I64(ReachedDay);
|
||||
w.Count(Unlocks.Count);
|
||||
foreach (var u in Unlocks) u.Write(ref w);
|
||||
w.Flags(0);
|
||||
}
|
||||
|
||||
public static TierInfo Read(ref SpanReader r)
|
||||
{
|
||||
var m = new TierInfo
|
||||
{
|
||||
Level = r.U8(), NameIt = r.String(), NameEn = r.String(), NetWorthRequired = r.Money(), TownsRequired = r.I32(), TownPopulation = r.I32(),
|
||||
RatingRequired = r.String(), Reached = r.Bool(), ReachedDay = r.I64(),
|
||||
};
|
||||
for (int n = r.Count(), i = 0; i < n; i++) m.Unlocks.Add(UnlockInfo.Read(ref r));
|
||||
r.Flags();
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Voce dello stato patrimoniale o del conto economico: Kind secondo la tabella del messaggio, valore con segno.</summary>
|
||||
public sealed class AmountInfo
|
||||
{
|
||||
public byte Kind { get; init; }
|
||||
public Money Value { get; init; }
|
||||
|
||||
public void Write(ref SpanWriter w)
|
||||
{
|
||||
w.U8(Kind); w.Money(Value);
|
||||
w.Flags(0);
|
||||
}
|
||||
|
||||
public static AmountInfo Read(ref SpanReader r)
|
||||
{
|
||||
var m = new AmountInfo { Kind = r.U8(), Value = r.Money() };
|
||||
r.Flags();
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Prestito in corso: residuo, tasso annuo, mesi restanti.</summary>
|
||||
public sealed class LoanInfo
|
||||
{
|
||||
public int Loan { get; init; }
|
||||
public Money Remaining { get; init; }
|
||||
public float AnnualRate { get; init; }
|
||||
public int MonthsLeft { get; init; }
|
||||
|
||||
public void Write(ref SpanWriter w)
|
||||
{
|
||||
w.I32(Loan); w.Money(Remaining); w.F32(AnnualRate); w.I32(MonthsLeft);
|
||||
w.Flags(0);
|
||||
}
|
||||
|
||||
public static LoanInfo Read(ref SpanReader r)
|
||||
{
|
||||
var m = new LoanInfo { Loan = r.I32(), Remaining = r.Money(), AnnualRate = r.F32(), MonthsLeft = r.I32() };
|
||||
r.Flags();
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Patrimonio netto a un giorno della partita.</summary>
|
||||
public sealed class NetWorthPointInfo
|
||||
{
|
||||
public long Day { get; init; }
|
||||
public Money Value { get; init; }
|
||||
|
||||
public void Write(ref SpanWriter w)
|
||||
{
|
||||
w.I64(Day); w.Money(Value);
|
||||
w.Flags(0);
|
||||
}
|
||||
|
||||
public static NetWorthPointInfo Read(ref SpanReader r)
|
||||
{
|
||||
var m = new NetWorthPointInfo { Day = r.I64(), Value = r.Money() };
|
||||
r.Flags();
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Quadro della scalata per la compagnia della sessione (F6, ADR 0018): livelli con requisiti e
|
||||
/// sblocchi, requisiti del prossimo livello con l'avanzamento, stato patrimoniale per voce (somma al
|
||||
/// patrimonio netto del motore), conto economico, prestiti e storico del patrimonio netto.
|
||||
/// </summary>
|
||||
public sealed class ClimbReport : IMessage
|
||||
{
|
||||
/// <summary>Voci degli attivi (Assets[].Kind), come AssetCategory del Core.</summary>
|
||||
public const byte AssetTrack = 0, AssetStations = 1, AssetVehicles = 2, AssetIndustries = 3, AssetGoods = 4;
|
||||
/// <summary>Righe del conto economico (Income[].Kind), come IncomeLineKind del Core.</summary>
|
||||
public const byte IncomeFares = 0, IncomeOther = 1, IncomeOperating = 2, IncomeMaintenance = 3, IncomeInterest = 4;
|
||||
|
||||
public MessageId Id => MessageId.ClimbReport;
|
||||
public long Day { get; init; }
|
||||
public int Company { get; init; }
|
||||
public long FoundedDay { get; init; }
|
||||
public Money InitialCapital { get; init; }
|
||||
public byte Tier { get; init; }
|
||||
/// <summary>Livello successivo (0 all'ultimo livello: i requisiti che seguono sono vuoti).</summary>
|
||||
public byte NextTier { get; init; }
|
||||
public List<TierInfo> Tiers { get; init; } = [];
|
||||
|
||||
/// <summary>Requisiti del livello successivo: valore attuale, soglia, frazione (0–1) e se è soddisfatto.</summary>
|
||||
public Money NetWorth { get; init; }
|
||||
public Money NetWorthRequired { get; init; }
|
||||
public float NetWorthFraction { get; init; }
|
||||
public bool NetWorthMet { get; init; }
|
||||
public int Towns { get; init; }
|
||||
public int TownsRequired { get; init; }
|
||||
public int TownPopulation { get; init; }
|
||||
public float TownsFraction { get; init; }
|
||||
public bool TownsMet { get; init; }
|
||||
public string Rating { get; init; } = "";
|
||||
public string RatingRequired { get; init; } = "";
|
||||
public float RatingFraction { get; init; }
|
||||
public bool RatingMet { get; init; }
|
||||
/// <summary>Avanzamento complessivo verso il livello successivo (media delle tre frazioni).</summary>
|
||||
public float Progress { get; init; }
|
||||
|
||||
/// <summary>Stato patrimoniale: attivi per voce, partecipazioni, cassa; prestiti (tasso medio), scoperto.</summary>
|
||||
public List<AmountInfo> Assets { get; init; } = [];
|
||||
public Money Portfolio { get; init; }
|
||||
public Money Cash { get; init; }
|
||||
public Money TotalAssets { get; init; }
|
||||
public Money Loans { get; init; }
|
||||
public float LoansRate { get; init; }
|
||||
public Money Overdraft { get; init; }
|
||||
public Money TotalLiabilities { get; init; }
|
||||
public Money BalanceNetWorth { get; init; }
|
||||
|
||||
/// <summary>Conto economico dell'anno indicato (Partial se è l'anno in corso fino a oggi).</summary>
|
||||
public int IncomeYear { get; init; }
|
||||
public bool IncomePartial { get; init; }
|
||||
public List<AmountInfo> Income { get; init; } = [];
|
||||
public Money Profit { get; init; }
|
||||
|
||||
public List<LoanInfo> LoanList { get; init; } = [];
|
||||
public Money MaxLoan { get; init; }
|
||||
public Money LoanAvailable { get; init; }
|
||||
public float NewLoanRate { get; init; }
|
||||
public bool LoansAllowed { get; init; } = true;
|
||||
|
||||
public List<NetWorthPointInfo> History { get; init; } = [];
|
||||
|
||||
public void Write(ref SpanWriter w)
|
||||
{
|
||||
w.I64(Day); w.I32(Company); w.I64(FoundedDay); w.Money(InitialCapital); w.U8(Tier); w.U8(NextTier);
|
||||
w.Count(Tiers.Count);
|
||||
foreach (var t in Tiers) t.Write(ref w);
|
||||
w.Money(NetWorth); w.Money(NetWorthRequired); w.F32(NetWorthFraction); w.Bool(NetWorthMet);
|
||||
w.I32(Towns); w.I32(TownsRequired); w.I32(TownPopulation); w.F32(TownsFraction); w.Bool(TownsMet);
|
||||
w.String(Rating); w.String(RatingRequired); w.F32(RatingFraction); w.Bool(RatingMet); w.F32(Progress);
|
||||
w.Count(Assets.Count);
|
||||
foreach (var a in Assets) a.Write(ref w);
|
||||
w.Money(Portfolio); w.Money(Cash); w.Money(TotalAssets); w.Money(Loans); w.F32(LoansRate); w.Money(Overdraft);
|
||||
w.Money(TotalLiabilities); w.Money(BalanceNetWorth);
|
||||
w.I32(IncomeYear); w.Bool(IncomePartial);
|
||||
w.Count(Income.Count);
|
||||
foreach (var i in Income) i.Write(ref w);
|
||||
w.Money(Profit);
|
||||
w.Count(LoanList.Count);
|
||||
foreach (var l in LoanList) l.Write(ref w);
|
||||
w.Money(MaxLoan); w.Money(LoanAvailable); w.F32(NewLoanRate); w.Bool(LoansAllowed);
|
||||
w.Count(History.Count);
|
||||
foreach (var p in History) p.Write(ref w);
|
||||
w.Flags(0);
|
||||
}
|
||||
|
||||
public static ClimbReport Read(ref SpanReader r)
|
||||
{
|
||||
long day = r.I64();
|
||||
int company = r.I32();
|
||||
long founded = r.I64();
|
||||
var capital = r.Money();
|
||||
byte tier = r.U8(), next = r.U8();
|
||||
var tiers = new List<TierInfo>();
|
||||
for (int n = r.Count(), i = 0; i < n; i++) tiers.Add(TierInfo.Read(ref r));
|
||||
var worth = r.Money();
|
||||
var worthRequired = r.Money();
|
||||
float worthFraction = r.F32();
|
||||
bool worthMet = r.Bool();
|
||||
int towns = r.I32(), townsRequired = r.I32(), townPopulation = r.I32();
|
||||
float townsFraction = r.F32();
|
||||
bool townsMet = r.Bool();
|
||||
string rating = r.String(), ratingRequired = r.String();
|
||||
float ratingFraction = r.F32();
|
||||
bool ratingMet = r.Bool();
|
||||
float progress = r.F32();
|
||||
var assets = new List<AmountInfo>();
|
||||
for (int n = r.Count(), i = 0; i < n; i++) assets.Add(AmountInfo.Read(ref r));
|
||||
var portfolio = r.Money();
|
||||
var cash = r.Money();
|
||||
var totalAssets = r.Money();
|
||||
var loans = r.Money();
|
||||
float loansRate = r.F32();
|
||||
var overdraft = r.Money();
|
||||
var totalLiabilities = r.Money();
|
||||
var balanceWorth = r.Money();
|
||||
int incomeYear = r.I32();
|
||||
bool partial = r.Bool();
|
||||
var income = new List<AmountInfo>();
|
||||
for (int n = r.Count(), i = 0; i < n; i++) income.Add(AmountInfo.Read(ref r));
|
||||
var profit = r.Money();
|
||||
var loanList = new List<LoanInfo>();
|
||||
for (int n = r.Count(), i = 0; i < n; i++) loanList.Add(LoanInfo.Read(ref r));
|
||||
var maxLoan = r.Money();
|
||||
var available = r.Money();
|
||||
float newRate = r.F32();
|
||||
bool allowed = r.Bool();
|
||||
var history = new List<NetWorthPointInfo>();
|
||||
for (int n = r.Count(), i = 0; i < n; i++) history.Add(NetWorthPointInfo.Read(ref r));
|
||||
r.Flags();
|
||||
return new ClimbReport
|
||||
{
|
||||
Day = day, Company = company, FoundedDay = founded, InitialCapital = capital, Tier = tier, NextTier = next, Tiers = tiers,
|
||||
NetWorth = worth, NetWorthRequired = worthRequired, NetWorthFraction = worthFraction, NetWorthMet = worthMet,
|
||||
Towns = towns, TownsRequired = townsRequired, TownPopulation = townPopulation, TownsFraction = townsFraction, TownsMet = townsMet,
|
||||
Rating = rating, RatingRequired = ratingRequired, RatingFraction = ratingFraction, RatingMet = ratingMet, Progress = progress,
|
||||
Assets = assets, Portfolio = portfolio, Cash = cash, TotalAssets = totalAssets, Loans = loans, LoansRate = loansRate,
|
||||
Overdraft = overdraft, TotalLiabilities = totalLiabilities, BalanceNetWorth = balanceWorth,
|
||||
IncomeYear = incomeYear, IncomePartial = partial, Income = income, Profit = profit,
|
||||
LoanList = loanList, MaxLoan = maxLoan, LoanAvailable = available, NewLoanRate = newRate, LoansAllowed = allowed,
|
||||
History = history,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ public static class MessageCodec
|
||||
MessageId.IndustryCard => IndustryCard.Read(ref r),
|
||||
MessageId.Chronicle => Chronicle.Read(ref r),
|
||||
MessageId.MarketReport => MarketReport.Read(ref r),
|
||||
MessageId.ClimbReport => ClimbReport.Read(ref r),
|
||||
MessageId.MarketTape => MarketTape.Read(ref r),
|
||||
MessageId.CommandResult => CommandResultMessage.Read(ref r),
|
||||
MessageId.Notification => Notification.Read(ref r),
|
||||
|
||||
Reference in new issue
Block a user