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>
75 lines
4.2 KiB
C#
75 lines
4.2 KiB
C#
using RailEnterprise.Core.Commands;
|
|
using RailEnterprise.Core.Common;
|
|
using RailEnterprise.Core.Data;
|
|
using RailEnterprise.Core.Rail;
|
|
using RailEnterprise.Tests.Harness;
|
|
using RailEnterprise.Tests.Rail;
|
|
using static RailEnterprise.Tests.Rail.RailFixture;
|
|
|
|
namespace RailEnterprise.Tests.Scenarios;
|
|
|
|
public static class CommutingAcceptanceTests
|
|
{
|
|
/// <summary>
|
|
/// Rete di Valdoria con tre linee: merci (miniere → acciaieria → Valdoria, con minerale, carbone
|
|
/// e acciaio), lavoratori (Borgo Ceresio → acciaieria) e personale (Valdoria → acciaieria).
|
|
/// </summary>
|
|
internal static (RailFixture F, Core.Economy.Industry Mill) ThreeLines()
|
|
{
|
|
var f = Valdoria();
|
|
var (mine, mill, depot) = f.BuildFreightNetwork(waitForConstruction: false);
|
|
int borgo = f.Ok(new BuildStationCommand(K(12.4, 8.0), 2, "Borgo Ceresio"));
|
|
int valdoria = f.Ok(new BuildStationCommand(K(12.8, 4.9), 2, "Valdoria"));
|
|
f.Ok(new BuildTrackCommand(f.Scenario!.Route("borgo", f.Me).Polyline));
|
|
f.Ok(new BuildTrackCommand(f.Scenario!.Route("valdoria", f.Me).Polyline));
|
|
Assert.True(f.RunUntil(() => f.W.Network.Edges.All(e => e.State == EdgeState.Active), 500), "cantieri completati");
|
|
|
|
var steel = f.W.Industries.First(i => i.Def.Id == "steel_mill");
|
|
Assert.True(steel.Efficiency < 0.4, $"efficienza iniziale {steel.Efficiency:P0}");
|
|
|
|
int freight = f.Train(depot, "Merci 1", ("loco_steam_1850", 1), ("wagon_hopper", 6), ("wagon_flat", 2));
|
|
int workers = f.Train(depot, "Operai 1", ("loco_steam_1850", 1), ("coach_worker", 2));
|
|
int staff = f.Train(depot, "Tecnici 1", ("loco_steam_1850", 1), ("coach_staff", 1));
|
|
int lineFreight = f.Ok(new CreateLineCommand("Linea 1, minerale, carbone e acciaio", "#e0a526",
|
|
new[] { new LineStop(new StationId(mine)), new LineStop(new StationId(mill)), new LineStop(new StationId(valdoria)) }));
|
|
int lineWorkers = f.Ok(new CreateLineCommand("Linea 2, operai di Borgo", "#4f7cac",
|
|
new[] { new LineStop(new StationId(borgo)), new LineStop(new StationId(mill)) }));
|
|
int lineStaff = f.Ok(new CreateLineCommand("Linea 3, tecnici di Valdoria", "#b3573e",
|
|
new[] { new LineStop(new StationId(valdoria)), new LineStop(new StationId(mill)) }));
|
|
f.Ok(new AssignTrainCommand(new TrainId(freight), new LineId(lineFreight)));
|
|
f.Ok(new AssignTrainCommand(new TrainId(workers), new LineId(lineWorkers)));
|
|
f.Ok(new AssignTrainCommand(new TrainId(staff), new LineId(lineStaff)));
|
|
return (f, steel);
|
|
}
|
|
|
|
[Test(Description = "Accettazione F2: con tre linee (merci, lavoratori, personale) l'acciaieria passa da < 40 % a > 80 % in 2 anni senza stalli")]
|
|
public static void ThreeLinesBringTheSteelMillAboveEightyPercent()
|
|
{
|
|
var (f, steel) = ThreeLines();
|
|
int startLevel = steel.Level;
|
|
double bestMonth = 0;
|
|
int dpm = f.W.Calendar.DaysPerMonth;
|
|
for (int month = 0; month < 24; month++)
|
|
{
|
|
// media mensile dell'efficienza giornaliera: un picco di un giorno non basta
|
|
double sum = 0;
|
|
for (int d = 0; d < dpm; d++)
|
|
{
|
|
f.W.RunDays(1);
|
|
sum += steel.Efficiency;
|
|
}
|
|
bestMonth = Math.Max(bestMonth, sum / dpm);
|
|
}
|
|
Assert.True(bestMonth > 0.8, $"efficienza media mensile massima {bestMonth:P0}");
|
|
Assert.False(steel.Closed);
|
|
Assert.True(steel.Level >= startLevel, $"livello {steel.Level}");
|
|
Assert.False(f.W.Events.Recent.Any(e => e.Text.Contains("possibile stallo", StringComparison.Ordinal)), "nessuno stallo");
|
|
Assert.True(f.W.Commutes.Any(c => !c.Walking && c.Category == PaxClass.Worker), "contratti di lavoratori su rotaia");
|
|
Assert.True(f.W.Commutes.Any(c => !c.Walking && c.Category == PaxClass.Staff), "contratti di personale su rotaia");
|
|
Assert.True(f.W.Player.YearEntries[(int)Core.Economy.LedgerEntry.PassengerRevenue] > 0, "tariffe dei pendolari incassate");
|
|
Assert.Equal(0L, f.W.MoneyBalanceSum());
|
|
for (int g = 0; g < f.W.Data.GoodCount; g++)
|
|
Assert.Equal(f.W.Goods.ExpectedStock(g), f.W.TotalStock(g), $"merce {f.W.Data.Goods[g].Id}");
|
|
}
|
|
}
|