/// <summary> /// Copies the column values into the given DbParameterValues using the database column name /// with a prefixed @ as the key. The key must already exist in the DbParameterValues /// for the value to be copied over. If any of the keys in the DbParameterValues do not /// match one of the column names, or if there is no field for a key, then it will be /// ignored. Because of this, it is important to be careful when using this method /// since columns or keys can be skipped without any indication. /// </summary> /// <param name="source">The object to copy the values from.</param> /// <param name="paramValues">The DbParameterValues to copy the values into.</param> public static void TryCopyValues(this IQuestTable source, NetGore.Db.DbParameterValues paramValues) { for (int i = 0; i < paramValues.Count; i++) { switch (paramValues.GetParameterName(i)) { case "id": paramValues[i] = (System.UInt16)source.ID; break; case "repeatable": paramValues[i] = (System.Boolean)source.Repeatable; break; case "reward_cash": paramValues[i] = (System.Int32)source.RewardCash; break; case "reward_exp": paramValues[i] = (System.Int32)source.RewardExp; break; } } }
/// <summary> /// Copies the column values into the given DbParameterValues using the database column name /// with a prefixed @ as the key. The keys must already exist in the DbParameterValues; /// this method will not create them if they are missing. /// </summary> /// <param name="source">The object to copy the values from.</param> /// <param name="paramValues">The DbParameterValues to copy the values into.</param> public static void CopyValues(this IQuestTable source, NetGore.Db.DbParameterValues paramValues) { paramValues["id"] = (System.UInt16)source.ID; paramValues["repeatable"] = (System.Boolean)source.Repeatable; paramValues["reward_cash"] = (System.Int32)source.RewardCash; paramValues["reward_exp"] = (System.Int32)source.RewardExp; }
/// <summary> /// Checks if this <see cref="IQuestTable"/> contains the same values as another <see cref="IQuestTable"/>. /// </summary> /// <param name="source">The source <see cref="IQuestTable"/>.</param> /// <param name="otherItem">The <see cref="IQuestTable"/> to compare the values to.</param> /// <returns> /// True if this <see cref="IQuestTable"/> contains the same values as the <paramref name="otherItem"/>; otherwise false. /// </returns> public static System.Boolean HasSameValues(this IQuestTable source, IQuestTable otherItem) { return(Equals(source.ID, otherItem.ID) && Equals(source.Repeatable, otherItem.Repeatable) && Equals(source.RewardCash, otherItem.RewardCash) && Equals(source.RewardExp, otherItem.RewardExp)); }
/// <summary> /// Copies the values from the given <paramref name="source"/> into this QuestTable. /// </summary> /// <param name="source">The IQuestTable to copy the values from.</param> public void CopyValuesFrom(IQuestTable source) { ID = source.ID; Repeatable = source.Repeatable; RewardCash = source.RewardCash; RewardExp = source.RewardExp; }
/// <summary> /// Copies the column values into the given Dictionary using the database column name /// with a prefixed @ as the key. The keys must already exist in the Dictionary; /// this method will not create them if they are missing. /// </summary> /// <param name="source">The object to copy the values from.</param> /// <param name="dic">The Dictionary to copy the values into.</param> public static void CopyValues(IQuestTable source, IDictionary <String, Object> dic) { dic["id"] = source.ID; dic["repeatable"] = source.Repeatable; dic["reward_cash"] = source.RewardCash; dic["reward_exp"] = source.RewardExp; }
/// <summary> /// Copies the column values into the given DbParameterValues using the database column name /// with a prefixed @ as the key. The keys must already exist in the DbParameterValues; /// this method will not create them if they are missing. /// </summary> /// <param name="source">The object to copy the values from.</param> /// <param name="paramValues">The DbParameterValues to copy the values into.</param> public static void CopyValues(this IQuestTable source, DbParameterValues paramValues) { paramValues["id"] = (UInt16)source.ID; paramValues["repeatable"] = source.Repeatable; paramValues["reward_cash"] = source.RewardCash; paramValues["reward_exp"] = source.RewardExp; }
/// <summary> /// Copies the values from the given <paramref name="source"/> into this QuestTable. /// </summary> /// <param name="source">The IQuestTable to copy the values from.</param> public void CopyValuesFrom(IQuestTable source) { this.ID = (NetGore.Features.Quests.QuestID)source.ID; this.Repeatable = (System.Boolean)source.Repeatable; this.RewardCash = (System.Int32)source.RewardCash; this.RewardExp = (System.Int32)source.RewardExp; }
/// <summary> /// Copies the column values into the given Dictionary using the database column name /// with a prefixed @ as the key. The keys must already exist in the Dictionary; /// this method will not create them if they are missing. /// </summary> /// <param name="source">The object to copy the values from.</param> /// <param name="dic">The Dictionary to copy the values into.</param> public static void CopyValues(IQuestTable source, System.Collections.Generic.IDictionary <System.String, System.Object> dic) { dic["id"] = (NetGore.Features.Quests.QuestID)source.ID; dic["repeatable"] = (System.Boolean)source.Repeatable; dic["reward_cash"] = (System.Int32)source.RewardCash; dic["reward_exp"] = (System.Int32)source.RewardExp; }
/// <summary> /// Loads the rewards for finishing a quest. /// </summary> /// <param name="questID">The ID of the quest.</param> /// <param name="table">The <see cref="IQuestTable"/>.</param> /// <param name="dbController">The <see cref="IDbController"/> to use to load values.</param> /// <returns>The rewards for finishing a quest.</returns> static IQuestRewardCollection <User> LoadRewards(QuestID questID, IQuestTable table, IDbController dbController) { var l = new List <IQuestReward <User> > { new MoneyQuestReward(table.RewardCash), new ExpQuestReward(table.RewardExp) }; // Items var rewardItems = dbController.GetQuery <SelectQuestRewardItemQuery>().Execute(questID); if (!rewardItems.IsEmpty()) { l.Add(new ItemsQuestReward(rewardItems.Select(x => new QuestItemTemplateAmount(x.ItemTemplateID, x.Amount)))); } return(new QuestRewardCollection <User>(l)); }
/// <summary> /// Copies the column values into the given DbParameterValues using the database column name /// with a prefixed @ as the key. The key must already exist in the DbParameterValues /// for the value to be copied over. If any of the keys in the DbParameterValues do not /// match one of the column names, or if there is no field for a key, then it will be /// ignored. Because of this, it is important to be careful when using this method /// since columns or keys can be skipped without any indication. /// </summary> /// <param name="source">The object to copy the values from.</param> /// <param name="paramValues">The DbParameterValues to copy the values into.</param> public static void TryCopyValues(this IQuestTable source, DbParameterValues paramValues) { for (var i = 0; i < paramValues.Count; i++) { switch (paramValues.GetParameterName(i)) { case "id": paramValues[i] = (UInt16)source.ID; break; case "repeatable": paramValues[i] = source.Repeatable; break; case "reward_cash": paramValues[i] = source.RewardCash; break; case "reward_exp": paramValues[i] = source.RewardExp; break; } } }
/// <summary> /// Copies the column values into the given Dictionary using the database column name /// with a prefixed @ as the key. The keys must already exist in the Dictionary; /// this method will not create them if they are missing. /// </summary> /// <param name="source">The object to copy the values from.</param> /// <param name="dic">The Dictionary to copy the values into.</param> public static void CopyValues(IQuestTable source, System.Collections.Generic.IDictionary<System.String,System.Object> dic) { dic["id"] = (NetGore.Features.Quests.QuestID)source.ID; dic["repeatable"] = (System.Boolean)source.Repeatable; dic["reward_cash"] = (System.Int32)source.RewardCash; dic["reward_exp"] = (System.Int32)source.RewardExp; }
/// <summary> /// Checks if this <see cref="IQuestTable"/> contains the same values as another <see cref="IQuestTable"/>. /// </summary> /// <param name="source">The source <see cref="IQuestTable"/>.</param> /// <param name="otherItem">The <see cref="IQuestTable"/> to compare the values to.</param> /// <returns> /// True if this <see cref="IQuestTable"/> contains the same values as the <paramref name="otherItem"/>; otherwise false. /// </returns> public static Boolean HasSameValues(this IQuestTable source, IQuestTable otherItem) { return Equals(source.ID, otherItem.ID) && Equals(source.Repeatable, otherItem.Repeatable) && Equals(source.RewardCash, otherItem.RewardCash) && Equals(source.RewardExp, otherItem.RewardExp); }
/// <summary> /// Initializes a new instance of the <see cref="QuestTable"/> class. /// </summary> /// <param name="source">IQuestTable to copy the initial values from.</param> public QuestTable(IQuestTable source) { CopyValuesFrom(source); }
/// <summary> /// Copies the column values into the given Dictionary using the database column name /// with a prefixed @ as the key. The keys must already exist in the Dictionary; /// this method will not create them if they are missing. /// </summary> /// <param name="source">The object to copy the values from.</param> /// <param name="dic">The Dictionary to copy the values into.</param> public static void CopyValues(IQuestTable source, IDictionary<String, Object> dic) { dic["id"] = source.ID; dic["repeatable"] = source.Repeatable; dic["reward_cash"] = source.RewardCash; dic["reward_exp"] = source.RewardExp; }