Intermediate fleet summaries attempt
This commit is contained in:
		@@ -50,7 +50,10 @@ public partial class PlayerPlanetViewModel : ViewModelBase
 | 
			
		||||
            .ToProperty(this, vm => vm.RemainingFactories);
 | 
			
		||||
 | 
			
		||||
        _factoryGermaniumDeltaHelper = this
 | 
			
		||||
            .WhenAnyValue(vm => vm.RemainingFactories)
 | 
			
		||||
            .WhenAnyValue(vm => vm.RemainingFactories,
 | 
			
		||||
                vm => vm.EnRouteGermanium,
 | 
			
		||||
                vm => vm.SurfaceGermanium,
 | 
			
		||||
                (remFact, gerEnRoute, surGer) => remFact)
 | 
			
		||||
            .Select(gerCost => ComputeFactoryGermaniumDelta())
 | 
			
		||||
            .ToProperty(this, vm => vm.FactoryGermaniumDelta);
 | 
			
		||||
 | 
			
		||||
@@ -67,15 +70,36 @@ public partial class PlayerPlanetViewModel : ViewModelBase
 | 
			
		||||
            .Log(this, "fleetSummaryChange", change => $"{Name}: {change.Reason}: {change.Previous} => {change.Current}")
 | 
			
		||||
        ;
 | 
			
		||||
 | 
			
		||||
        _populationEnRouteHelper = _fleetSummaryChanges
 | 
			
		||||
        _enRoutePopulationHelper = _fleetSummaryChanges
 | 
			
		||||
            .Select(change => change.Reason != ChangeReason.Remove ? change.Current.TotalColonists : 0)
 | 
			
		||||
            .Log(this, "PopulationEnRoute", pop => $"{Name}: {pop}")
 | 
			
		||||
            .ToProperty(this, vm => vm.PopulationEnRoute)
 | 
			
		||||
            .Log(this, "EnRoutePopulation", pop => $"{Name}: {pop}")
 | 
			
		||||
            .ToProperty(this, vm => vm.EnRoutePopulation)
 | 
			
		||||
        ;
 | 
			
		||||
 | 
			
		||||
        _enRouteIroniumHelper = _fleetSummaryChanges
 | 
			
		||||
            .Select(change => change.Reason != ChangeReason.Remove ? change.Current.TotalIronium : 0)
 | 
			
		||||
            .Log(this, "EnRouteIronium", ironium => $"{Name}: {ironium}")
 | 
			
		||||
            .ToProperty(this, vm => vm.EnRouteIronium)
 | 
			
		||||
        ;
 | 
			
		||||
 | 
			
		||||
        _enRouteBoraniumHelper = _fleetSummaryChanges
 | 
			
		||||
            .Select(change => change.Reason != ChangeReason.Remove ? change.Current.TotalBoranium : 0)
 | 
			
		||||
            .Log(this, "EnRouteBoranium", boranium => $"{Name}: {boranium}")
 | 
			
		||||
            .ToProperty(this, vm => vm.EnRouteBoranium)
 | 
			
		||||
        ;
 | 
			
		||||
 | 
			
		||||
        _enRouteGermaniumHelper = _fleetSummaryChanges
 | 
			
		||||
            .Select(change => change.Reason != ChangeReason.Remove ? change.Current.TotalGermanium : 0)
 | 
			
		||||
            .Log(this, "EnRouteGermanium", germanium => $"{Name}: {germanium}")
 | 
			
		||||
            .ToProperty(this, vm => vm.EnRouteGermanium)
 | 
			
		||||
        ;
 | 
			
		||||
        
 | 
			
		||||
        this.WhenActivated((CompositeDisposable disposables) => 
 | 
			
		||||
        {
 | 
			
		||||
            disposables.Add(_populationEnRouteHelper);
 | 
			
		||||
            disposables.Add(_enRoutePopulationHelper);
 | 
			
		||||
            disposables.Add(_enRouteIroniumHelper);
 | 
			
		||||
            disposables.Add(_enRouteBoraniumHelper);
 | 
			
		||||
            disposables.Add(_enRouteGermaniumHelper);
 | 
			
		||||
 | 
			
		||||
            // /* handle activation */
 | 
			
		||||
            // Disposable
 | 
			
		||||
@@ -167,7 +191,7 @@ public partial class PlayerPlanetViewModel : ViewModelBase
 | 
			
		||||
 | 
			
		||||
    public int PopulationGrowth => GameEngine.PlanetPopGrowthForPlayer(Population, Value);
 | 
			
		||||
 | 
			
		||||
    public int PopulationT1 => Population + PopulationGrowth /* TODO + Pop En Route */;
 | 
			
		||||
    public int PopulationT1 => Population + PopulationGrowth + EnRoutePopulation;
 | 
			
		||||
 | 
			
		||||
    public int BuildableFactories => GameEngine.MaxBuildableFactoriesForPlayer(Value);
 | 
			
		||||
 | 
			
		||||
@@ -187,27 +211,26 @@ public partial class PlayerPlanetViewModel : ViewModelBase
 | 
			
		||||
 | 
			
		||||
    public int AvailableGermanium => MRGermanium + SurfaceGermanium;
 | 
			
		||||
 | 
			
		||||
    [ObservableAsProperty]
 | 
			
		||||
    private int _populationTarget;
 | 
			
		||||
    [ObservableAsProperty] private int _populationTarget;
 | 
			
		||||
 | 
			
		||||
    [ObservableAsProperty]
 | 
			
		||||
    private int _populationToShip;
 | 
			
		||||
    [ObservableAsProperty] private int _populationToShip;
 | 
			
		||||
 | 
			
		||||
    [ObservableAsProperty]
 | 
			
		||||
    private int _targetFactories;
 | 
			
		||||
    [ObservableAsProperty] private int _targetFactories;
 | 
			
		||||
 | 
			
		||||
    [ObservableAsProperty]
 | 
			
		||||
    private int _remainingFactories;
 | 
			
		||||
    [ObservableAsProperty] private int _remainingFactories;
 | 
			
		||||
 | 
			
		||||
    [ObservableAsProperty]
 | 
			
		||||
    private int _factoryGermaniumDelta;
 | 
			
		||||
    [ObservableAsProperty] private int _factoryGermaniumDelta;
 | 
			
		||||
 | 
			
		||||
    [ObservableAsProperty]
 | 
			
		||||
    private int _remainingMines;
 | 
			
		||||
    [ObservableAsProperty] private int _remainingMines;
 | 
			
		||||
 | 
			
		||||
    [ObservableAsProperty]
 | 
			
		||||
    private int _populationEnRoute;
 | 
			
		||||
    [ObservableAsProperty] private int _enRoutePopulation;
 | 
			
		||||
 | 
			
		||||
    [ObservableAsProperty] private int _enRouteIronium;
 | 
			
		||||
 | 
			
		||||
    [ObservableAsProperty] private int _enRouteBoranium;
 | 
			
		||||
 | 
			
		||||
    [ObservableAsProperty] private int _enRouteGermanium;
 | 
			
		||||
    
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region Helper functions
 | 
			
		||||
@@ -230,24 +253,19 @@ public partial class PlayerPlanetViewModel : ViewModelBase
 | 
			
		||||
        if (gerReq < AvailableGermanium)
 | 
			
		||||
            return Math.Max(0, SurfaceGermanium - gerReq);
 | 
			
		||||
 | 
			
		||||
        return AvailableGermanium + MRGermanium - gerReq;
 | 
			
		||||
        // TODO: Extrapolate to T1, so that excess Germanium is visible.
 | 
			
		||||
        // TODO: Take shipping into account.
 | 
			
		||||
        // When extrapolating to T1, we take the available Germanium
 | 
			
		||||
        // this turn (surface + MR), add MR a second time (the mines
 | 
			
		||||
        // will yield it next turn as well) and add the inbound shipping
 | 
			
		||||
        // as this will be available next turn as well. That#s the basis
 | 
			
		||||
        // for the Germanium requirement in the next turn. We will top
 | 
			
		||||
        // it out at 0, as we don't have any Germanium available this
 | 
			
		||||
        // turn, and we don't want to show a projected surplus here
 | 
			
		||||
        // (we can't pull it off the planet in this turn anyway).
 | 
			
		||||
        return Math.Min(
 | 
			
		||||
            AvailableGermanium + EnRouteGermanium + MRGermanium - gerReq
 | 
			
		||||
            , 0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
    private int ComputePopulationEnRoute()
 | 
			
		||||
    {
 | 
			
		||||
        using var db = Locator.Current.GetService<Model.StarsDatabase>()!;
 | 
			
		||||
 | 
			
		||||
        var enRoute = from flt in db.Fleet
 | 
			
		||||
            where flt.OwnerFileId == Game.Player.PlayerFileId && flt.TrueDestination == Planet.Name
 | 
			
		||||
            select new {  Colonists = flt.Sum(f => f.Colonists) };
 | 
			
		||||
 | 
			
		||||
        return enRoute.Colonists ?? 0;
 | 
			
		||||
    }
 | 
			
		||||
    */
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user