/// <summary> /// Constructor. /// </summary> /// <param name="id">the reward's ID (unique id to distinguish between rewards).</param> /// <param name="name">the reward's name.</param> public Reward(string id, string name) : base(id, name, "") { Schedule = Schedule.AnyTimeOnce(); RewardsMap.AddOrUpdate(this.ID, this); }
/// <summary> /// Factory method to easily create a reward according to the given JSONObject. /// </summary> /// <returns>A JSONObject representation of <c>Reward</c>.</returns> /// <param name="rewardObj">The actual reward according to the given JSONObject.</param> public static Reward fromJSONObject(JSONObject rewardObj) { string className = rewardObj[JSONConsts.SOOM_CLASSNAME].str; Reward reward = (Reward)Activator.CreateInstance(Type.GetType("Soomla." + className), new object[] { rewardObj }); RewardsMap.AddOrUpdate(reward.ID, reward); return(reward); }
/// <summary> /// Constructor. /// </summary> /// <param name="jsonReward">A JSONObject representation of <c>Reward</c>.</param> public Reward(JSONObject jsonReward) : base(jsonReward) { JSONObject scheduleObj = jsonReward[JSONConsts.SOOM_SCHEDULE]; if (scheduleObj) { Schedule = new Schedule(scheduleObj); } else { Schedule = null; } RewardsMap.AddOrUpdate(this.ID, this); }