public void Handle(IEvent @event) { string currentSystem = _playerStatus.Location; IEnumerable <Celestial> remaining = _navigator.GetSystem(currentSystem)? .Celestials .Where(c => c.Scanned == false) .OrderBy(r => r.ShortName); bool surfaceScansRemain = false; if (remaining == null) { _communicator.Communicate(_skipPhraseBook.GetRandomPhrase()); return; } if (!remaining.Any()) { remaining = _navigator.GetSystem(currentSystem)? .Celestials .Where(c => c.SurfaceScanned == false) .OrderBy(r => r.ShortName); if (!remaining.Any()) { _communicator.Communicate(_completePhrases.GetRandomPhrase()); return; } else { surfaceScansRemain = true; } } string script = string.Empty; foreach (Celestial celestial in remaining) { if (celestial == remaining.Last() && remaining.Count() > 1) { script += $" {_andPhrase} "; } script += $"{_planetPhrase} {celestial.ShortName}. "; } string finalScript = string.Format(_remainingPhrases.GetRandomPhrase(), remaining.Count(), script, surfaceScansRemain ? "surface " : "", PhraseBook.PluralizedEnding(remaining.Count(), "s")); _communicator.Communicate(finalScript); }
public void Handle(IEvent @event) { List <StarSystem> systems = _navigator.GetAllExpeditionSystems(); double totalSystems = systems.Count; double scannedSystems = systems.Where(s => s.Scanned).Count(); double progressPercentage = Math.Round(scannedSystems / totalSystems * 100); TimeSpan expeditionLength = _playerStatus.ExpeditionLength; _communicator.Communicate(_progressPhrases.GetRandomPhraseWith(expeditionLength.Days, expeditionLength.Hours, expeditionLength.Minutes, progressPercentage)); _communicator.Communicate(_systemsScannedPhrases.GetRandomPhraseWith(scannedSystems, totalSystems)); }
public void Handle(IEvent @event) { Dictionary <string, object> payload = @event.Payload; if (payload.ContainsKey("JumpType") && payload["JumpType"].ToString() == "Supercruise") { return; } string systemName = payload["StarSystem"].ToString(); if (ShouldCommunicate) { _communicator.Communicate(string.Format(_jumpPhraseBook.GetRandomPhrase(), systemName)); } StarSystem system = _navigator.GetSystem(systemName); if (system == null) { if (_communicateSkippableSystems && ShouldCommunicate) { _communicator.Communicate(_skipPhraseBook.GetRandomPhrase()); } return; } if (system.Celestials.All(c => c.Scanned)) { if (_communicateSkippableSystems && ShouldCommunicate) { _communicator.Communicate(_alreadyScannedBook.GetRandomPhrase()); } return; } string script = BuildScanScript(system); if (ShouldCommunicate) { _communicator.Communicate(script); } script = BuildSystemValueScript(system); if (ShouldCommunicate) { _communicator.Communicate(script); } }
public void Handle(IEvent @event) { string currentSystem = _playerStatus.Location; StarSystem system = _navigator.GetSystem(currentSystem); if (system == null) { _communicator.Communicate(_skipPhrases.GetRandomPhrase()); return; } Celestial nextToScan = _navigator.GetNextCelestial(system); _communicator.Communicate(BuildScript(nextToScan)); }
public void Handle(IEvent @event) { string currentSystem = _playerStatus.Location; if (!_navigator.SystemInExpedition(currentSystem)) { _communicator.Communicate(_notExpeditionSystem.GetRandomPhrase()); return; } bool success = _navigator.UnscanSystem(currentSystem); string script = success ? _systemUnscanned.GetRandomPhrase() : _errorPhrase; _communicator.Communicate(script); }
public void Handle(IEvent @event) { if (_navigator.OnExpedition) { return; } if (!_detourPlanner.DetourSuggested) { _logger.Information("Checking to see if we have a long route plotted..."); object val; @event.Payload.TryGetValue("RemainingJumpsInRoute", out val); int jumpsRemaining; if (val != null && Int32.TryParse(val.ToString(), out jumpsRemaining) && jumpsRemaining > 5) { _detourPlanner.DetourSuggested = true; _communicator.Communicate("Commander, it looks as if you're going on a long route. If you'd like to scan high-value systems on the way, target your final destination and say 'take a detour'"); } } string location = @event.Payload["Name"].ToString(); _detourPlanner.Destination = location; _logger.Information($"Setting destination to {location}"); }
public void Handle(IEvent @event) { if (_executionCount == 0) { _executionCount++; _communicator.Communicate(_warning); } else if (_executionCount == 1) { _executionCount = 0; bool success = _navigator.CancelExpedition(); string script = success ? _complete : _error; _communicator.Communicate(script); } }
public void Handle(IEvent @event) { _communicator.Communicate(_phraseBook.GetRandomPhrase()); StarSystem nextSystem = _navigator.GetNextSystem(); _galaxyMap.FindSystem(nextSystem.Name); }
public void Handle(IEvent @event) { StarSystem nextSystem = _navigator.GetNextSystem(); string nextSystemName; if (nextSystem == null && !String.IsNullOrEmpty(_playerStatus.Destination)) { _communicator.Communicate(_finalDestination.GetRandomPhrase()); nextSystemName = _playerStatus.Destination; } else { _communicator.Communicate(_phraseBook.GetRandomPhrase()); nextSystemName = nextSystem.Name; } _galaxyMap.FindSystem(nextSystemName); }
public void Handle(IEvent @event) { _communicator.Communicate(_genericPhrases.GetRandomPhrase()); var payload = @event.Payload; double fuelCapacity = (double)payload["FuelCapacity"]; _playerStatus.SetFuelCapacity(fuelCapacity); }
protected void HandleDetour(int?detourAmount = null) { if (_navigator.OnExpedition) { _communicator.Communicate(_expeditionExists); return; } // Get the start and destination if (String.IsNullOrEmpty(_playerStatus.Location)) { _logger.Error("No location known, can't find detour"); _communicator.Communicate("Unable to find detour, no starting location known."); return; } if (String.IsNullOrEmpty(_detourPlanner.Destination)) { _logger.Error("No destination found, can't plot detour"); _communicator.Communicate("Unable to find detour, no destination known. Please target your final destination from the galaxy map."); return; } if (detourAmount.HasValue) { _detourPlanner.DetourAmount = detourAmount.Value; } _communicator.Communicate($"Finding high-value systems within {_detourPlanner.DetourAmount} light years on the way to {_detourPlanner.Destination}. "); // try...catch here? bool result = _detourPlanner.PlanDetour(); if (result == false) { _communicator.Communicate("Sorry, I had a problem getting detour data."); return; } if (_detourPlanner.SystemsInDetour == 0) { _communicator.Communicate("I couldn't find any systems close enough to your route."); return; } string script = string.Format("I found {0} high-value {1} within {2} light years from your route. ", _detourPlanner.SystemsInDetour, _grammar.PluralizePhrase("system", _detourPlanner.SystemsInDetour), _detourPlanner.DetourAmount); _communicator.Communicate(script); _communicator.Communicate("To confirm this detour, say 'plan expedition'"); }
public virtual void Handle(IEvent @event) { IEnumerable <StarSystem> expeditionData = _userDataService.GetExpeditionData(); if (_navigator.ExpeditionStarted) { _communicator.Communicate(_expeditionExists); return; } bool success = _navigator.PlanExpedition(expeditionData); if (!success) { _communicator.Communicate(_unableToPlot); return; } CommunicateExpedition(); }
public void Handle(IEvent @event) { Dictionary <string, object> eventPayload = @event.Payload; string currentSystem = _playerStatus.Location; bool expeditionSystem = _navigator.SystemInExpedition(currentSystem); _navigator.ScanCelestial(eventPayload["BodyName"].ToString()); string script = BuildScript(currentSystem, expeditionSystem); _communicator.Communicate(script); }
public virtual void Handle(IEvent @event) { if (_navigator.ExpeditionStarted) { if (_navigator.ExpeditionComplete) { _communicator.Communicate("I'll clear your earlier expedition."); _navigator.CancelExpedition(); } else { _communicator.Communicate(_expeditionExists); return; } } bool success; if (_detourPlanner.DetourPlanned) { success = _detourPlanner.ConfirmDetour(); } else { IEnumerable <StarSystem> expeditionData = _userDataService.GetExpeditionData(); success = _navigator.PlanExpedition(expeditionData); } if (!success) { _communicator.Communicate(_unableToPlot); return; } _playerStatus.SetExpeditionStart(DateTimeOffset.Now); CommunicateExpedition(); }
public void Handle(IEvent @event) { string currentSystem = _playerStatus.Location; StarSystem system = _navigator.GetSystem(currentSystem); if (system == null) { _communicator.Communicate(_skipPhrases.GetRandomPhrase()); return; } Celestial nextToScan = system.Celestials .Where(c => c.Scanned == false) .OrderBy(r => r.ShortName) .FirstOrDefault(); if (nextToScan == null) { _communicator.Communicate(_completePhrases.GetRandomPhrase()); return; } _communicator.Communicate(_nextScanPhrases.GetRandomPhraseWith(nextToScan.ShortName)); }
public void Handle(IEvent @event) { Dictionary <string, object> eventPayload = @event.Payload; string currentSystem = _playerStatus.Location; bool expeditionSystem = _navigator.SystemInExpedition(currentSystem); string celestialName = eventPayload["BodyName"].ToString(); bool celestialScanned = _navigator.ScanCelestial(celestialName); if (celestialScanned) { // Only speak if the scanned body was actually one we were looking for (to prevent spam from autodiscovery) string script = BuildScript(currentSystem, celestialName); _communicator.Communicate(script); } }
public void Handle(IEvent @event) { Dictionary <string, object> eventPayload = @event.Payload; string currentSystem = _playerStatus.Location; bool expeditionSystem = _navigator.SystemInExpedition(currentSystem); bool efficient = ConvertPayloadKeyToInt(eventPayload, "ProbesUsed") <= ConvertPayloadKeyToInt(eventPayload, "EfficiencyTarget"); bool wasInExpedition = _navigator.ScanCelestialSurface(eventPayload["BodyName"].ToString(), efficient); if (wasInExpedition) { // Only speak if the scanned body was actually one we were looking for (to prevent spam from autodiscovery) string script = BuildScript(currentSystem, expeditionSystem); _communicator.Communicate(script); } }
public void Handle(IEvent @event) { _communicator.Communicate(_phraseBook.GetRandomPhrase()); }
public void Handle(IEvent @event) { StarSystem nextSystem = _navigator.GetNextSystem(); _communicator.Communicate(string.Format(_phraseBook.GetRandomPhrase(), nextSystem.Name)); }