Пример #1
0
        public SectorInfoOut GetSectorInfo(IDbConnection connection, short sectorId)
        {
            var sector = _gSectorsService.GetById(connection, sectorId, i => i);

            if (sector == null)
            {
                return(null);
            }

            var sectorType = _gameTypeService.GetGGameType(connection, sector.TypeId);

            if (sectorType == null)
            {
                return(null);
            }

            var galaxyName = _galaxyService.GetGalaxyById(connection, sector.GalaxyId, i => i);

            if (galaxyName == null)
            {
                return(null);
            }


            var topAllianceName = _allianceService.GetTopAllianceInSector(connection, sectorId);
            var systemIds       = _systemService.GetSystemIds(connection, sectorId);

            var sectorInfo = new SectorInfoOut
            {
                GalaxyId          = sector.GalaxyId,
                GalaxyName        = galaxyName.NativeName,
                SectorId          = sector.Id,
                SectorName        = sector.NativeName,
                Id                = sector.Id,
                NativeName        = sector.NativeName,
                TextureTypeId     = sector.TextureTypeId,
                TypeNativeName    = sectorType.Type,
                TypeTranslateName =
                    L10N.ExecuteTranslateNameOrDescr(sectorType.Description, true, L10N.GetCurrentCulture()),
                SubtypeNativeName = sectorType.SubType,
                Description       = L10N.ExecuteTranslateNameOrDescr(sector.Translate, false, L10N.GetCurrentCulture()),
                AllianceName      = topAllianceName,
                ChildCount        = (short)systemIds.Count,
                SpriteImages      = new SpriteImages().SectorImages(sector.TextureTypeId),
                GameTypeId        = sectorType.Id
            };

            sectorInfo.SetComplexButtonView();
            return(sectorInfo);
        }
Пример #2
0
        public IList <Sector> GetInitSectors(IDbConnection connection)
        {
            var sectors = GetActiveSectors(connection, s => new Sector
            {
                Id            = s.Id,
                NativeName    = s.NativeName,
                Translate     = s.Translate,
                TranslateName = L10N.ExecuteTranslateNameOrDescr(s.Translate, true, null),
                Position      = s.Position,
                GalaxyId      = s.GalaxyId,
                GameTypeId    = s.TypeId,
                TextureTypeId = s.TextureTypeId,
                SectorId      = s.Id
            });

            return(sectors.OrderBy(s => s.GalaxyId).ToList());
        }
Пример #3
0
        public GalaxyInfoOut GetGalaxyInfo(IDbConnection connection, byte galaxyId)
        {
            var galaxy = _galaxyService.GetGalaxyById(connection, galaxyId, i => i);

            if (galaxy == null)
            {
                throw new ArgumentNullException(nameof(galaxy), Error.NoData);
            }

            var galaxyType   = _gameTypeService.GetGGameType(connection, galaxy.TypeId);
            var sectorsIds   = _gSectorsService.GetSectorsByGalaxy(connection, galaxyId, i => i.Id);
            var sectorsCount = sectorsIds.Count;

            var galaxyName = L10N.ExecuteTranslateNameOrDescr(galaxy.Translate, true, L10N.GetCurrentCulture());

            var galaxyInfo = new GalaxyInfoOut
            {
                Id                   = galaxy.Id,
                GalaxyId             = galaxy.Id,
                NativeName           = galaxy.NativeName,
                GalaxyName           = galaxyName,
                TranslateName        = galaxyName,
                TextureTypeId        = galaxy.TextureTypeId,
                TypeNativeName       = galaxyType.Type,
                TypeTranslateName    = galaxyName,
                SubtypeNativeName    = galaxyType.SubType,
                SubtypeTranslateName = "Spirale",
                SpriteImages         = new SpriteImages().GalaxyImages(galaxy.TextureTypeId),
                Description          = L10N.ExecuteTranslateNameOrDescr(galaxy.Translate, false),
                ChildCount           = (short)sectorsCount
            };


            //todo  сделать перевод
            galaxyInfo.SetComplexButtonView();
            return(galaxyInfo);
        }
Пример #4
0
        public MoonInfoOut GetMoonInfo(IDbConnection connection, int moonId)
        {
            var geometryMoon = _moonService.GetGeometryMoon(connection, moonId);

            if (geometryMoon == null)
            {
                return(null);
            }
            var moonType = _gameTypeService.GetGGameType(connection, geometryMoon.TypeId);

            if (moonType == null)
            {
                return(null);
            }

            var galaxyName = _galaxyService.GetGalaxyById(connection, geometryMoon.GalaxyId, i => i.NativeName);

            if (galaxyName == null)
            {
                return(null);
            }

            var sectorName = _gSectorsService.GetById(connection, geometryMoon.SectorId, i => i.NativeName);

            if (sectorName == null)
            {
                return(null);
            }

            var systemName = _systemService.GetDetailSystemBySystemId(connection, geometryMoon.SystemId, i => i.Name);

            if (systemName == null)
            {
                return(null);
            }

            var detailMoon = _moonService.GetDetailMoon(connection, moonId);

            if (detailMoon == null)
            {
                return(null);
            }


            var moonInfo = new MoonInfoOut
            {
                GalaxyId       = geometryMoon.GalaxyId,
                GalaxyName     = galaxyName,
                SectorId       = geometryMoon.SectorId,
                SectorName     = sectorName,
                SystemId       = geometryMoon.SystemId,
                SystemName     = systemName,
                Id             = geometryMoon.Id,
                NativeName     = detailMoon.Name,
                TextureTypeId  = geometryMoon.TextureTypeId,
                SpriteImages   = new SpriteImages().MoonImages(geometryMoon.TextureTypeId),
                TypeNativeName = moonType.SubType,
                Description    = L10N.ExecuteTranslateNameOrDescr(detailMoon.Description, false, L10N.GetCurrentCulture()),
            };

            moonInfo.SetComplexButtonView();
            return(moonInfo);
        }
Пример #5
0
        public PlanetInfoOut GetPlanetInfo(IDbConnection connection, int planetId, int currentUserId)
        {
            var planetGeometry = _geometryPlanetService.GetGeometryPlanetById(connection, planetId);

            if (planetGeometry == null)
            {
                return(null);
            }

            var planetType = _gameTypeService.GetGGameType(connection, planetGeometry.TypeId);

            if (planetType == null)
            {
                return(null);
            }


            var galaxyName = _galaxyService.GetGalaxyById(connection, planetGeometry.GalaxyId, i => i.NativeName);

            if (galaxyName == null)
            {
                return(null);
            }

            var sectorName = _gSectorsService.GetById(connection, planetGeometry.SectorId, i => i.NativeName);

            if (sectorName == null)
            {
                return(null);
            }

            var systemName = _systemService.GetDetailSystemBySystemId(connection, planetGeometry.SystemId, i => i.Name);

            if (systemName == null)
            {
                return(null);
            }


            var planetDetail = _gDetailPlanetService.GetPlanet(connection, planetId);

            if (planetDetail == null)
            {
                return(null);
            }


            var skagry             = NpcHelper.GetNpcByName(Npc.SkagyName);
            var userName           = skagry.NpcUser.Nickname;
            var planetAllianceName = skagry.NpcAlliance.Name;

            if (planetDetail.UserId != skagry.NpcUser.Id)
            {
                userName           = _gameUserService.GetGameUser(connection, planetDetail.UserId, i => i.Nickname);
                planetAllianceName = _allianceService.GetAllianceById(connection, planetDetail.AllianceId, i => i.Name);
            }
            var isCurrentUser = currentUserId == planetDetail.UserId;


            var planetInfo = new PlanetInfoOut
            {
                GalaxyId                 = planetGeometry.GalaxyId,
                GalaxyName               = galaxyName,
                SectorId                 = planetGeometry.SectorId,
                SectorName               = sectorName,
                SystemId                 = planetGeometry.SystemId,
                SystemName               = systemName,
                Id                       = planetGeometry.Id,
                NativeName               = planetDetail.Name,
                TextureTypeId            = planetGeometry.TextureTypeId,
                Owner                    = userName,
                LastActive               = planetDetail.LastActive,
                PlanetReferToCurrentUser = isCurrentUser,
                TypeNativeName           = planetType.Type,
                SubtypeNativeName        = planetType.SubType,
                Description              =
                    L10N.ExecuteTranslateNameOrDescr(planetDetail.Description, false, L10N.GetCurrentCulture()),
                AllianceName = planetAllianceName,
                ChildCount   = planetDetail.MoonCount,
                SpriteImages = new SpriteImages().PlanetImages(planetType.SubType, planetGeometry.TextureTypeId)
            };


            if (string.Equals(planetInfo.SubtypeNativeName, PlanetoidSubTypes.Earth.ToString(),
                              StringComparison.CurrentCultureIgnoreCase))
            {
                planetInfo.SubtypeTranslateName = "translate Earth";
            }
            else if (string.Equals(planetInfo.SubtypeNativeName, PlanetoidSubTypes.Gas.ToString(),
                                   StringComparison.CurrentCultureIgnoreCase))
            {
                planetInfo.SubtypeTranslateName = "translate Gas Gigant";
            }
            else if (string.Equals(planetInfo.SubtypeNativeName, PlanetoidSubTypes.IceGas.ToString(),
                                   StringComparison.CurrentCultureIgnoreCase))
            {
                planetInfo.SubtypeTranslateName = "translate Ice";
            }
            planetInfo.SetComplexButtonView();
            return(planetInfo);
        }
Пример #6
0
        public StarInfoOut GetStarInfo(IDbConnection connection, int starId)
        {
            var system = _systemService.GetSystem(connection, starId, i => i);

            if (system == null)
            {
                return(null);
            }

            var galaxyName = _galaxyService.GetGalaxyById(connection, system.GalaxyId, i => i.NativeName);

            if (galaxyName == null)
            {
                return(null);
            }

            var sectorName = _gSectorsService.GetById(connection, system.SectorId, i => i.NativeName);

            if (sectorName == null)
            {
                return(null);
            }

            var geometryStar = _systemService.GetGeometryStarById(connection, starId, i => i);

            if (geometryStar == null)
            {
                return(null);
            }

            var detailSystem = _systemService.GetDetailSystemBySystemId(connection, starId);

            if (detailSystem == null)
            {
                return(null);
            }

            var planetCountsInSystem = _gDetailPlanetService.GetPlanetCountInSystem(connection, starId);

            if (planetCountsInSystem == 0)
            {
                return(null);
            }


            var npcSkagry       = NpcHelper.GetNpcByName(Npc.SkagyName);
            var npcConfederaion = NpcHelper.GetNpcByName(Npc.ConfederationName);

            var owner        = npcSkagry.NpcUser.Nickname;
            var allianceName = npcSkagry.NpcAlliance.Name;


            if (detailSystem.AllianceId == npcConfederaion.NpcAlliance.Id)
            {
                owner        = npcConfederaion.NpcUser.Nickname;
                allianceName = npcConfederaion.NpcAlliance.Name;
            }
            if (detailSystem.UserName != null && detailSystem.UserName != npcSkagry.NpcUser.Nickname)
            {
                owner = detailSystem.UserName;
                if (detailSystem.AllianceId == npcConfederaion.NpcAlliance.Id)
                {
                    allianceName = npcConfederaion.NpcAlliance.Name;
                }
                else
                {
                    allianceName = _allianceService.GetAllianceById(connection, detailSystem.AllianceId, i => i.Name);
                }
            }

            var systemType = _gameTypeService.GetGGameType(connection, geometryStar.TypeId);
            var starInfo   = new StarInfoOut
            {
                GalaxyId             = system.GalaxyId,
                GalaxyName           = galaxyName,
                SectorId             = system.SectorId,
                SectorName           = sectorName,
                SystemId             = system.Id,
                SystemName           = detailSystem.Name,
                Id                   = system.Id,
                NativeName           = detailSystem.Name,
                TextureTypeId        = geometryStar.TextureTypeId,
                Owner                = owner,
                Bonus                = detailSystem.EnergyBonus,
                TypeNativeName       = systemType.Type,
                SubtypeNativeName    = systemType.SubType,
                SubtypeTranslateName = systemType.SubType,
                Description          =
                    L10N.ExecuteTranslateNameOrDescr(detailSystem.Description, false, L10N.GetCurrentCulture()),
                AllianceName = allianceName,
                ChildCount   = planetCountsInSystem,
                SpriteImages = new SpriteImages().StarImages(systemType.SubType, geometryStar.TextureTypeId)
            };

            starInfo.SetComplexButtonView();

            return(starInfo);
        }