You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

78 regels
1.7 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using SUISS.Cloud.Boomlagoon.JSON;
  4. using SUISS.Storage;
  5. public class VisitingIsland : IStorable
  6. {
  7. public VisitingIsland()
  8. {
  9. this.Data = new JSONObject();
  10. this.Time = DateTime.MinValue;
  11. this.Island = Island.None;
  12. this.PlayerUuid = string.Empty;
  13. }
  14. public VisitingIsland(Island island, string uuid, JSONObject data)
  15. {
  16. this.Data = data;
  17. this.Island = island;
  18. this.PlayerUuid = uuid;
  19. this.Time = DateTime.UtcNow;
  20. }
  21. public JSONObject Data { get; private set; }
  22. public DateTime Time { get; private set; }
  23. public bool UnLocked
  24. {
  25. get
  26. {
  27. return this.Data.ToString() != "{}";
  28. }
  29. }
  30. public Island Island { get; private set; }
  31. public string PlayerUuid { get; private set; }
  32. public virtual void FromStorage(IDictionary<string, object> dict)
  33. {
  34. if (dict.ContainsKey("data"))
  35. {
  36. this.Data = JSONObject.Parse((string)dict["data"]);
  37. }
  38. if (dict.ContainsKey("island"))
  39. {
  40. this.Island = (Island)((int)dict["island"]);
  41. }
  42. if (dict.ContainsKey("island"))
  43. {
  44. this.PlayerUuid = (string)dict["playeruuid"];
  45. }
  46. if (dict.ContainsKey("time"))
  47. {
  48. this.Time = new DateTime((long)dict["time"]);
  49. }
  50. }
  51. public virtual IDictionary<string, object> ToStorage()
  52. {
  53. Dictionary<string, object> dictionary = new Dictionary<string, object>();
  54. dictionary["data"] = this.Data.ToString();
  55. dictionary["island"] = (int)this.Island;
  56. dictionary["playeruuid"] = this.PlayerUuid;
  57. dictionary["time"] = this.Time.Ticks;
  58. return dictionary;
  59. }
  60. private const string DataKey = "data";
  61. private const string IslandKey = "island";
  62. private const string PlayerUuidKey = "playeruuid";
  63. private const string TimeKey = "time";
  64. }