public IList <EstateItemOut> GetList(IDbConnection connection, UserMothershipDataModel mother, IList <GDetailPlanetDataModel> planets)
        {
            var motherAdress = _systemService.GetSystem(connection, mother.StartSystemId, i => i);
            var list         = new List <EstateItemOut>
            {
                new EstateItemOut
                {
                    Name          = "MotherShip",
                    Type          = false,
                    Sector        = motherAdress.SectorId,
                    System        = motherAdress.Id,
                    Galaxy        = motherAdress.GalaxyId,
                    TextureTypeId = 2000,
                    GameTypeId    = 20
                }
            };

            if (!planets.Any())
            {
                return(list);
            }
            var estatePlenets = _detailPlanetService.GetUserEstates(connection, planets);

            list.AddRange(estatePlenets);

            return(list);
        }
示例#2
0
        public UserMothershipDataModel CreateMother(IDbConnection connection, int userId, int startSystem = 1)
        {
            var r         = StorageResources.InitMotherResources();
            var curMother = GetMother(connection, userId, false);

            if (curMother != null)
            {
                return(curMother);
            }

            var teches = new BattleTeches();

            teches.CreateStartTeches();
            var userTeches = teches.ConvertToDbTeches();

            var newMother = new UserMothershipDataModel
            {
                Id                  = userId,
                StartSystemId       = startSystem,
                Resources           = r,
                Hangar              = UnitList.InitUnitsInOwn(),
                ExtractionProportin = MaterialResource.InitBaseOwnProportion(),
                UnitProgress        = new Dictionary <UnitType, TurnedUnit>(),
                TechProgress        = userTeches
            };

            return(AddOrUpdate(connection, newMother));
        }
示例#3
0
        public UserMothershipDataModel Update(IDbConnection connection, UserMothershipDataModel updatedData)
        {
            var suc = _uMothershipRepo.Update(connection, updatedData);

            if (suc)
            {
                return(_uMothershipCache.UpdateLocalItem(connection, updatedData));
            }
            return(_uMothershipCache.GetById(connection, updatedData.Id, true));
        }
 public UserMothershipDataModel RunUser(IDbConnection connection, UserMothershipDataModel mother, UserPremiumWorkModel userPremium, IMothershipService motherService, IUMotherJumpService motherJump)
 {
     if (mother == null)
     {
         return(null);
     }
     motherJump.SinchronizeByMotherId(connection, mother.Id);
     FixProgreses(mother, userPremium);
     return(motherService.Update(connection, mother));
 }
 public override List <BuildItemUnitView> GetMotherBuildList(UserMothershipDataModel mother,
                                                             UserPremiumWorkModel userPremium)
 {
     return(new List <BuildItemUnitView>
     {
         _storage.GetMotherViewModel(userPremium.IsActive, mother.Resources),
         _extractionModule.GetMotherViewModel(userPremium.IsActive,
                                              StorageResources.StorageProportion(mother.ExtractionProportin)),
         _energyConverter.GetMotherViewModel(userPremium.IsActive)
     });
 }
        private static Dictionary <UnitType, HangarUnitsOut> GetherMotherUnits(UserMothershipDataModel mother,
                                                                               UserPremiumWorkModel userPremium)
        {
            var outUnits = UnitList.ConvertToHangar(mother.Hangar);

            if (mother.UnitProgress == null || !mother.UnitProgress.Any())
            {
                return(outUnits);
            }
            SetUnitUpgradeInHangarUnit(userPremium, 1, ref outUnits, mother.UnitProgress);
            return(outUnits);
        }
 public void CreateMotherNpc(IDbConnection connection, UserMothershipDataModel npc)
 {
     try
     {
         _mothershipService.AddOrUpdate(connection, npc);
     }
     //catch (DuplicateKeyException e)
     catch (Exception e)
     {
         var q = e;
         throw;
     }
 }
        public override List <BuildItemUnitView> GetMotherBuildList(UserMothershipDataModel mother,
                                                                    UserPremiumWorkModel userPremium)
        {
            var teches    = new BattleTeches(mother.TechProgress);
            var techesOut = teches.ConvertToTechesOut(false);


            var propertiesView = teches.CreateBuildItemTechData(false);
            var result         = new List <BuildItemUnitView>();

            techesOut.ForEach(i =>
            {
                var techOut = techesOut[i.Value.TechType];
                techOut.CalcResultPrice(userPremium.IsActive);
                var model = new BuildItemUnitView
                {
                    Progress      = i.Value.Progress,
                    TranslateName = i.Value.Text.Name,
                    NativeName    = i.Value.TechType.ToString(),
                    IconSelf      = i.Value.SpriteImages.Icon,
                    Info          = new BuildDropItemInfo
                    {
                        Description = i.Value.Text.Description,
                        DropImage   = i.Value.SpriteImages.Detail,
                        Data        = propertiesView[i.Value.TechType]
                    },
                    Update = new BuildDropItemUpdate
                    {
                        Properties    = propertiesView[i.Value.TechType].Properties.Select(p => p.Value).ToList(),
                        Price         = i.Value.BasePrice,
                        IsUnitUpgrade = false
                    },
                    IsBuildItem  = false,
                    AdvancedData = new Dictionary <string, object>
                    {
                        { "TechOut", techOut }
                    }
                };
                model.SetComplexButtonView();
                if (!techOut.Disabled)
                {
                    model.Update.SetButtons(true);
                }


                result.Add(model);
            });
            return(result);
        }
 private static bool _needUpdate(UserMothershipDataModel mother)
 {
     if (!mother.Resources.AllFull())
     {
         return(true);
     }
     if (mother.UnitProgress != null && mother.UnitProgress.Any())
     {
         return(true);
     }
     if (mother.LaboratoryProgress.IsProgress != null && mother.LaboratoryProgress.IsProgress == true)
     {
         return(true);
     }
     return(mother.TechProgress.Any(techProgress => techProgress.Value.IsProgress == true));
 }
示例#10
0
 public ItemProgress FixMotherItemProgress(UnitType unitType, UserMothershipDataModel mother,
                                           UserPremiumWorkModel userPremium)
 {
     return(FixItemProgress(unitType, mother.Hangar, mother.UnitProgress, userPremium));
 }
示例#11
0
        public bool CallculateNewResources(IDbConnection connection, IMothershipService motherService, UserMothershipDataModel mother, EnergyConverterChangeOut clientData)
        {
            var dbRes         = mother.Resources;
            var calculatedRes = _callculateNewResources(dbRes, clientData, 1);

            if (dbRes.Equals(calculatedRes))
            {
                return(false);
            }
            mother.Resources = calculatedRes;
            mother           = motherService.AddOrUpdate(connection, mother);
            return(true);
        }
 public UserMothershipDataModel UserMothership(IDbConnection connection, UserMothershipDataModel mother, UserPremiumWorkModel userPremium, IMothershipService motherService, IUMotherJumpService motherJump)
 {
     return(_motherRunner.RunUser(connection, mother, userPremium, motherService, motherJump));
 }
示例#13
0
        /// <summary>
        ///     Предварительные данные должны быть синхронизированны
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="mother"></param>
        /// <param name="allianceTech"></param>
        /// <param name="confederationService"></param>
        /// <param name="storeService"></param>
        /// <returns></returns>
        public static Dictionary <UnitType, Dictionary <BattleStatTypes, IBattleStatsDouble> > GetUnitStatsAndMods(IDbConnection connection, UserMothershipDataModel mother, AllianceTechDataModel allianceTech, IConfederationService confederationService, IStoreService storeService)
        {
            var boosersMods           = GetBoosterBonuses(connection, mother.Id, storeService);
            var officerBonus          = confederationService.GetOfficerBonus(connection, allianceTech.Id);
            var userTechesService     = new BattleTeches(mother.TechProgress);
            var allianceTechesService = new BattleTeches(allianceTech.Teches);

            return(GetUnitStatsAndMods(mother.Id, userTechesService, allianceTechesService, officerBonus, boosersMods));
        }
        public PlanshetViewData GetMotherCollection(IDbConnection connection, UserDataModel user, UserPremiumWorkModel userPremium, UserMothershipDataModel own, bool synchronize = true)
        {
            var mother = own;

            if (synchronize)
            {
                mother = _synchronizer.UserMothership(connection, mother, userPremium, _mothershipService, _motherJumpService);
            }
            var motherPlanshet = _getMotherCollection(GetMotherBuildList(mother, userPremium));

            motherPlanshet.IsMother = true;
            return(motherPlanshet);
        }
 public abstract List <BuildItemUnitView> GetMotherBuildList(UserMothershipDataModel mother,
                                                             UserPremiumWorkModel userPremium);
示例#16
0
        public Dictionary <string, IPlanshetViewData> GetMotherEstate(IDbConnection connection, UserDataModel user, UserPremiumWorkModel userPremium, UserMothershipDataModel own, bool synchronize = true)
        {
            var mother = own;

            if (synchronize)
            {
                mother = _synchronizer.UserMothership(connection, own, userPremium, _mothershipService, _motherJumpService);
            }
            var ic         = _industrialComplex.GetMotherCollection(connection, user, userPremium, mother, false);
            var shipyard   = _shipyard.GetMotherCollection(connection, user, userPremium, mother, false);
            var laboratory = _laboratory.GetMotherCollection(connection, user, userPremium, mother, false);

            return(new Dictionary <string, IPlanshetViewData>
            {
                { ic.UniqueId, ic },
                { shipyard.UniqueId, shipyard },
                { laboratory.UniqueId, laboratory }
            });
        }
示例#17
0
 public override List <BuildItemUnitView> GetMotherBuildList(UserMothershipDataModel mother, UserPremiumWorkModel userPremium)
 {
     return(Unit.GetBuildItemUnitViewList(mother.Hangar, mother.UnitProgress, null, userPremium, OwnType.Mother));
 }
        public object SetTechTurn(IDbConnection connection, TechType techType, UnitTurnOut input, UserMothershipDataModel mother, UserPremiumWorkModel premium)
        {
            var teches    = new BattleTeches(mother.TechProgress);
            var techesOut = teches.ConvertToTechesOut(false);
            var tech      = techesOut[techType];

            if (tech.Disabled)
            {
                throw new NotImplementedException(Error.TechDisabled);
            }
            tech.CalcResultPrice(premium.IsActive);
            var price = tech.BasePrice;

            if (input.ForCc)
            {
                var cc          = (int)price.Cc;
                var preResultCc = _storeService.BalanceCalcResultCc(connection, input.UserId, cc);
                ItemProgress.ProgressUpdateComplite(tech.Progress);
                mother.TechProgress = teches.ConvertToDbTeches();
                _mothershipService.AddOrUpdate(connection, mother);
                _storeService.AddOrUpdateBalance(connection, preResultCc);
                return(preResultCc.Quantity);
            }
            if (tech.Progress.IsProgress == true)
            {
                throw new Exception(Error.TechInProgress);
            }

            var bu = new BuildUpgrade(mother.Resources, tech.Progress, techType.ToString());

            var newBu = BuildUpgrade.SetUpgrade(bu, price);

            newBu.Progress.StartTime = UnixTime.UtcNow();
            mother.Resources         = newBu.StorageResources;
            tech.Progress.SetFromOther(newBu.Progress);
            mother.TechProgress = teches.ConvertToDbTeches();
            _mothershipService.AddOrUpdate(connection, mother);
            return(true);
        }
示例#19
0
        public UserMothershipDataModel AddOrUpdate(IDbConnection connection, UserMothershipDataModel dataModel)
        {
            var db = _uMothershipRepo.AddOrUpdateeModel(connection, dataModel);

            return(_uMothershipCache.UpdateLocalItem(connection, db));
        }
 public override List <BuildItemUnitView> GetMotherBuildList(UserMothershipDataModel mother,
                                                             UserPremiumWorkModel userPremium)
 {
     throw new NotImplementedException("ICommandCenter for mother not exist");
 }
        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
        }
        public ItemProgress SetMotherUnitTurn(IDbConnection connection, UnitType unitType, int count, UserMothershipDataModel mother, UserPremiumWorkModel userPremium)
        {
            var       hangarCount = mother.Hangar[unitType];
            UnitModel unit        = null;

            GetTurnResultData(connection, unitType, count, userPremium.UserId, 0, mother.Resources, mother.UnitProgress,
                              (newUnitModel, newRes) =>
            {
                unit             = newUnitModel;
                mother.Resources = newRes;
            });

            _mother.AddOrUpdate(connection, mother);
            return(CalculateUnitProgress(mother.UnitProgress[unitType], unit.BasePrice.TimeProduction, 1, userPremium,
                                         hangarCount));
        }