private GDetailSystemDataModel CreateSystemDetail(IDbConnection connection, int id, byte typeId, string name) { var translate = new L10N(); translate.InitializeField(); var type = _gameTypeService.GetGGameType(connection, typeId); var typeTranslate = type.Description; translate.En.Description = "Unique Description En " + name + " " + " TypeDescription: " + typeTranslate.En.Description; translate.Es.Description = "Unique Description Es " + name + " " + " TypeDescription: " + typeTranslate.Es.Description; translate.Ru.Description = "Unique Description Ru " + name + " " + " TypeDescription: " + typeTranslate.Ru.Description; translate.En.Name = translate.Es.Name = translate.Ru.Name = name; return(new GDetailSystemDataModel { Id = id, TypeId = typeId, AllianceId = 1, Name = name, UserName = Npc.SkagyName, Description = translate, EnergyBonus = 1 }); }
private bool CreateGalaxies(IDbConnection connection) { var galaxyNativeName = MapTypes.Galaxy.ToString(); var spiraleNativeName = GalaxySubTypes.Spirale.ToString(); var gTypes = _gameTypeService.GetGGameTypes(connection, galaxyNativeName, spiraleNativeName); var typeIds = gTypes.Select(i => i.Id).ToList(); var typeUsed = new List <byte>(); var translate = new L10N(); translate.InitializeField(); var galaxyIds = new List <byte> { 1 }; const string baseName = "galaxy"; var galaxies = new List <GGalaxyDataModel>(); foreach (var galaxyId in galaxyIds) { translate.En.Name = "Galaxy " + galaxyId; translate.Es.Name = "Galaxia " + galaxyId; translate.Ru.Name = "Галактика " + galaxyId; var typeId = GameTypeHalper.GetRandomTypeFromUsedTyps(typeIds, ref typeUsed); var type = gTypes.Single(i => i.Id == typeId); var typeTranslate = type.Description; translate.En.Description = "Unique Description En " + translate.En.Name + " TypeDescription: " + typeTranslate.En.Description; translate.Es.Description = "Unique Description Es " + translate.Es.Name + " TypeDescription: " + typeTranslate.Es.Description; translate.Ru.Description = "Unique Description Ru " + translate.Ru.Name + " TypeDescription: " + typeTranslate.Ru.Description; var textures = _gameTypeService.GetTextures(connection, typeId); galaxies.Add(new GGalaxyDataModel { Id = galaxyId, Translate = translate, NativeName = baseName + galaxyId, Opened = true, TypeId = type.Id, Position = CreateGalaxyPosition(galaxyId), TextureTypeId = _gameTypeService.GetRandTextureId(textures, Rand) }); } foreach (var i in galaxies) { _gGalaxyService.AddOrUpdate(connection, i); } return(true); }
protected override void _setUpdatedData(g_detail_system oldData, GDetailSystemDataModel newData) { L10N description; if (newData.Description == null) { description = new L10N(); description.InitializeField(); description.En.Name = newData.Name; description.Ru.Name = newData.Name; description.Es.Name = newData.Name; } else { description = newData.Description; } var rDescription = description.ToSerealizeString(); if (rDescription.Length > L10N.DefaultMaxLength) { throw new ValidationException(Error.OverMaxLength); } var allianceId = newData.AllianceId == 0 ? Npc.SkagryGameUserId : newData.AllianceId; if (oldData.Id != newData.Id) { oldData.Id = newData.Id; } if (oldData.typeId != newData.TypeId) { oldData.typeId = newData.TypeId; } if (oldData.name != newData.Name) { oldData.name = newData.Name; } if (oldData.userName != newData.UserName) { oldData.userName = newData.UserName; } if (oldData.allianceId != allianceId) { oldData.allianceId = allianceId; } if (oldData.description != rDescription) { oldData.description = rDescription; } if (Math.Abs(oldData.energyBonus - newData.EnergyBonus) > 0) { oldData.energyBonus = newData.EnergyBonus; } }
private GDetailMoonDataModel _createMoonDetail(IDbConnection connection, int newMoonId, string name) { var translate = new L10N(); translate.InitializeField(); var type = _gameTypeService.GetGGameType(connection, (byte)PlanetoidSubTypes.Moon); var typeTranslate = type.Description; translate.En.Description = "Unique Description En " + name + " " + " TypeDescription: " + typeTranslate.En.Description; translate.Es.Description = "Unique Description Es " + name + " " + " TypeDescription: " + typeTranslate.Es.Description; translate.Ru.Description = "Unique Description Ru " + name + " " + " TypeDescription: " + typeTranslate.Ru.Description; translate.En.Name = translate.Es.Name = translate.Ru.Name = name; return(new GDetailMoonDataModel { Id = newMoonId, Name = name, Description = translate }); }
private bool CreatePlanetDetails(IDbConnection connection) { var planets = _getPlanetCollection(connection); var npc = NpcHelper.GetNpcByName(Npc.SkagyName); var detailPlanets = new List <GDetailPlanetDataModel>(); foreach (var planet in planets) { var translate = new L10N(); translate.InitializeField(); var type = _gameTypeService.GetGGameType(connection, planet.GameTypeId); var typeTranslate = type.Description; translate.En.Description = "Unique Description En " + planet.NativeName + " " + " TypeDescription: " + typeTranslate.En.Description; translate.Es.Description = "Unique Description Es " + planet.NativeName + " " + " TypeDescription: " + typeTranslate.Es.Description; translate.Ru.Description = "Unique Description Ru " + planet.NativeName + " " + " TypeDescription: " + typeTranslate.Ru.Description; translate.En.Name = translate.Es.Name = translate.Ru.Name = planet.NativeName; var detailPlanet = new GDetailPlanetDataModel { Id = planet.Id, UserId = npc.NpcUser.Id, AllianceId = npc.NpcAlliance.Id, Name = planet.NativeName, Description = translate, DangerLevel = 1, LastActive = DateTime.UtcNow, MoonCount = GetMoonCount(planet.SystemPosition), UnitProgress = new Dictionary <UnitType, TurnedUnit>() }; _iOwnProgressInitializer.SetInitialPlanetBuilds(detailPlanet, npc.NpcUser.Id); _iOwnProgressInitializer.SetInitialHangarAndResource(connection, detailPlanet); detailPlanets.Add(detailPlanet); } #region for Delete //for (int p = 0; p < planets.Count; p++) //{ // var planet = planets[p]; // var system = detailSystems.First(i => i.Id == planet.SystemId); // var systemName = system.Name; // //var planetName = systemName + "-"+ planet.SystemPosition; // var translate = new L10N(); // translate.InitializeField(); // var type = await _gameTypeService.GetGGameTypeAsync(planet.GameTypeId); // var typeTranslate = type.Description; // translate.En.Description = "Unique Description En " + planet.NativeName + " " + " TypeDescription: " + // typeTranslate.En.Description; // translate.Es.Description = "Unique Description Es " + planet.NativeName + " " + " TypeDescription: " + // typeTranslate.Es.Description; // translate.Ru.Description = "Unique Description Ru " + planet.NativeName + " " + " TypeDescription: " + // typeTranslate.Ru.Description; // translate.En.Name = translate.Es.Name = translate.Ru.Name = planet.NativeName; // var detailPlanet = new GDetailPlanetDataModel // { // Id = planet.Id, // UserId = npc.NpcUser.Id, // AllianceId = npc.NpcAlliance.Id, // Name = planet.NativeName, // Description = translate, // DangerLevel = (byte)Rand.Next(0, 10), // LastActive = DateTime.UtcNow, // MoonCount = GetMoonCount(planet.SystemPosition) // }; // _iOwnProgressInitializer.SetInitialPlanetBuilds(detailPlanet, npc.NpcUser.Id); // _iOwnProgressInitializer.SetInitialHangarAndResource(detailPlanet); // detailPlanets.Add(detailPlanet); //} #endregion var suc = _gDetailPlanetService.AddOrUpdateDetailPlanetList(connection, detailPlanets).Any(); return(true); }
public bool CreateSectors(IDbConnection connection) { // short sectorCounts = 70; //todo delete after debug or put 70 short sectorCounts = 3; //var sectorTypeNativeName = MapTypes.Sector.ToString(); var types = _gameTypeService.GetGGameTypes(connection, MapTypes.Sector.ToString()); var galaxies = _gGalaxyService.GetGalaxyIds(connection); var sectors = new List <GSectorsDataModel>(); foreach (var galaxyId in galaxies) { for (short s = 0; s < sectorCounts; s++) { var type = types.Count == 1 ? types[0] : types[Rand.Next(0, types.Count)]; var typeId = type.Id; var typeTranslate = type.Description; var translate = new L10N(); translate.InitializeField(); var sectorNames = SectorNamesHelper.Names; var sectorNumber = s; sectorNumber += 1; string sectorName; if (s < sectorNames.Count) { sectorName = sectorNames[s]; translate.En.Name = "Sector " + sectorName; translate.Es.Name = "Sector " + sectorName; translate.Ru.Name = "Сектор " + sectorName; } else { sectorName = "Sector" + sectorNumber; translate.En.Name = "Sector " + sectorNumber; translate.Es.Name = "Sector " + sectorNumber; translate.Ru.Name = "Сектор " + sectorNumber; } translate.En.Description = "Unique Description En " + sectorName + " " + " TypeDescription: " + typeTranslate.En.Description; translate.Es.Description = "Unique Description Es " + sectorName + " " + " TypeDescription: " + typeTranslate.Es.Description; translate.Ru.Description = "Unique Description Ru " + sectorName + " " + " TypeDescription: " + typeTranslate.Ru.Description; var textures = _gameTypeService.GetTextures(connection, typeId); sectors.Add(new GSectorsDataModel { Id = sectorNumber, Opened = true, TextureTypeId = _gameTypeService.GetRandTextureId(textures, Rand), GalaxyId = galaxyId, Translate = translate, TypeId = typeId, NativeName = sectorName, Position = Vector3.Zero }); } } var suc = _gSectorsService.AddOrUpdateAllSectors(connection, sectors).Any(); return(suc); }