Browse Source

Fix uneffective code in data saving process

Veloe 4 years ago
parent
commit
51dbc0d981
1 changed files with 3 additions and 17 deletions
  1. 3 17
      MafiaTelegramBot/Game/GameRooms/GameRoom.GameProcess.cs

+ 3 - 17
MafiaTelegramBot/Game/GameRooms/GameRoom.GameProcess.cs

@@ -491,25 +491,15 @@ namespace MafiaTelegramBot.Game.GameRooms
                     
                     void UpdateWins(Player player)
                     {
-                        var userProfile = UserDao.GetPlayerById(player.Id).Result;
                         foreach (var row in statsList.Where(s => s.UserId == player.Id))
                         {
                             row.Wins++;
                         }
 
-                        // var roles = openRolesList.Where(o => o.Id == player.Id).First();
-                        //
-                        // if (roles.Hooker == false)
-                        // {
-                        //     roles.Hooker = true;
-                        //     
-                        // }
-                            
-
-                        if (userProfile.Statistics.Contains(Roles.All))
+                        if (player.Statistics.Contains(Roles.All))
                         {
-                            userProfile.Statistics[player.CurrentRole.RoleKey].Wins++;
-                            userProfile.Statistics[Roles.All].Wins++;
+                            player.Statistics[player.CurrentRole.RoleKey].Wins++;
+                            player.Statistics[Roles.All].Wins++;
                         }
                     }
                     
@@ -530,8 +520,6 @@ namespace MafiaTelegramBot.Game.GameRooms
                             else if (player.CurrentRole.ColorRole == 2)
                                 player.WerewolfRoleAchievementEvent(2, true);
                             else player.ResetParasiteProgress();
-                            
-
                         }
                         else
                         {
@@ -541,7 +529,6 @@ namespace MafiaTelegramBot.Game.GameRooms
                                 player.HookerRoleAchievementEvent();
                                 player.ParasiteRoleAchievementEvent(mafiaTeam.ToList());
                                 player.WerewolfRoleAchievementEvent(2);
-                                
                             }
                             else if (player.CurrentRole.ColorRole == 1) 
                                 player.WerewolfRoleAchievementEvent(1, true);
@@ -589,7 +576,6 @@ namespace MafiaTelegramBot.Game.GameRooms
                     await PlayersCh.SendExcept(Owner.Id, strings.thanks_for_game, Keyboard.PlayerGameMenu);
                 }
                 if (Players.Count <= Constants.PLAYER_DISABLE_TIMER) StartTimer();
-                await MafiaDataBase.GetInstance().SaveChangesAsync();
             });
         }
     }