Пример #1
0
        private List <TabSpyOut> _getSpyItemsList(IDbConnection connection, int userId, int lastId = 0)
        {
            var reports = _uSpyService.GetSpyReports(connection, userId, s => new TabSpyOut
            {
                Id = s.Id,

                TargetPlanetId = s.TargetPlanetId,

                TargetUserName   = s.TargetUserName,
                TargetSystemName = s.TargetPlanetName.Substring(0, 5),
                TargetPlanetName = s.TargetPlanetName,
                TargetResource   = s.TargetResource,
                //SourceOwnType = false,
                TargetHangar = UnitList.ConvertToHangar(s.TargetPlanetHangar),

                //todo  временно назначен
                LeftImage  = ImageView.Img(_spriteImages.MapControlIcons("jumptoplanetoid").Icon),
                RightImage =
                    (s.TargetUserName == Npc.SkagyName)
                        ? ImageView.Img(_spriteImages.MapControlIcons("interface-skagry-icon").Icon, Npc.SkagyName,
                                        false, Npc.SkagyName)
                        : ImageView.Img(s.TargetUserImage.Icon, s.TargetUserName, true, s.TargetUserName),
                Date    = UnixTime.GetDateFromTimeStamp(s.DateActivate),
                TimeNow = UnixTime.GetTimeFromTimeStamp(s.DateActivate),
            }, lastId);

            return(reports);
        }
Пример #2
0
        public Func <UserReportDataModel, TabReportOut> SetReportItem(int userId, List <UserTaskDataModel> tasks)
        {
            return(i => {
                var doneTask = tasks.Single(t => t.Id == i.TaskId);
                if (doneTask == null)
                {
                    throw new NullReferenceException(Error.NoData);
                }
                var jumpToPlanetoid = ImageView.Img(_spriteImages.MapControlIcons("jumptoplanetoid").Icon,
                                                    doneTask.TargetPlanetName, false, doneTask.TargetPlanetName);
                var isLose = !(i.AtackerWin && userId == i.AtackerUserId || !i.AtackerWin && userId == i.DefenderUserId);
                var report = new TabReportOut {
                    Id = i.Id,
                    CurrentUserIsAtacker = i.AtackerUserId == userId,
                    SourceUserName = i.AtackerUserName,
                    SourceReportHangar = ReportFleetOut.ConvertBattleFleetsToReportFleetView(i.AtackerSummaryReport),
                    TargetUserName = i.DefenderUserName,
                    TargetReportHangar = ReportFleetOut.ConvertBattleFleetsToReportFleetView(i.DefenderSummaryReport),

                    AtackerIsSkagry = i.AtackerIsSkagry,


                    TargetPlanetId = doneTask.TargetPlanetId,
                    TargetPlanetName = doneTask.TargetPlanetName,
                    TargetSystemName = doneTask.TargetPlanetName.Substring(0, 5),
                    Date = UnixTime.GetDateFromTimeStamp(i.BattleTime),
                    TimeNow = UnixTime.GetTimeFromTimeStamp(i.BattleTime),
                    TargetResource = i.Resources.ConvertToInt(),
                    //todo  временно назначен

                    LeftImage = doneTask.SourceOwnType
                        ? jumpToPlanetoid
                        : ImageView.Img(_spriteImages.MapControlIcons("jumptomother").Icon, null, false, null),
                    RightImage = jumpToPlanetoid,
                    // RightImage = ImageView.Img("r-RightImage"),
                    //todo  сделать аву для скагрей
                    IsLose = isLose
                };
                return report;
            });
        }
        public IHttpActionResult TestPush()
        {
            var curTime               = UnixTime.UtcNow();
            var currDatetime          = UnixTime.GetDateFromTimeStamp(curTime);
            var startRegistrationTime = _confederationService.StartRegistrationTime;
            var startVoteTime         = _confederationService.StartVoteTime;
            var endVoteTime           = _confederationService.EndVoteTime;

            var candidates      = _confederationService.GetCandidates(false);
            var candidatesCount = candidates.Count;

            var isVotePeriod = _confederationService.VotingInProgress;
            var periodName   = isVotePeriod ? "IsVotePeriod" : "isRegisterdPeriod";
            //todo  logic toggle
            var timeToNextUpgrage = isVotePeriod ? endVoteTime - curTime : startVoteTime - curTime;
            var activeOfficers    = new List <IOfficerOut>();

            try
            {
                activeOfficers = _confederationService.GetOfficers(true);
            }
            catch
            {
                // ignored
            }
            var activeOfficersCount = activeOfficers?.Count ?? 0;

            return(Json(new
            {
                periodName,
                timeToNextUpgrage,
                curTime = UnixTime.ConvertSecondToFormat(curTime, UnixTime.Format_dd_hh_mm),
                startRegistrationTime = UnixTime.ConvertSecondToFormat(startRegistrationTime, UnixTime.Format_dd_hh_mm),
                startVoteTime = UnixTime.ConvertSecondToFormat(startVoteTime, UnixTime.Format_dd_hh_mm),
                endVoteTime = UnixTime.ConvertSecondToFormat(endVoteTime, UnixTime.Format_dd_hh_mm),
                candidatesCount,
                activeOfficersCount
            }));
        }
Пример #4
0
        // todo  не работает
        public TabReportOut CreateReportItem(IDbConnection connection, string id)
        {
            throw new NotImplementedException("ReportItem(string id) метод не работает проверить место вызова");
            var random       = new Random();
            var randPlanetId = random.Next(300, 500);
            var tmpSorce     = false;

            var tPlanet    = _gDetailPlanetService.GetPlanet(connection, randPlanetId, i => i);
            var systemName = _geometryPlanetService.GetPlanetSystemName(connection, randPlanetId);

            var tUser = _gameUserService.GetGameUser(connection, tPlanet.UserId);

            var j = new TabReportOut {
                Id               = 300,
                TargetUserName   = tUser.Nickname,
                TargetSystemName = systemName,
                TargetPlanetName = tPlanet.Name,
                TargetResource   = tPlanet.Resources.Current.ConvertToInt(),
                SourceOwnType    = false,
                SourceUserName   = "", //get user

                //TargetHangar = HangarUnitsOut.EmptyHangar(),
                //todo  временно назначен
                LeftImage =
                    (!tmpSorce)
                        ? ImageView.Img(_spriteImages.MapControlIcons("jumptomother").Icon)
                        : ImageView.Img(_spriteImages.MapControlIcons("jumptoplanetoid").Icon),
                RightImage = ImageView.Img(_spriteImages.MapControlIcons("jumptoplanetoid").Icon),
                // RightImage = ImageView.Img("r-RightImage"),

                Date    = UnixTime.GetDateFromTimeStamp(DateTime.UtcNow),
                TimeNow = UnixTime.GetTimeFromTimeStamp(DateTime.UtcNow)
            };

            if (tmpSorce)
            {
            }
            return(j);
        }
Пример #5
0
        private TabSpyOut _writeAndReturnSpyItem(IDbConnection connection, int currentUserId, GDetailPlanetDataModel tPlanet)
        {
            var resource   = MaterialResource.ConvertStorageToMaterial(tPlanet.Resources).ConvertToInt();
            var planetType = _geometryPlanetService.GetGeometryPlanetById(connection, tPlanet.Id);

            var spyItem = new UserSpyDataModel {
                DateActivate       = UnixTime.UtcNow(),
                TargetPlanetTypeId = planetType.TypeId,
                TargetPlanetName   = tPlanet.Name,
                TargetPlanetId     = tPlanet.Id,
                TargetPlanetHangar = tPlanet.Hangar,
                TargetResource     = resource,
                SourceUserId       = currentUserId,
            };

            var isSkagry = false;

            if (tPlanet.UserId == Npc.SkagryGameUserId)
            {
                spyItem.TargetUserName = Npc.SkagyName;
                //todo  сделать стиль скагрей
                spyItem.TargetUserImage = _spriteImages.MapControlIcons("interface-skagry-icon");

                isSkagry = true;
            }
            else
            {
                var targetUser = _gameUserService.GetGameUser(connection, tPlanet.UserId);
                spyItem.TargetUserName  = targetUser.Nickname;
                spyItem.TargetUserImage = targetUser.Avatar;
            }

            var newSpyItem = _uSpyService.AddOrUpdate(connection, spyItem);

            if (newSpyItem.Id == 0)
            {
                throw new Exception(Error.NoData);
            }


            var leftSprite = new SpriteImages();

            leftSprite.MapControlIcons("jumptoplanetoid");
            var j = new TabSpyOut {
                // SourceOwnType = false,

                Id               = newSpyItem.Id,
                TargetUserName   = newSpyItem.TargetUserName,
                TargetResource   = newSpyItem.TargetResource,
                TargetHangar     = UnitList.ConvertToHangar(tPlanet.Hangar),
                TargetPlanetId   = newSpyItem.TargetPlanetId,
                TargetPlanetName = newSpyItem.TargetPlanetName,
                TargetSystemName = newSpyItem.TargetPlanetName.Substring(0, 5),
                LeftImage        = ImageView.Img(leftSprite.Icon),
                RightImage       =
                    (isSkagry)
                        ? ImageView.Img(spyItem.TargetUserImage.Icon)
                        : ImageView.Img(spyItem.TargetUserImage.Icon, null, true),
                Date    = UnixTime.GetDateFromTimeStamp(newSpyItem.DateActivate),
                TimeNow = UnixTime.GetTimeFromTimeStamp(newSpyItem.DateActivate)
            };

            j.RightImage.Title = j.RightImage.Alt = j.TargetUserName;

            TabSpyOut.InitComplexBtnItem(j);
            return(j);
        }