private int CompareExpirationDates(SquadWarRewardData a, SquadWarRewardData b) { if (b.ExpireDate > a.ExpireDate) { return(1); } if (b.ExpireDate < a.ExpireDate) { return(-1); } return(0); }
public ISerializable FromObject(object obj) { Dictionary <string, object> dictionary = obj as Dictionary <string, object>; if (dictionary.ContainsKey("id")) { this.SquadMemberId = Convert.ToString(dictionary["id"], CultureInfo.InvariantCulture); } if (dictionary.ContainsKey("name")) { this.SquadMemberName = Convert.ToString(dictionary["name"], CultureInfo.InvariantCulture); } if (dictionary.ContainsKey("victoryPoints")) { this.VictoryPointsLeft = Convert.ToInt32(dictionary["victoryPoints"], CultureInfo.InvariantCulture); } if (dictionary.ContainsKey("warMap") && dictionary["warMap"] != null) { this.BaseMap = new Map(); this.BaseMap.FromObject(dictionary["warMap"]); this.BaseMap.InitializePlanet(); } if (dictionary.ContainsKey("donatedTroops")) { this.WarTroops = SquadUtils.GetSquadDonatedTroopsFromObject(dictionary["donatedTroops"]); } if (dictionary.ContainsKey("rewards")) { Dictionary <string, object> dictionary2 = dictionary["rewards"] as Dictionary <string, object>; if (dictionary2 != null) { this.WarRewards.Clear(); foreach (object current in dictionary2.Values) { SquadWarRewardData squadWarRewardData = new SquadWarRewardData(); squadWarRewardData.FromObject(current); if (squadWarRewardData.ExpireDate > Service.Get <ServerAPI>().ServerTime) { this.WarRewards.Add(squadWarRewardData); } } this.WarRewards.Sort(new Comparison <SquadWarRewardData>(this.CompareExpirationDates)); } } return(this); }