@inject IEconomyComparisonService economyComparisonService
@implements IDisposable
Starting Advantage
At Time: @StartingAdvantageAtTime | T @Interval.ToTime(StartingAdvantageAtTime)
Peak Advantage
By Alloy: @PeakAdvantageByAlloy
At Time: @PeakAdvantageAtTime | T @Interval.ToTime(PeakAdvantageAtTime)
Worsening Time
At Time: @WorseningTime | T @Interval.ToTime(WorseningTime)
Miracle Time
At Time: @MiracleTime | T @Interval.ToTime(MiracleTime)
@code {
private int StartingAdvantageAtTime = 0;
private int PeakAdvantageByAlloy = 0;
private int PeakAdvantageAtTime = 0;
private int WorseningTime = 0;
private int MiracleTime = 0;
protected override void OnInitialized()
{
base.OnInitialized();
economyComparisonService.Subscribe(CalculateDifferences);
}
void IDisposable.Dispose()
{
economyComparisonService.Unsubscribe(CalculateDifferences);
}
void CalculateDifferences()
{
PeakAdvantageByAlloy = 0;
StartingAdvantageAtTime = 0;
WorseningTime = 0;
MiracleTime = 0;
for (var interval = 0; interval < economyComparisonService.BuildsToCompare[0].EconomyOverTimeModel.Count; interval++)
{
var yourEconomy = economyComparisonService.BuildsToCompare[0].EconomyOverTimeModel[interval];
var theirEconomy = economyComparisonService.BuildsToCompare[1].EconomyOverTimeModel[interval];
var deltaEconomy = yourEconomy.Alloy - theirEconomy.Alloy;
if (deltaEconomy >= 0)
{
if (deltaEconomy > PeakAdvantageByAlloy)
{
if (StartingAdvantageAtTime == 0)
{
StartingAdvantageAtTime = interval;
}
PeakAdvantageByAlloy = (int)deltaEconomy;
PeakAdvantageAtTime = interval;
}
}
else
{
if (PeakAdvantageByAlloy > 0 && WorseningTime == 0)
{
WorseningTime = interval;
}
if (deltaEconomy < -1000 && MiracleTime == 0)
{
MiracleTime = interval;
}
}
}
StateHasChanged();
}
}