/// <summary> /// Set players ready if they have waited for 10 seconds in the lobby or in the siding /// </summary> public async Task EnforceWaiting() { using (var db = new PersistedRepository()) { var players = db.Players.Where(p => p.GridId == 1 | p.GridId == 2); foreach(var p in players) { double dur = (DateTime.Now - p.StartLobby).TotalSeconds; if(dur > 10) { p.IsReady = true; await db.SaveAsync(); } } } }
/// <summary> /// Adds message to log and broadcasts to admin /// </summary> /// <param name="g">The calling grid.</param> /// <param name="message">The message to save to the log file.</param> /// <param name="method">The method that called the grid message.</param> /// <param name="runtime">Runtime of the calling method.</param> /// <param name="verbosity">Verbosity level</param> private async Task GridMessageAsync(Grid g, string message, string method, long runtime, int verbosity) { using (var db = new PersistedRepository()) { // Add to message log var messageLog = new MessageLog(g, message, method, runtime); db.Add(messageLog); await db.SaveAsync(); } if(_engine.Verbosity >= verbosity) { // Send to admin string adminMessage = string.Format("Grid {0} : {1} : {2} : {3} [{4}]", g.GridId, g.GridState, g.Round, message, runtime); if (verbosity < 2) AdminMessage(adminMessage); } }