Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 

132 řádky
3.2 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using SUISS.Storage;
  4. namespace SUISS.Cloud
  5. {
  6. public class LeaderboardEntry : IStorable, ILeaderboardEntry
  7. {
  8. public LeaderboardEntry(string sagid, string username, int primaryScore, int secondaryScore, int tertiaryScore, int quaternaryScore, int votes, bool islandReady)
  9. {
  10. this.Sagid = sagid;
  11. this.Username = username;
  12. this.PrimaryScore = primaryScore;
  13. this.SecondaryScore = secondaryScore;
  14. this.TertiaryScore = tertiaryScore;
  15. this.QuaternaryScore = quaternaryScore;
  16. this.Votes = votes;
  17. this.IslandReady = islandReady;
  18. }
  19. public LeaderboardEntry()
  20. {
  21. }
  22. public string Playername
  23. {
  24. get
  25. {
  26. return this.Username;
  27. }
  28. }
  29. public string InstallUuid
  30. {
  31. get
  32. {
  33. return this.Sagid;
  34. }
  35. }
  36. public int Votes { get; set; }
  37. public bool IslandReady { get; set; }
  38. public string Username { get; set; }
  39. public string Sagid { get; set; }
  40. public int PrimaryScore { get; set; }
  41. public int SecondaryScore { get; set; }
  42. public int TertiaryScore { get; set; }
  43. public int QuaternaryScore { get; set; }
  44. [Obsolete("Use Leaderboard.GetRank(LeaderboardEntry myEntry)")]
  45. public int Rank { get; private set; }
  46. public void SetRank(int rank)
  47. {
  48. this.Rank = rank;
  49. }
  50. void IStorable.FromStorage(IDictionary<string, object> dict)
  51. {
  52. if (dict.ContainsKey("Username"))
  53. {
  54. this.Username = (string)dict["Username"];
  55. }
  56. if (dict.ContainsKey("PrimaryScore"))
  57. {
  58. this.PrimaryScore = (int)dict["PrimaryScore"];
  59. }
  60. if (dict.ContainsKey("SecondaryScore"))
  61. {
  62. this.SecondaryScore = (int)dict["SecondaryScore"];
  63. }
  64. if (dict.ContainsKey("TertiaryScore"))
  65. {
  66. this.TertiaryScore = (int)dict["TertiaryScore"];
  67. }
  68. if (dict.ContainsKey("QuaternaryScore"))
  69. {
  70. this.QuaternaryScore = (int)dict["QuaternaryScore"];
  71. }
  72. if (dict.ContainsKey("SagId"))
  73. {
  74. this.Sagid = (string)dict["SagId"];
  75. }
  76. if (dict.ContainsKey("Votes"))
  77. {
  78. this.Votes = (int)dict["Votes"];
  79. }
  80. if (dict.ContainsKey("IslandReady"))
  81. {
  82. this.IslandReady = (bool)dict["IslandReady"];
  83. }
  84. }
  85. IDictionary<string, object> IStorable.ToStorage()
  86. {
  87. Dictionary<string, object> dictionary = new Dictionary<string, object>();
  88. dictionary["Username"] = this.Username;
  89. dictionary["PrimaryScore"] = this.PrimaryScore;
  90. dictionary["SecondaryScore"] = this.SecondaryScore;
  91. dictionary["TertiaryScore"] = this.TertiaryScore;
  92. dictionary["QuaternaryScore"] = this.QuaternaryScore;
  93. dictionary["SagId"] = this.Sagid;
  94. dictionary["Votes"] = this.Votes;
  95. dictionary["IslandReady"] = this.IslandReady;
  96. return dictionary;
  97. }
  98. private const string UsernameKey = "Username";
  99. private const string PrimaryScoreKey = "PrimaryScore";
  100. private const string SecondaryScoreKey = "SecondaryScore";
  101. private const string TertiaryScoreKey = "TertiaryScore";
  102. private const string QuaternaryScoreKey = "QuaternaryScore";
  103. private const string SagidKey = "SagId";
  104. private const string VotesKey = "Votes";
  105. private const string IslandReadyKey = "IslandReady";
  106. }
  107. }