@@ -139,6 +139,7 @@ void main_window::connect_with_room(const ChitChatMessage::Query &data) {
139139
140140 current_user.user_sprite ->setFlag (QGraphicsItem::ItemIsFocusable);
141141 current_user.user_sprite ->setFocus ();
142+ update_rating ();
142143}
143144
144145void main_window::user_changed_position (const std::string &name, int x, int y) {
@@ -151,6 +152,7 @@ void main_window::roommate_disconnect(const std::string &roommate_name) {
151152 users_in_the_room[roommate_name].user_sprite ->name_display );
152153 scene->removeItem (users_in_the_room[roommate_name].user_sprite );
153154 users_in_the_room.erase (roommate_name);
155+ update_rating ();
154156}
155157
156158void main_window::roommate_connect (
@@ -161,6 +163,7 @@ void main_window::roommate_connect(
161163 users_in_the_room.insert ({u.get_name (), u});
162164 scene->addItem (u.user_sprite );
163165 scene->addItem (u.user_sprite ->name_display );
166+ update_rating ();
164167}
165168
166169void main_window::show_current_sprite () {
@@ -189,11 +192,35 @@ void main_window::send_skin(const std::string &skin) {
189192}
190193
191194void main_window::send_score (int score, std::string game_name) {
192- auto q = current_user. serialize (
193- ChitChatMessage::Query_RequestType_GET_SCORE);
195+ auto q =
196+ current_user. serialize ( ChitChatMessage::Query_RequestType_GET_SCORE);
194197 q.set_game_name (game_name);
195198 q.set_score (score);
196199 run_send_request (q);
200+ update_rating ();
201+ }
202+
203+ void main_window::update_rating () {
204+ scene->choose_game .games_rating .arkanoid_rating .clear ();
205+ scene->choose_game .games_rating .hangman_rating .clear ();
206+
207+ for (auto &x : users_in_the_room) {
208+ auto q = x.second .serialize (ChitChatMessage::Query::RequestType::
209+ Query_RequestType_GET_SCORE);
210+ q.set_game_name (" hangman" );
211+ emit run_send_request (q);
212+ q.set_game_name (" arkanoid" );
213+ emit run_send_request (q);
214+ }
215+
216+ auto q = current_user.serialize (
217+ ChitChatMessage::Query::RequestType::Query_RequestType_GET_SCORE);
218+ q.set_game_name (" hangman" );
219+ emit run_send_request (q);
220+ q.set_game_name (" arkanoid" );
221+ emit run_send_request (q);
222+
223+ scene->choose_game .games_rating .update_rating ();
197224}
198225
199226void main_window::set_user_skin (const std::string &skin) {
@@ -224,8 +251,8 @@ void main_window::on_change_avatar_button_clicked() {
224251 text->setPen (avatar_pen);
225252
226253 std::vector<std::string> characters = {
227- " finn" , " gambol" , " miku" , " mushroom" , " rafael" ,
228- " sonic" , " stormtroopers" , " kermit" , " pikachu" };
254+ " finn" , " gambol" , " miku" , " mushroom" , " rafael" ,
255+ " sonic" , " stormtroopers" , " kermit" , " pikachu" };
229256 for (int i = 0 ; i < 9 ; i++) {
230257 auto *skin = new sprite_for_choice (characters[i]);
231258 connect (skin, SIGNAL (add_curren_sprite ()), this ,
@@ -271,5 +298,6 @@ void main_window::initialize_user(client_user &u) {
271298 u.user_sprite ->change_skin (u.get_skin ());
272299}
273300void main_window::terminate () {
274- emit run_send_request (current_user.serialize (ChitChatMessage::Query_RequestType_DEBUG_TERMINATE));
301+ emit run_send_request (current_user.serialize (
302+ ChitChatMessage::Query_RequestType_DEBUG_TERMINATE));
275303}
0 commit comments