示例#1
0
        public async Task <CompanyLvUpResult> CompanyLvUp(CompanyLvUpResult result)
        {
            var role = LogicServer.User.role;
            var bg   = LogicServer.User.bag;


            var company = await CompanyDataHelper.Instance.GetCompanyByRoleIdAsync(role.Id);

            var department = await DepartmentGroupDataHelper.Instance.GetDepartMentGroupByRoleId(role.Id);

            var cmpConfig = CompanyInfo.GetForId(company.Level + 1);

            if (company == null || department == null)
            {
                result.Result = GameEnum.WsResult.NotFoundCompany;
                return(result);
            }
            if (CheckCompanyLvUp(company, department))
            {
                result.Level = await CompanyLevelUp(role.Id, company, cmpConfig.CostGold, (int)Currency.Gold);

                return(result);
            }
            else
            {
                result.Result = GameEnum.WsResult.CompanyLvUpFailed;
                return(result);
            }
        }
示例#2
0
        private bool CheckCompanyLvUp(Company r, DepartmentGroup department)
        {
            var bg  = LogicServer.User.bag;
            var cmp = CompanyInfo.GetForId(r.Level);

            bg.Items.TryGetValue((int)Currency.Gold, out Model.Data.General.Item count);
            if (department.Finance.Level >= cmp.FinanceLv && department.Investment.Level >= cmp.InvestmentLv && department.Market.Level >= cmp.MarketLv &&
                department.Personnel.Level >= cmp.PersonnelLv && count.CurCount >= cmp.CostGold && r.CurExp >= cmp.TotalRevenue)
            {
                return(true);
            }
            return(false);
        }
示例#3
0
        public Company(string name)
        {
            this.Id         = Guid.NewGuid();
            this.Name       = name;
            this.CreateTime = DateTime.Now;
            var comp = CompanyInfo.GetForId(1);

            if (comp != null)
            {
                this.CurExp          = 0;
                this.Level           = comp.Id;
                this.CurFinanceLv    = comp.FinanceLv;
                this.CurInvestmentLv = comp.InvestmentLv;
                this.CurMarketLv     = comp.MarketLv;
                this.CurPersonnelLv  = comp.PersonnelLv;
            }
            //TODO
        }
示例#4
0
        private async Task <int> CompanyLevelUp(Guid roleId, Company cmp, int goldCount, int goldType)
        {
            cmp.Level++;
            var cmpConfig = CompanyInfo.GetForId(cmp.Level);
            var role      = LogicServer.User.role;

            role.SocialStatus += cmpConfig.Income;
            FinanceLogData log = new FinanceLogData()
            {
                Count     = -goldCount,
                MoneyType = goldType,
                Type      = (int)GameEnum.FinanceLog.LvUpCompany,
                AorD      = false
            };

            using (var tx = LogicServer.Instance.StateManager.CreateTransaction())
            {
                await BagDataHelper.Instance.DecGold(goldCount, goldType, tx);                //减钱

                await CompanyDataHelper.Instance.UpdateCompanyByRoleIdAsync(roleId, cmp, tx); //升级

                await RoleDataHelper.Instance.UpdateRoleByRoleIdAsync(roleId, role, tx);      //更新身价

                await FinanceLogController.Instance.UpdateFinanceLog(roleId, log, tx);

                await tx.CommitAsync();
            }
            await MsgSender.Instance.UpdateIncome();       //发送身价变动消息

            await MsgSender.Instance.UpdateGold(goldType); //发送金钱变动消息

            await MsgSender.Instance.FinanceLogUpdate(log);


            return(cmp.Level);
        }