- TrackGeometry: polilinea raccordata con il raggio della classe - TrackPlanner: campioni ogni 25 m, due passate di pendenza, smussatura, franchi sui fiumi, classificazione delle opere, costi, giorni, vincoli per era (campate per classe di fiume, lunghezza delle gallerie) - Scenari a mano (ScenarioLoader) e tests/scenarios/valdoria.json - viaferrea-tools profile; industrie al prezzo globale; servizi di base Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0191R7vXgtbAvSV4V8tj8uzL
35 lines
1.2 KiB
C#
35 lines
1.2 KiB
C#
using ViaFerrea.Core.Rail;
|
|
using ViaFerrea.Core.Simulation;
|
|
using ViaFerrea.Core.Simulation.Scenarios;
|
|
|
|
namespace ViaFerrea.Tests.Scenarios;
|
|
|
|
/// <summary>Accesso agli scenari di riferimento copiati accanto ai test.</summary>
|
|
public static class ScenarioHelper
|
|
{
|
|
public static string PathOf(string name)
|
|
{
|
|
string beside = Path.Combine(AppContext.BaseDirectory, "scenarios", name + ".json");
|
|
if (File.Exists(beside)) return beside;
|
|
var dir = new DirectoryInfo(Directory.GetCurrentDirectory());
|
|
while (dir is not null)
|
|
{
|
|
string candidate = Path.Combine(dir.FullName, "tests", "ViaFerrea.Tests", "scenarios", name + ".json");
|
|
if (File.Exists(candidate)) return candidate;
|
|
dir = dir.Parent;
|
|
}
|
|
throw new FileNotFoundException($"Scenario {name} non trovato");
|
|
}
|
|
|
|
public static LoadedScenario Load(string name) => ScenarioLoader.LoadFile(TestData.Data, PathOf(name));
|
|
|
|
public static TrackPlanContext PlanContext(World w) => new()
|
|
{
|
|
Data = w.Data,
|
|
Sampler = w.Sampler,
|
|
Year = w.Clock.Year,
|
|
CostMultiplier = w.Difficulty.ConstructionCostMultiplier,
|
|
NearestTownEdgeKm = p => w.Towns.Min(t => w.TownEdgeDistanceKm(t, p)),
|
|
};
|
|
}
|