ソースを参照

opened roles sorting

Tigran 4 年 前
コミット
4d1bac06c9

+ 25 - 3
MafiaTelegramBot/Models/Inlines/ShowMyRolesQuery.cs

@@ -1,3 +1,4 @@
+using System.Collections.Generic;
 using System.Linq;
 using System.Threading.Tasks;
 using MafiaTelegramBot.DataBase.EntityDao;
@@ -15,9 +16,30 @@ namespace MafiaTelegramBot.Models.Inlines
             await DeletePreviousMessage(ChatId, update.CallbackQuery.Message.MessageId);
             var user = await UserDao.GetPlayerById(UserId);
             var opened = user.OpenedRoles.ToList();
-            if (opened.Count > 3) return await Bot.SendWithMarkdown2(ChatId, opened.Where(role => role is not (Roles.Cop or Roles.Don or Roles.Doctor))
-                .Aggregate(strings.your_opened_roles_list, (current, role) => current + $"\n{roles.ResourceManager.GetString(role.ToString())}"));
-            return await Bot.SendWithMarkdown2(ChatId, strings.you_dont_have_any_extended_role);
+            var tier2 = Utilities.TierDictionary[2].Intersect(opened).ToList();
+            var tier3 = Utilities.TierDictionary[3].Intersect(opened).ToList();
+            var tier4 = Utilities.TierDictionary[4].Intersect(opened).ToList();
+            var tier5 = Utilities.TierDictionary[5].Intersect(opened).ToList();
+            var message = $"{strings.opened_roles}:";
+            if (Utilities.TierDictionary[0].Count > 0)
+                message += AddMessage(Utilities.TierDictionary[0], strings.classic);
+            if (tier2.Count > 0)
+                message += AddMessage(tier2, strings.rare);
+            if (tier3.Count > 0)
+                message += AddMessage(tier3, strings.mythic);
+            if (tier4.Count > 0)
+                message += AddMessage(tier4, strings.epic);
+            if (tier5.Count > 0)
+                message += AddMessage(tier5, strings.legendary);
+            return await Bot.SendWithMarkdown2(ChatId, message);
+        }
+
+        private string AddMessage(List<Roles> list, string rarity)
+        {
+            var result = $"\n\n{strings.rarity}: {rarity}";
+            foreach (var role in list)
+                result += $"\n{roles.ResourceManager.GetString(role.ToString())}";
+            return result;
         }
     }
 }

+ 42 - 0
MafiaTelegramBot/Resources/strings.Designer.cs

@@ -1460,5 +1460,47 @@ namespace MafiaTelegramBot {
                 return ResourceManager.GetString("my_packs", resourceCulture);
             }
         }
+        
+        internal static string opened_roles {
+            get {
+                return ResourceManager.GetString("opened_roles", resourceCulture);
+            }
+        }
+        
+        internal static string classic {
+            get {
+                return ResourceManager.GetString("classic", resourceCulture);
+            }
+        }
+        
+        internal static string rare {
+            get {
+                return ResourceManager.GetString("rare", resourceCulture);
+            }
+        }
+        
+        internal static string mythic {
+            get {
+                return ResourceManager.GetString("mythic", resourceCulture);
+            }
+        }
+        
+        internal static string epic {
+            get {
+                return ResourceManager.GetString("epic", resourceCulture);
+            }
+        }
+        
+        internal static string legendary {
+            get {
+                return ResourceManager.GetString("legendary", resourceCulture);
+            }
+        }
+        
+        internal static string rarity {
+            get {
+                return ResourceManager.GetString("rarity", resourceCulture);
+            }
+        }
     }
 }

+ 21 - 0
MafiaTelegramBot/Resources/strings.resx

@@ -726,4 +726,25 @@
     <data name="my_packs" xml:space="preserve">
         <value>Мои наборы</value>
     </data>
+    <data name="opened_roles" xml:space="preserve">
+        <value>Открытые роли</value>
+    </data>
+    <data name="classic" xml:space="preserve">
+        <value>Классические</value>
+    </data>
+    <data name="rare" xml:space="preserve">
+        <value>Редкие</value>
+    </data>
+    <data name="mythic" xml:space="preserve">
+        <value>Мифические</value>
+    </data>
+    <data name="epic" xml:space="preserve">
+        <value>Эпические</value>
+    </data>
+    <data name="legendary" xml:space="preserve">
+        <value>Легендарные</value>
+    </data>
+    <data name="rarity" xml:space="preserve">
+        <value>Редкость</value>
+    </data>
 </root>

+ 4 - 0
MafiaTelegramBot/Utilities.cs

@@ -14,6 +14,10 @@ namespace MafiaTelegramBot
 
         public static readonly Dictionary<int, List<Roles>> TierDictionary = new()
         {
+            {
+                0,
+                new List<Roles> { Roles.Villager, Roles.Doctor, Roles.Cop, Roles.Mafia, Roles.Don }
+            },
             {
                 2,
                 new List<Roles> { Roles.Hooker, Roles.Elder, Roles.Bodyguard, Roles.Werewolf }