Exemplo n.º 1
0
        private void _atackReport(IDbConnection connection, TmpAtackModel am)
        {
            _calcDangerLevel(UnixTime.ToTimestamp(am.DefendorPlanet.LastActive), am.BattleTime, am.DefendorPlanet);
            am.Battle = new BattleFleetsCalculator(am.SourceUser.Fleet, am.DefendorUser.Fleet);
            am.Battle.SetUnitMods(am.SourceUser.UnitMods, am.DefendorUser.UnitMods);
            am.BattleLog = am.Battle.Battle(am.DefendorPlanet.Turels.Level ?? 0);


            var status = am.BattleLog.Last().BattleResult;
            var isWin  = status == BattleResult.AtackerWin;

            am.SourceUser.Report   = am.Battle.Source;
            am.DefendorUser.Report = am.Battle.Target;

            am.ReportDataModel = _uReportService.AddOrUpdate(connection, new UserReportDataModel
            {
                TaskId     = am.TaskItem.Id,
                BattleTime = am.BattleTime,
                //todo Сбрасывать ресурсы?
                Resources             = MaterialResource.ConvertStorageToMaterial(am.DefendorPlanet.Resources).ConvertToInt(),
                RoundsLog             = am.BattleLog,
                DefenderUserId        = am.DefendorUser.User.Id,
                DefenderUserName      = am.DefendorUser.User.Nickname,
                DefenderDeleteReport  = !am.AtackerIsSkagry,
                DefenderSummaryReport = am.DefendorUser.Report,

                AtackerResultStatus  = status,
                AtackerWin           = isWin,
                AtackerUserId        = am.SourceUser.User.Id,
                AtackerUserName      = am.SourceUser.User.Nickname,
                AtackerSummaryReport = am.SourceUser.Report,
                AtackerIsSkagry      = am.AtackerIsSkagry,
                AtackerDeleteReport  = am.AtackerIsSkagry
            });
        }
Exemplo n.º 2
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);
        }