Commits

Boris Nagaev committed 7ab726b

Game.set_state(): send private messages if state >= min_ended

  • Participants
  • Parent commits 07bc08a

Comments (0)

Files changed (1)

File src/model/Game.cpp

 #include "chess/CachedMoves.hpp"
 #include "log.hpp"
 #include "Options.hpp"
+#include "Application.hpp" // FIXME
 
 DBO_INSTANTIATE_TEMPLATES(thechess::Game);
 
 
 void Game::set_state(State state) {
     state_ = state;
+    if (state_ >= MIN_ENDED) {
+        Wt::WString notification = "[auto] " + game_a(id());
+        UserPtr from = tApp ? tApp->user() : UserPtr();
+        if (from != white()) {
+            User::send_message(from, white(), notification);
+        }
+        if (from != black()) {
+            User::send_message(from, black(), notification);
+        }
+    }
 }
 
 void Game::set_of_color(const UserPtr& user, Piece::Color color) {