public void Delete(LocalScheme resource) { var gameInfo = _wormsLocator.Find(); var path = _fileSystem.Path.Combine(gameInfo.SchemesFolder, resource.Name + ".wsc"); _fileSystem.File.Delete(path); }
private string ValidateOutputFolder(string outputFolder) { if (string.IsNullOrWhiteSpace(ResourceFolder)) { var gameInfo = _wormsLocator.Find(); if (!gameInfo.IsInstalled) { throw new ConfigurationException( "Worms is not installed. Use the --resource-folder option to specify where the Scheme should be created"); } outputFolder = gameInfo.SchemesFolder; } if (_fileSystem.Directory.Exists(outputFolder)) { return(outputFolder); } Logger.Information($"Output folder ({outputFolder}) does not exit. It will be created."); _fileSystem.Directory.CreateDirectory(outputFolder); return(outputFolder); }
public Task RunWorms(params string[] wormsArgs) { return(Task.Factory.StartNew( () => { var gameInfo = _wormsLocator.Find(); var args = string.Join(" ", wormsArgs); using (var process = Process.Start(gameInfo.ExeLocation, args)) { if (process == null) { return; } process.WaitForExit(); if (process.ExitCode == 0) { return; } } _steamService.WaitForSteamPrompt(); var wormsProcess = Process.GetProcessesByName(gameInfo.ProcessName).FirstOrDefault(); wormsProcess?.WaitForExit(); })); }
public IReadOnlyCollection <string> GetReplayPaths(string pattern) { var gameInfo = _wormsLocator.Find(); if (!gameInfo.IsInstalled) { return(new List <string>(0)); } return(_fileSystem.Directory.GetFiles(gameInfo.ReplayFolder, $"{pattern}*.WAgame")); }
public Task <int> OnExecuteAsync() { var cliInfo = _cliInfoRetriever.Get(); Logger.Information($"Worms CLI: {cliInfo.Version.ToString(3)}"); var gameInfo = _wormsLocator.Find(); var gameVersion = gameInfo.IsInstalled ? gameInfo.Version.ToString(4) : "Not Installed"; Logger.Information($"Worms Armageddon: {gameVersion}"); return(Task.FromResult(0)); }
public IReadOnlyCollection <ReplayPaths> GetReplayPaths(string pattern) { var gameInfo = _wormsLocator.Find(); if (!gameInfo.IsInstalled) { return(new List <ReplayPaths>(0)); } var waGamePaths = _fileSystem.Directory.GetFiles(gameInfo.ReplayFolder, $"{pattern}*.WAgame"); return(waGamePaths.Select(x => new ReplayPaths(x, GetLogPath(x))).ToList()); }
public Task RunWorms(params string[] wormsArgs) { return(Task.Factory.StartNew( () => { var gameInfo = _wormsLocator.Find(); var args = string.Join(" ", wormsArgs); using var process = Process.Start("wine", gameInfo.ExeLocation + " " + args); if (process == null) { return; } process.WaitForExit(); })); }
public async Task <int> OnExecuteAsync() { Logger.Verbose("Loading configuration"); var config = _configManager.Load(); string hostIp; try { const string domain = "red-gate.com"; hostIp = GetIpAddress(domain); } catch (Exception e) { Logger.Error($"IP address could not be found. {e.Message}"); return(1); } var gameInfo = _wormsLocator.Find(); if (!gameInfo.IsInstalled) { Logger.Error("Worms Armageddon is not installed"); return(1); } Logger.Information("Downloading the latest options"); if (!DryRun) { await _leagueUpdater.Update(config, Logger).ConfigureAwait(false); } Logger.Information("Starting Worms Armageddon"); var runGame = !DryRun?_wormsRunner.RunWorms("wa://") : Task.CompletedTask; Logger.Information("Announcing game on Slack"); Logger.Verbose($"Host name: {hostIp}"); if (!DryRun) { await _slackAnnouncer.AnnounceGameStarting(hostIp, config.SlackWebHook, Logger).ConfigureAwait(false); } await runGame; return(0); }
public async Task Update(Config config, ILogger logger) { _packageManager.Connect("TheEadie", "WormsLeague", "schemes/v", config.GitHubPersonalAccessToken); var versions = (await _packageManager.GetAvailableVersions().ConfigureAwait(false)).ToList(); logger.Verbose($"Available versions: {string.Join(", ", versions)}"); var latestVersion = versions.OrderByDescending(x => x).FirstOrDefault(); logger.Verbose($"Latest version: {latestVersion}"); logger.Information($"Downloading Schemes: {latestVersion}"); var schemesFolder = _wormsLocator.Find().SchemesFolder; await _packageManager.DownloadVersion(latestVersion, schemesFolder).ConfigureAwait(false); }
private string GetFilePath(string name) { var gameInfo = _wormsLocator.Find(); if (!gameInfo.IsInstalled) { throw new ConfigurationException( "Worms is not installed."); } var filePath = _fileSystem.Path.Combine(gameInfo.SchemesFolder, name + ".wsc"); if (!_fileSystem.File.Exists(filePath)) { throw new ConfigurationException($"No Scheme file found with name: {name}"); } return(filePath); }
public IReadOnlyCollection <SchemeResource> Get(string pattern = "*") { var gameInfo = _wormsLocator.Find(); if (!gameInfo.IsInstalled) { return(new List <SchemeResource>(0)); } var schemes = new List <SchemeResource>(); foreach (var scheme in _fileSystem.Directory.GetFiles(gameInfo.SchemesFolder, $"{pattern}.wsc")) { var fileName = _fileSystem.Path.GetFileNameWithoutExtension(scheme); var details = _wscReader.Read(scheme); schemes.Add(new SchemeResource(fileName, "local", details)); } return(schemes); }
public Task RunWorms(params string[] wormsArgs) { return(Task.Factory.StartNew( () => { var gameInfo = _wormsLocator.Find(); var args = string.Join(" ", wormsArgs); var processStartInfo = new ProcessStartInfo { FileName = "wine", Arguments = gameInfo.ExeLocation + " " + args, RedirectStandardOutput = true, RedirectStandardError = true }; using var process = Process.Start(processStartInfo); if (process == null) { return; } process.WaitForExit(); })); }
public async Task <LocalGif> Create(LocalGifCreateParameters parameters) { var replayPath = parameters.Replay.Paths.WAgamePath; var turn = parameters.Replay.Details.Turns.ElementAt((int)parameters.Turn - 1); var replayName = _fileSystem.Path.GetFileNameWithoutExtension(replayPath); var worms = _wormsLocator.Find(); var framesFolder = _fileSystem.Path.Combine(worms.CaptureFolder, replayName); var outputFileName = _fileSystem.Path.Combine(worms.CaptureFolder, replayName + " - " + parameters.Turn + ".gif"); var animationDelay = 100 / parameters.FramesPerSecond / parameters.SpeedMultiplier; DeleteFrames(framesFolder); await _replayFrameExtractor.ExtractReplayFrames( replayPath, parameters.FramesPerSecond, turn.Start + parameters.StartOffset, turn.End - parameters.EndOffset); CreateGifFromFiles(framesFolder, outputFileName, animationDelay, 640, 480); DeleteFrames(framesFolder); return(new LocalGif(outputFileName)); }