using System; using System.Collections.Generic; using SUISS.Cloud.Boomlagoon.JSON; using SUISS.Storage; public class VisitingIsland : IStorable { public VisitingIsland() { this.Data = new JSONObject(); this.Time = DateTime.MinValue; this.Island = Island.None; this.PlayerUuid = string.Empty; } public VisitingIsland(Island island, string uuid, JSONObject data) { this.Data = data; this.Island = island; this.PlayerUuid = uuid; this.Time = DateTime.UtcNow; } public JSONObject Data { get; private set; } public DateTime Time { get; private set; } public bool UnLocked { get { return this.Data.ToString() != "{}"; } } public Island Island { get; private set; } public string PlayerUuid { get; private set; } public virtual void FromStorage(IDictionary dict) { if (dict.ContainsKey("data")) { this.Data = JSONObject.Parse((string)dict["data"]); } if (dict.ContainsKey("island")) { this.Island = (Island)((int)dict["island"]); } if (dict.ContainsKey("island")) { this.PlayerUuid = (string)dict["playeruuid"]; } if (dict.ContainsKey("time")) { this.Time = new DateTime((long)dict["time"]); } } public virtual IDictionary ToStorage() { Dictionary dictionary = new Dictionary(); dictionary["data"] = this.Data.ToString(); dictionary["island"] = (int)this.Island; dictionary["playeruuid"] = this.PlayerUuid; dictionary["time"] = this.Time.Ticks; return dictionary; } private const string DataKey = "data"; private const string IslandKey = "island"; private const string PlayerUuidKey = "playeruuid"; private const string TimeKey = "time"; }