private static void FixProgreses(UserMothershipDataModel mother, UserPremiumWorkModel userPremium) { #region Premium var pt = userPremium.TimeLineStatus; #endregion #region CalcResource var lastUpgradeProductionTime = mother.LastUpgradeProductionTime; var beforeResource = mother.Resources.CloneDeep(); var last = pt?.Status?.Last(); var curPrem = (last != null && (bool)last); // var motherExtatracionLevel = 1; var motherExtatracionLevel = 22; StorageResources.CalculateProductionResources(beforeResource, mother.ExtractionProportin, ref lastUpgradeProductionTime, motherExtatracionLevel, curPrem, ExtractionModule.BaseProportion.Ir, ExtractionModule.BaseProportion.Dm, ExtractionModule.GetPower, (res) => { StorageResourcesService.FixCurrentResources(res); } ); if (!mother.Resources.Equals(beforeResource)) { mother.Resources = beforeResource; } #region Laboratory if (mother.TechProgress.Select(i => i.Value).ToList().Any(i => i.IsProgress == true)) { var techService = new BattleTeches(mother.TechProgress); if (techService.CalculateTechProgreses(techService.GetTeches(false), userPremium)) { mother.TechProgress = techService.ConvertToDbTeches(); } } #endregion mother.LastUpgradeProductionTime = lastUpgradeProductionTime; #endregion if (mother.UnitProgress == null || !mother.UnitProgress.Any()) { if (mother.UnitProgress == null) { mother.UnitProgress = new Dictionary <UnitType, TurnedUnit>(); } return; } #region Calc UnitProgress const int shipyardLevel = 1; var pureTurn = mother.UnitProgress; var hangarUnits = mother.Hangar; bool unitInProgress; TurnedUnit.CalculateUserUnits(pt, ref pureTurn, out unitInProgress, ref hangarUnits, shipyardLevel, Unit.CalculateTrickyUnitTimeProduction, (unitType) => UnitHelper.GetBaseUnit(unitType).BasePrice.TimeProduction, Unit.CalculateTimeProduction); mother.UnitProgress = unitInProgress ? pureTurn : new Dictionary <UnitType, TurnedUnit>(); mother.Hangar = hangarUnits; #endregion }
private static void FixProgreses(GDetailPlanetDataModel planet, UserPremiumWorkModel userPremium) { #region Calc BuildProgress var pt = userPremium.TimeLineStatus; if (planet.BuildEnergyConverter.CheckProgressIsDone()) { ItemProgress.ProgressUpdateComplite(planet.BuildEnergyConverter); } if (planet.BuildExtractionModule.CheckProgressIsDone()) { ItemProgress.ProgressUpdateComplite(planet.BuildExtractionModule); } if (planet.BuildSpaceShipyard.CheckProgressIsDone()) { ItemProgress.ProgressUpdateComplite(planet.BuildSpaceShipyard); } if (planet.BuildStorage.CheckProgressIsDone()) { ItemProgress.ProgressUpdateComplite(planet.BuildStorage); } if (planet.Turels.CheckProgressIsDone()) { ItemProgress.ProgressUpdateComplite(planet.Turels); } var extractionLevel = 1; if (planet.BuildExtractionModule?.Level != null) { extractionLevel = (int)planet.BuildExtractionModule.Level; } #endregion #region CalcResource var lastUpgradeProductionTime = planet.LastUpgradeProductionTime; var beforeResource = planet.Resources.CloneDeep(); var last = pt?.Status?.Last(); var curPrem = (last != null && (bool)last); StorageResources.CalculateProductionResources(beforeResource, planet.ExtractionProportin, ref lastUpgradeProductionTime, extractionLevel, curPrem, ExtractionModule.BaseProportion.Ir, ExtractionModule.BaseProportion.Dm, ExtractionModule.GetPower, (res) => { StorageResourcesService.FixCurrentResources(res); }); if (!planet.Resources.Equals(beforeResource)) { planet.Resources = beforeResource; } planet.LastUpgradeProductionTime = lastUpgradeProductionTime; #endregion if (planet.UnitProgress == null || !planet.UnitProgress.Any()) { return; } #region Calc UnitProgress var shipyardLevel = planet.BuildSpaceShipyard.Level ?? 1; var pureTurn = planet.UnitProgress; var hangarUnits = planet.Hangar; bool unitInProgress; TurnedUnit.CalculateUserUnits(pt, ref pureTurn, out unitInProgress, ref hangarUnits, shipyardLevel, Unit.CalculateTrickyUnitTimeProduction, (unitType) => UnitHelper.GetBaseUnit(unitType).BasePrice.TimeProduction, Unit.CalculateTimeProduction); planet.UnitProgress = unitInProgress ? pureTurn : new Dictionary <UnitType, TurnedUnit>(); planet.Hangar = hangarUnits; #endregion }