BuCol Setup
This commit is contained in:
@ -18,7 +18,6 @@ public partial class BuColViewModel : ViewModelBase
|
||||
public BuColViewModel()
|
||||
{
|
||||
var PlanetManager = Locator.Current.GetService<PlanetManager>()!;
|
||||
PlanetManager.__test__Init();
|
||||
|
||||
PlanetManager.PlayerPlanetsSource
|
||||
.ObserveOn(RxApp.MainThreadScheduler)
|
||||
|
@ -30,6 +30,31 @@ public partial class PlayerPlanetViewModel : ViewModelBase
|
||||
.Select(popTgt => this.MaxPopulation * popTgt / 10000 * 100)
|
||||
.ToProperty(this, vm => vm.PopulationTarget);
|
||||
|
||||
_populationToShipHelper = this
|
||||
.WhenAnyValue(vm => vm.PopulationTarget)
|
||||
.Select(popToShip => this.ComputePopulationToShip())
|
||||
.ToProperty(this, vm => vm.PopulationToShip);
|
||||
|
||||
_targetFactoriesHelper = this
|
||||
.WhenAnyValue(vm => vm.PopulationTarget)
|
||||
.Select(tgtFact => GameEngine.MaxOperableFactoriesForPlayer(_populationTarget, Value))
|
||||
.ToProperty(this, vm => vm.TargetFactories);
|
||||
|
||||
_remainingFactoriesHelper = this
|
||||
.WhenAnyValue(vm => vm.TargetFactories)
|
||||
.Select(factRem => Factories < _targetFactories ? _targetFactories - Factories : 0)
|
||||
.ToProperty(this, vm => vm.RemainingFactories);
|
||||
|
||||
_factoryGermaniumDeltaHelper = this
|
||||
.WhenAnyValue(vm => vm.RemainingFactories)
|
||||
.Select(gerCost => ComputeFactoryGermaniumDelta())
|
||||
.ToProperty(this, vm => vm.FactoryGermaniumDelta);
|
||||
|
||||
_remainingMinesHelper = this
|
||||
.WhenAnyValue(vm => vm.PopulationTarget)
|
||||
.Select(remMines => Math.Max(0, GameEngine.MaxOperableMinesForPlayer(_populationTarget, Value) - Mines))
|
||||
.ToProperty(this, vm => vm.RemainingMines);
|
||||
|
||||
this.WhenActivated((CompositeDisposable disposables) =>
|
||||
{
|
||||
// /* handle activation */
|
||||
@ -122,6 +147,8 @@ public partial class PlayerPlanetViewModel : ViewModelBase
|
||||
|
||||
public int PopulationGrowth => GameEngine.PlanetPopGrowthForPlayer(Population, Value);
|
||||
|
||||
public int PopulationT1 => Population + PopulationGrowth /* TODO + Pop En Route */;
|
||||
|
||||
public int BuildableFactories => GameEngine.MaxBuildableFactoriesForPlayer(Value);
|
||||
|
||||
public int BuildableMines => GameEngine.MaxBuildableMinesForPlayer(Value);
|
||||
@ -134,9 +161,57 @@ public partial class PlayerPlanetViewModel : ViewModelBase
|
||||
|
||||
public int ResourcesFromFactories => GameEngine.ResourcesFromFactForPlayer(Population, Factories, Value);
|
||||
|
||||
public int AvailableIronium => MRIronium + SurfaceIronium;
|
||||
|
||||
public int AvailableBoranium => MRBoranium + SurfaceBoranium;
|
||||
|
||||
public int AvailableGermanium => MRGermanium + SurfaceGermanium;
|
||||
|
||||
[ObservableAsProperty]
|
||||
private int _populationTarget;
|
||||
|
||||
[ObservableAsProperty]
|
||||
private int _populationToShip;
|
||||
|
||||
[ObservableAsProperty]
|
||||
private int _targetFactories;
|
||||
|
||||
[ObservableAsProperty]
|
||||
private int _remainingFactories;
|
||||
|
||||
[ObservableAsProperty]
|
||||
private int _factoryGermaniumDelta;
|
||||
|
||||
[ObservableAsProperty]
|
||||
private int _remainingMines;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Helper functions
|
||||
|
||||
private int ComputePopulationToShip()
|
||||
{
|
||||
if (Population >= _populationTarget)
|
||||
return Population - _populationTarget;
|
||||
|
||||
if (PopulationT1 < _populationTarget)
|
||||
return PopulationT1 - _populationTarget;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int ComputeFactoryGermaniumDelta()
|
||||
{
|
||||
int gerReq = GameEngine.FactoryGermaniumCostForPlayer(_remainingFactories);
|
||||
|
||||
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.
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
Reference in New Issue
Block a user