Exemplo n.º 1
0
        public void Should_return_5_artifacts_when_repo_has_5_artifacts()
        {
            var response = _fixture.Build <ArtifactResponseModel>()
                           .With(x => x.Results, _fixture.CreateMany <ArtifactModel>(5))
                           .With(x => x.Links, _fixture.CreateMany <LinkModel>(2))
                           .Create();

            _artifactRepo.GetArtifacts(Arg.Any <ArtifactCriteriaModel>()).Returns(response);

            var results = _artifactService.GetArtifacts(null).Result;

            results.Results.FirstOrDefault().Should().BeOfType <ArtifactModel>();
            results.Links.FirstOrDefault().Should().BeOfType <LinkModel>();
            results.Results.Count().Should().Be(5);
            results.Links.Count().Should().Be(2);
        }
Exemplo n.º 2
0
        public IEnumerable <ArtifactScanResult> Scan(Player player, int scanRange, double scanAccuracy)
        {
            _artifactGenerator.GenerateArtifacts();

            var scanPosition         = player.CurrentPosition;
            var artifactsInScanRange = _artifactRepository.GetArtifacts();

            var scanResults = new List <ArtifactScanResult>();

            foreach (var artifact in artifactsInScanRange)
            {
                var dist = scanPosition.TotalDistance2D(artifact.Position);
                if (dist > scanRange)
                {
                    continue;
                }

                var scanResult = new ArtifactScanResult {
                    scannedArtifact = artifact
                };

                if (dist < 3.0)
                {
                    player.SendArtifactRadarBeam(artifact.Position);

                    scanResult.estimatedPosition = artifact.Position;
                    scanResult.radius            = 0.0;

                    _artifactRepository.DeleteArtifact(artifact);

                    CreateLoots(player, artifact);
                    SpawnNpcs(player, artifact);

                    var ep = _zone.Configuration.IsBeta ? 10 : 5;
                    if (_zone.Configuration.Type == ZoneType.Training)
                    {
                        ep = 0;
                    }
                    if (ep > 0)
                    {
                        player.Character.AddExtensionPointsBoostAndLog(EpForActivityType.Artifact, ep);
                    }

                    player.MissionHandler.EnqueueMissionEventInfo(new FindArtifactEventInfo(player, artifact.Info.type, artifact.Position));
                }
                else
                {
                    var radius = Math.Pow(dist, 1.5) / (scanAccuracy * 60);
                    var p      = artifact.Position.GetRandomPositionInRange2D(-radius, radius);
                    scanResult.radius            = p.TotalDistance2D(artifact.Position);
                    scanResult.estimatedPosition = p;
                }

                scanResults.Add(scanResult);
            }

            return(scanResults);
        }
Exemplo n.º 3
0
        public void GenerateArtifacts()
        {
            var artifactType = _target.GetArtifactType();
            var artifactInfo = _repository.GetArtifactInfo(artifactType);

            if (!_repository.GetArtifacts().Where(a => a.MissionGuid == _target.MyZoneMissionInProgress.missionGuid && artifactInfo == a.Info).IsNullOrEmpty())
            {
                return;
            }

            var position = _target.GetPosition();
            var range    = _target.GetRange();

            var resultPosition = _target.Zone.FindPassablePointInRadius(position, range);

            var artifact = new Artifact(artifactInfo, resultPosition, _target.Player.Character)
            {
                MissionGuid = _target.MyZoneMissionInProgress.missionGuid
            };

            _repository.InsertArtifact(artifact);
        }
Exemplo n.º 4
0
 public async Task <ArtifactResponseModel> GetArtifacts(ArtifactCriteriaModel criteriaModel)
 {
     return(await _artifactRepo.GetArtifacts(criteriaModel).ConfigureAwait(false));
 }