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);
        }
Esempio n. 2
0
        public AllianceTechesOut(AllianceRoleDataModel userRole, Dictionary <TechType, ItemProgress> dbAllianceTeches)
        {
            CanUpgrade = userRole.SetTech;
            var techService = new BattleTeches(dbAllianceTeches);
            var teches      = techService.GetTeches(false);

            teches.ForEach(i =>
            {
                i.Value.Progress.Advanced = i.Value.GetPropertiesView(true);
            });
            Teches = techService.ConvertToTechesOut(true);
            Teches.ForEach(i =>
            {
                i.Value.CalcResultPrice(false);
            });

            SetComplexButtonView();
        }
        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);
        }