Example #1
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));
        }
Example #2
0
        public NpcModel(string npcName, int npcId)
        {
            NpcUser = new NpcUser();

            NpcUser.Init(npcName, npcId);

            NpcMother = new NpcMother();
            NpcMother.Init(NpcUser);

            NpcAlliance = new NpcAlliance();
            NpcAlliance.Init(NpcUser);

            NpcAllianceUser = new NpcAllianceUser();
            NpcAllianceUser.Init(NpcUser, NpcAlliance);

            var teches = new BattleTeches();

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

            NpcAllianceTeth = new NpcAllianceTeth
            {
                Id     = NpcAlliance.Id,
                Teches = npcTeches
            };
        }
Example #3
0
        public void Init(NpcUser npc, StorageResources sr = null, Dictionary <UnitType, int> hangar = null,
                         MaterialResource extraction      = null)
        {
            Id                        = npc.Id;
            Resources                 = sr ?? StorageResources.InitPlanetResources();
            Hangar                    = hangar ?? UnitList.InitUnitsInOwn(true);
            ExtractionProportin       = extraction ?? MaterialResource.InitBaseOwnProportion();
            StartSystemId             = 1;
            LastUpgradeProductionTime = 0;
            LaboratoryProgress        = new ItemProgress();
            var teches = new BattleTeches();

            teches.CreateStartTeches();
            TechProgress = teches.ConvertToDbTeches();
        }
Example #4
0
        private AllianceDataModel _addAlliance(IDbConnection connection, AllianceDataModel dataModel)
        {
            AllianceDataModel     newAllianceData        = null;
            AllianceUserDataModel newCreatorAllianceUser = null;
            AllianceTechDataModel newTeches = null;

            var tech = new BattleTeches();

            tech.CreateStartTeches();
            var newDbTeches = tech.ConvertToDbTeches().ToSerealizeString();

            var al = _aRepo.AddOrUpdate(connection, _aRepo.ConvertToEntity(dataModel));

            newAllianceData = _aRepo.ConvertToWorkModel(al);
            var au = _aUserRepo.AddOrUpdate(connection, new alliance_user
            {
                allianceId = al.Id,
                userId     = al.creatorId,
                roleId     = (byte)AllianceRoles.Creator,
                dateCreate = al.dateCreate
            });

            newCreatorAllianceUser = _aUserRepo.ConvertToWorkModel(au);

            var teches = _aTechRepo.AddOrUpdate(connection, new alliance_tech
            {
                Id           = al.Id,
                techProgress = newDbTeches
            });

            newTeches = _aTechRepo.ConvertToWorkModel(teches);
            if (newAllianceData == null || newCreatorAllianceUser == null || newTeches == null)
            {
                throw new NotImplementedException();
            }

            var lcAllianceData = _aCache.UpdateLocalItem(connection, newAllianceData);

            _aUserCache.UpdateLocalItem(connection, newCreatorAllianceUser);
            _aTechCahce.UpdateLocalItem(connection, newTeches);
            return(lcAllianceData);
        }