/// <summary> /// Uploads the next turn for this game. /// Sets the "processing game code" to null. /// </summary> public void UploadTurn() { // get list of files var path = Path.Combine(Path.GetDirectoryName(Engine.HostExecutable.Trim('"')), Mod.SavePath); var files = GetFiles(path, GenerateArgumentsOrFilter(Engine.HostTurnUploadFilter, true)); // send to PBW var url = "http://pbw.spaceempires.net/games/{0}/host-turn/upload".F(Code); PBW.Log.Write($"Uploading next turn for {this}."); ArchiveUploadAndDeleteArchive(files, url, "turn_file", HttpStatusCode.Redirect); // for some reason PBW gives a 302 on host turn upload ProcessingGame = null; }
private static HostGame LoadHostGame(XElement gx) { var g = new HostGame(); g.Code = gx.Element("game_code").Value; g.Password = gx.Element("game_password").Value; g.Mod = Mod.Find(gx.Element("mod_code").Value, gx.Element("game_type").Value); g.TurnMode = Game.ParseTurnMode(gx.Element("turn_mode").Value); g.TurnNumber = int.Parse(gx.Element("turn").Value); if (gx.Element("next_turn_date") != null) { g.TurnDueDate = UnixTimeToDateTime(gx.Element("next_turn_date").Value); } return(g); }
/// <summary> /// Prepares to process the turn for this game. /// You will need to actually start the process yourself. /// This is so you can attach an event handler to the process exit event. /// Sets the "processing game" to this game, on the assumption that the process will be started immediately. /// Only one game can be processed at a time. /// </summary> public ProcessStartInfo ProcessTurnPrepare() { if (ProcessingGame != null) { throw new InvalidOperationException("Cannot begin processing " + this + " because " + ProcessingGame + " is already being processed."); } ProcessingGame = this; var cmd = GenerateArgumentsOrFilter(Engine.HostExecutable, false); var args = GenerateArgumentsOrFilter(Engine.HostArguments, false); PBW.Log.Write($"Executing command to process {this}: {cmd} {args}"); return(new ProcessStartInfo(cmd, args)); }