Infrastruttura: nome «Rail Enterprise», CI e rilasci su Gitea, documentazione
Il progetto adotta il nome «Rail Enterprise» ovunque (codice RailEnterprise.*, variabili RE_*, intestazioni RESV/RECL, immagine rail-enterprise-server) per allinearsi al repository Gitea. Aggiunge Gitea Actions sul modello di Chronos: CI su PR e main, rilascio da tag con gioco Windows (client Godot + server in server/), server Windows/Linux e immagine Docker nel registro Gitea, nightly. Aggiunge i riferimenti visivi 06–09, i modelli di PR e issue, l'ADR 0014 e aggiorna README (comandi locali), STATE e CLAUDE.md. 120 test verdi. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f6c2a17b4d
commit
c1a0049bcf
300 files changed
+1602
-1045
No files matched your search
@@ -0,0 +1,183 @@
|
||||
using RailEnterprise.Core.Common;
|
||||
using RailEnterprise.Core.Data;
|
||||
|
||||
namespace RailEnterprise.Core.Economy;
|
||||
|
||||
/// <summary>Voci del conto economico di una compagnia.</summary>
|
||||
public enum LedgerEntry : byte
|
||||
{
|
||||
FreightRevenue = 0,
|
||||
PassengerRevenue = 1,
|
||||
Construction = 2,
|
||||
VehiclePurchase = 3,
|
||||
VehicleSale = 4,
|
||||
RunningCosts = 5,
|
||||
TrackMaintenance = 6,
|
||||
FleetMaintenance = 7,
|
||||
Wages = 8,
|
||||
Interest = 9,
|
||||
LoanTaken = 10,
|
||||
LoanRepaid = 11,
|
||||
Trading = 12,
|
||||
IndustryPurchase = 13,
|
||||
Dividends = 14,
|
||||
Shares = 15,
|
||||
Contracts = 16,
|
||||
Penalties = 17,
|
||||
Other = 18,
|
||||
/// <summary>Conguaglio mensile con le industrie possedute (utili versati o perdite coperte).</summary>
|
||||
Industries = 19,
|
||||
/// <summary>Utili versati dalle compagnie controllate.</summary>
|
||||
Subsidiaries = 20,
|
||||
}
|
||||
|
||||
/// <summary>Prestito con rata costante (ammortamento alla francese).</summary>
|
||||
public sealed class Loan
|
||||
{
|
||||
public required LoanId Id { get; init; }
|
||||
public required Money Principal { get; init; }
|
||||
public required double AnnualRate { get; init; }
|
||||
public required int TermMonths { get; init; }
|
||||
public Money Remaining { get; set; }
|
||||
public int MonthsLeft { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>Compagnia ferroviaria (giocatore o IA).</summary>
|
||||
public sealed class Company
|
||||
{
|
||||
public const int EntryCount = 21;
|
||||
|
||||
public required CompanyId Id { get; init; }
|
||||
public required string Name { get; set; }
|
||||
public required bool IsPlayer { get; init; }
|
||||
public string? AiPersonality { get; init; }
|
||||
public required string Color { get; init; }
|
||||
|
||||
public Money Cash { get; set; }
|
||||
public List<Loan> Loans { get; } = [];
|
||||
|
||||
/// <summary>Fido iniziale della difficoltà (base del fido massimo per livello).</summary>
|
||||
public Money BaseCredit { get; set; }
|
||||
|
||||
public CreditRating Rating { get; set; } = CreditRating.BB;
|
||||
|
||||
/// <summary>Politica di manutenzione della flotta (10.2), con eccezioni per linea o treno.</summary>
|
||||
public MaintenancePolicy MaintenancePolicy { get; set; } = MaintenancePolicy.Standard;
|
||||
public int Tier { get; set; } = 1;
|
||||
public int NegativeCashDays { get; set; }
|
||||
public bool Bankrupt { get; set; }
|
||||
public long FoundedDay { get; init; }
|
||||
|
||||
/// <summary>Movimenti del mese corrente per voce (centesimi, segno del flusso di cassa).</summary>
|
||||
public long[] MonthEntries { get; } = new long[EntryCount];
|
||||
|
||||
/// <summary>Movimenti dell'anno corrente per voce.</summary>
|
||||
public long[] YearEntries { get; } = new long[EntryCount];
|
||||
|
||||
/// <summary>Movimenti dell'anno precedente per voce (per rating e borsa).</summary>
|
||||
public long[] LastYearEntries { get; } = new long[EntryCount];
|
||||
|
||||
/// <summary>Valore contabile degli attivi non monetari (binari, stazioni, veicoli), aggiornato mensilmente.</summary>
|
||||
public Money AssetBookValue { get; set; }
|
||||
|
||||
public Money Debt
|
||||
{
|
||||
get
|
||||
{
|
||||
long sum = 0;
|
||||
foreach (var l in Loans) sum += l.Remaining.Cents;
|
||||
return new Money(sum);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Valore di mercato delle azioni di altre compagnie possedute (aggiornato ogni giorno dalla borsa).</summary>
|
||||
public Money PortfolioValue { get; set; }
|
||||
|
||||
/// <summary>Patrimonio netto = cassa + attivi a valore di libro + partecipazioni − debiti.</summary>
|
||||
public Money NetWorth => Cash + AssetBookValue + PortfolioValue - Debt;
|
||||
|
||||
// ------------------------------------------------------------------ borsa e controllo (12.2)
|
||||
|
||||
/// <summary>Libro dei soci.</summary>
|
||||
public ShareRegister Shares { get; } = new();
|
||||
|
||||
/// <summary>Quotata in borsa (le azioni del flottante si scambiano).</summary>
|
||||
public bool Listed { get; set; }
|
||||
|
||||
/// <summary>Prezzo per azione (centesimi, frazionario) e sentiment corrente.</summary>
|
||||
public double SharePrice { get; set; }
|
||||
public double Sentiment { get; set; } = 1;
|
||||
|
||||
/// <summary>Spinta del dividendo straordinario, che decade ogni giorno.</summary>
|
||||
public double ExtraSentiment { get; set; }
|
||||
|
||||
/// <summary>Utile operativo degli ultimi 12 mesi chiusi (anello mensile) e indice del prossimo mese.</summary>
|
||||
public long[] ProfitRing { get; } = new long[12];
|
||||
public int ProfitRingIndex { get; set; }
|
||||
|
||||
/// <summary>Dividendi pagati negli ultimi 12 mesi (anello mensile, centesimi).</summary>
|
||||
public long[] DividendRing { get; } = new long[12];
|
||||
|
||||
/// <summary>Utile dei 12 mesi alla chiusura dell'anno precedente (per la crescita).</summary>
|
||||
public long LastAnnualProfit { get; set; }
|
||||
|
||||
/// <summary>Compagnia che controlla questa (oltre la soglia di controllo) e da quando.</summary>
|
||||
public CompanyId ControlledBy { get; set; } = CompanyId.None;
|
||||
public long ControlSinceDay { get; set; } = -1;
|
||||
|
||||
/// <summary>Fusa in un'altra compagnia: non esiste più come impresa autonoma.</summary>
|
||||
public bool Merged { get; set; }
|
||||
public CompanyId MergedInto { get; set; } = CompanyId.None;
|
||||
|
||||
/// <summary>Amministrazione controllata del giocatore (12.3): fino a quando e sotto chi.</summary>
|
||||
public bool Receivership { get; set; }
|
||||
public long ReceivershipUntilDay { get; set; } = -1;
|
||||
public CompanyId ReceivershipBy { get; set; } = CompanyId.None;
|
||||
|
||||
/// <summary>Giorno della bancarotta (−1 se attiva) e attivi già liquidati.</summary>
|
||||
public long BankruptDay { get; set; } = -1;
|
||||
public bool Liquidated { get; set; }
|
||||
|
||||
/// <summary>Storico dei prezzi dell'azione, un valore al mese (centesimi).</summary>
|
||||
public List<double> PriceHistory { get; } = [];
|
||||
|
||||
/// <summary>Fotografie annuali per la Cronaca finale.</summary>
|
||||
public List<CompanyYear> History { get; } = [];
|
||||
|
||||
/// <summary>Fatti salienti (livelli, quotazione, scalate, fusioni) per la Cronaca finale.</summary>
|
||||
public List<CompanyMilestone> Milestones { get; } = [];
|
||||
|
||||
/// <summary>Compagnia fuori gioco: fallita o fusa.</summary>
|
||||
public bool Defunct => Bankrupt || Merged;
|
||||
|
||||
/// <summary>Utile operativo degli ultimi 12 mesi chiusi.</summary>
|
||||
public long AnnualProfit
|
||||
{
|
||||
get
|
||||
{
|
||||
long sum = 0;
|
||||
foreach (long p in ProfitRing) sum += p;
|
||||
return sum;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Capitalizzazione di borsa (centesimi).</summary>
|
||||
public double MarketCap => SharePrice * Shares.Outstanding;
|
||||
|
||||
/// <summary>Utile operativo dell'anno indicato (ricavi meno costi d'esercizio, esclusi prestiti e investimenti).</summary>
|
||||
public static long OperatingProfit(long[] entries)
|
||||
{
|
||||
long revenue = entries[(int)LedgerEntry.FreightRevenue] + entries[(int)LedgerEntry.PassengerRevenue]
|
||||
+ entries[(int)LedgerEntry.Trading] + entries[(int)LedgerEntry.Contracts]
|
||||
+ entries[(int)LedgerEntry.Industries] + entries[(int)LedgerEntry.Subsidiaries];
|
||||
long costs = entries[(int)LedgerEntry.RunningCosts] + entries[(int)LedgerEntry.TrackMaintenance]
|
||||
+ entries[(int)LedgerEntry.FleetMaintenance] + entries[(int)LedgerEntry.Wages]
|
||||
+ entries[(int)LedgerEntry.Interest] + entries[(int)LedgerEntry.Penalties];
|
||||
return revenue + costs; // i costi sono già negativi
|
||||
}
|
||||
|
||||
public static long Revenue(long[] entries) =>
|
||||
entries[(int)LedgerEntry.FreightRevenue] + entries[(int)LedgerEntry.PassengerRevenue]
|
||||
+ Math.Max(0, entries[(int)LedgerEntry.Trading]) + Math.Max(0, entries[(int)LedgerEntry.Contracts])
|
||||
+ Math.Max(0, entries[(int)LedgerEntry.Industries]) + Math.Max(0, entries[(int)LedgerEntry.Subsidiaries]);
|
||||
}
|
||||
Reference in new issue
Block a user