public void SetResult (NecromancerActivationResult result) { _result = result; RaisePropertyChanged (() => NecromancerRollDisplay); RaisePropertyChanged (() => DarknessDisplay); RaisePropertyChanged (() => DetectedHeroDisplay); RaisePropertyChanged (() => NewLocationDisplay); var models = _result.NewBlights .GroupBy (x => x.Item1) .Select (x => new SpawnLocationViewModel (x.Key, x.Select (y => y.Item2))).ToList (); if (_result.SpawnQuest) { var questLocation = _pendingGameState.Locations.Single (l => l.Id == _result.OldLocationId); var model = models.FirstOrDefault (x => x.Location.Id == _result.OldLocationId); if (model == null) { model = new SpawnLocationViewModel (questLocation, null); models.Add(model); } model.Spawns.Add (new QuestViewModel ()); } Locations.Clear (); models.ForEach (x => Locations.Add (x)); }
/// <summary> /// Activate the necromancer. First he detects and then moves. /// </summary> /// <param name="gameState">Game state.</param> /// <param name="detectedHero">Force this hero to be detected.</param> /// <param name="roll">Force the necromancer roll.</param> /// <param name="heroesToIgnore">Heroes that are ignored due to Elusive Spirit or Blinding Black</param> public NecromancerActivationResult Activate (GameState gameState, Hero detectedHero = null, int? roll = null, int[] heroesToIgnore = null) { var result = new NecromancerActivationResult (); result.NecromancerRoll = roll.HasValue ? roll.Value : _d6GeneratorService.RollDemBones (); result.OldLocationId = gameState.Necromancer.LocationId; result.DarknessIncrease = 1 + gameState.Locations.SelectMany (x => x.Blights).Count (x => x.Name == "Desecration"); if (gameState.Heroes.ShieldOfRadianceActive && result.NecromancerRoll == 6) { result.DarknessIncrease--; result.Notes += "Shield of Radiance triggered" + Environment.NewLine; } gameState.Darkness += result.DarknessIncrease; //detect if (detectedHero == null) result.DetectedHero = Detect (gameState, result.NecromancerRoll, heroesToIgnore); else result.DetectedHero = detectedHero; //move var newLocation = Move (gameState, detectedHero, result.NecromancerRoll); result.NewLocationId = newLocation.Id; //spawn var spawnResult = Spawn(gameState, newLocation, result.NecromancerRoll); result.NewBlights = spawnResult.NewBlights; result.SpawnQuest = spawnResult.SpawnQuest; return result; }