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)); }
private static GDetailPlanetDataModel _convertFromEntity(IGDetailPlanetDbItem data) { var result = new GDetailPlanetDataModel(); if (data == null) { return(result); } result.Id = data.Id; result.Name = data.name; result.Description = data.description.ToSpecificModel <L10N>(); result.MoonCount = data.moonCount; result.UserId = data.userId; result.AllianceId = data.allianceId; result.LastActive = data.lastActive; result.DangerLevel = data.dangerLevel; result.Resources = data.resources.ToSpecificModel <StorageResources>(); result.Hangar = data.hangar.ToSpecificModel <Dictionary <UnitType, int> >(); result.BuildSpaceShipyard = data.buildSpaceShipyard.ToSpecificModel <ItemProgress>(); result.BuildExtractionModule = data.buildExtractionModule.ToSpecificModel <ItemProgress>(); result.BuildEnergyConverter = data.buildEnergyConverter.ToSpecificModel <ItemProgress>(); result.BuildStorage = data.buildStorage.ToSpecificModel <ItemProgress>(); result.Turels = data.turels.ToSpecificModel <ItemProgress>(); result.UnitProgress = data.unitProgress == null ? new Dictionary <UnitType, TurnedUnit>() : data.unitProgress.ToSpecificModel <Dictionary <UnitType, TurnedUnit> >(); result.ExtractionProportin = data.extractionProportin == null ? MaterialResource.InitBaseOwnProportion() : data.extractionProportin.ToSpecificModel <MaterialResource>(); result.LastUpgradeProductionTime = data.lastUpgradeProductionTime; return(result); }
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(); }
public GDetailPlanetDataModel SetInitialPlanetBuilds(GDetailPlanetDataModel planet, int userId = 1) { var intiData = ItemProgress.InitBuildingProgress(); var turel = ItemProgress.InitBuildingProgress(); turel.Level = 0; planet.BuildEnergyConverter = intiData; planet.BuildExtractionModule = intiData; planet.BuildStorage = intiData; planet.BuildSpaceShipyard = intiData; planet.Turels = turel; planet.ExtractionProportin = MaterialResource.InitBaseOwnProportion(); planet.UserId = userId; return(planet); }
protected override void _setUpdatedData(g_detail_planet oldData, GDetailPlanetDataModel newData) { if (newData.Description == null) { throw new ArgumentNullException(Error.IsEmpty, nameof(newData.Description)); } if (newData.Resources == null) { throw new ArgumentNullException(Error.IsEmpty, nameof(newData.Resources)); } if (newData.Hangar == null) { throw new ArgumentNullException(Error.IsEmpty, nameof(newData.Hangar)); } if (newData.BuildSpaceShipyard == null) { throw new ArgumentNullException(Error.IsEmpty, nameof(newData.BuildSpaceShipyard)); } if (newData.BuildExtractionModule == null) { throw new ArgumentNullException(Error.IsEmpty, nameof(newData.BuildExtractionModule)); } if (newData.BuildEnergyConverter == null) { throw new ArgumentNullException(Error.IsEmpty, nameof(newData.BuildEnergyConverter)); } if (newData.BuildStorage == null) { throw new ArgumentNullException(Error.IsEmpty, nameof(newData.BuildStorage)); } if (newData.Turels == null) { throw new ArgumentNullException(Error.IsEmpty, nameof(newData.Turels)); } if (newData.ExtractionProportin == null) { throw new ArgumentNullException(Error.IsEmpty, nameof(newData.ExtractionProportin)); } var description = newData.Description.ToSerealizeString(); if (description.Length > L10N.DefaultMaxLength) { throw new ValidationException(Error.OverMaxLength); } var resources = newData.Resources.ToSerealizeString(); var hangar = newData.Hangar.ToSerealizeString(); var buildSpaceShipyard = newData.BuildSpaceShipyard.ToSerealizeString(); var buildExtractionModule = newData.BuildExtractionModule.ToSerealizeString(); var buildEnergyConverter = newData.BuildEnergyConverter.ToSerealizeString(); var buildStorage = newData.BuildStorage.ToSerealizeString(); var turels = newData.Turels.ToSerealizeString(); var unitProgress = newData.UnitProgress?.ToSerealizeString(); if (newData.ExtractionProportin == null) { newData.ExtractionProportin = MaterialResource.InitBaseOwnProportion(); } var extractionProportin = newData.ExtractionProportin.ToSerealizeString(); if (oldData.Id != newData.Id) { oldData.Id = newData.Id; } if (oldData.name != newData.Name) { oldData.name = newData.Name; } if (oldData.description != description) { oldData.description = description; } if (oldData.moonCount != newData.MoonCount) { oldData.moonCount = newData.MoonCount; } if (oldData.userId != newData.UserId) { oldData.userId = newData.UserId; } if (oldData.allianceId != newData.AllianceId) { oldData.allianceId = newData.AllianceId; } if (oldData.lastActive != newData.LastActive) { oldData.lastActive = newData.LastActive; } if (oldData.dangerLevel != newData.DangerLevel) { oldData.dangerLevel = newData.DangerLevel; } if (oldData.resources != resources) { oldData.resources = resources; } if (oldData.hangar != hangar) { oldData.hangar = hangar; } if (oldData.buildSpaceShipyard != buildSpaceShipyard) { oldData.buildSpaceShipyard = buildSpaceShipyard; } if (oldData.buildExtractionModule != buildExtractionModule) { oldData.buildExtractionModule = buildExtractionModule; } if (oldData.buildEnergyConverter != buildEnergyConverter) { oldData.buildEnergyConverter = buildEnergyConverter; } if (oldData.buildStorage != buildStorage) { oldData.buildStorage = buildStorage; } if (oldData.turels != turels) { oldData.turels = turels; } if (oldData.unitProgress != unitProgress) { oldData.unitProgress = unitProgress; } if (oldData.extractionProportin != extractionProportin) { oldData.extractionProportin = extractionProportin; } if (oldData.lastUpgradeProductionTime != newData.LastUpgradeProductionTime) { oldData.lastUpgradeProductionTime = newData.LastUpgradeProductionTime; } }