/// <summary>
 /// Creates a new QuestRequirement and does some basich compativilite checks for the parameters
 /// </summary>
 /// <param name="defaultNPC"></param>
 /// <param name="n"></param>
 /// <param name="v"></param>
 /// <param name="comp"></param>
 public RegionRequirement(GameNPC defaultNPC, Object n, Object v, eComparator comp)
     : base(defaultNPC, eRequirementType.Region, n, v, comp)
 {
 }
Esempio n. 2
0
 /// <summary>
 /// Creates a new QuestRequirement and does some basich compativilite checks for the parameters
 /// </summary>
 /// <param name="defaultNPC"></param>
 /// <param name="n"></param>
 /// <param name="v"></param>
 /// <param name="comp"></param>
 public QuestGivableRequirement(GameNPC defaultNPC, Object n, Object v, eComparator comp)
     : base(defaultNPC, eRequirementType.QuestGivable, n, v, comp)
 {
 }
Esempio n. 3
0
        public static string RequirementText(eRequirementType Type, string N, string V, eComparator comp)
        {
            string text = null;

            object[] formatParams   = null;
            DataRow  requirementRow = DB.GetRequirementTypeRowForID((int)Type);

            if (requirementRow != null)
            {
                text = Convert.ToString(requirementRow[DB.COL_REQUIREMENTTYPE_TEXT]);
                string typeN          = Convert.ToString(requirementRow[DB.COL_REQUIREMENTTYPE_N]);
                string typeV          = Convert.ToString(requirementRow[DB.COL_REQUIREMENTTYPE_V]);
                string comparatorType = Convert.ToString(requirementRow[DB.COL_REQUIREMENTTYPE_COMPARATOR]);

                int  startIndex = 0;
                int  index;
                int  i = 0;
                char param;
                formatParams = new object[3];
                while ((index = text.IndexOf('$', startIndex)) >= 0)
                {
                    param = Convert.ToChar(text.Substring(index + 1, 1));

                    if (param == Const.CODE_N)
                    {
                        formatParams[i++] = GenerateParameter(param, typeN, N);
                    }
                    else if (param == Const.CODE_V)
                    {
                        formatParams[i++] = GenerateParameter(param, typeV, V);
                    }
                    else if (param == Const.CODE_COMPARATOR)
                    {
                        formatParams[i++] = GenerateParameter(param, comp, comparatorType);
                    }

                    startIndex = index + 6;                     // skip ending $ of param clause
                }
            }

            if (!String.IsNullOrEmpty(text))
            {
                return(String.Format(text, formatParams));
            }
            else
            {
                Log.Warning("RequirementType unknown:" + Type);
                return("RequirementType unknown:" + Type);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Adds a new Requirement to the QuestPart.
        /// </summary>
        /// <param name="requirementType">RequirementType</param>
        /// <param name="requirementN">First Requirement Variable, meaning depends on RequirementType</param>
        /// <param name="requirementV">Second Requirement Variable, meaning depends on RequirementType</param>
        /// <param name="requirementComparator">Comparator used if some values are veeing compared</param>        
        public void AddRequirement(eRequirementType requirementType, Object requirementN, Object requirementV,eComparator requirementComparator) {

            IBehaviourRequirement requ = null;

            Type type = BehaviourMgr.GetTypeForRequirementType(requirementType);
            if (type != null)
            {                                
                requ = (IBehaviourRequirement)Activator.CreateInstance(type, new object[] { this.NPC, requirementN, requirementV, requirementComparator });
                AddRequirement(requ);
            }
            else
            {
                if (log.IsErrorEnabled)
                    log.Error("No registered requirement found for RequirementType " + requirementType);
            }

            
		}
        /// <summary>
        /// Creates a new QuestRequirement and does some basich compativilite checks for the parameters
        /// </summary>
        /// <param name="defaultNPC"></param>
        /// <param name="type"></param>
        /// <param name="n"></param>
        /// <param name="v"></param>
        /// <param name="comp"></param>
        public AbstractRequirement(GameNPC defaultNPC, eRequirementType type, object n, object v, eComparator comp) : this(defaultNPC, type, comp)
        {
            RequirementAttribute attr = BehaviourMgr.getRequirementAttribute(GetType());

            // handle parameter N
            object defaultValueN = GetDefaultValue(attr.DefaultValueN);

            N = (TypeN)BehaviourUtils.ConvertObject(n, defaultValueN, typeof(TypeN));
            CheckParameter(N, attr.IsNullableN, typeof(TypeN));

            // handle parameter V
            object defaultValueV = GetDefaultValue(attr.DefaultValueV);

            this.v = (TypeV)BehaviourUtils.ConvertObject(v, defaultValueV, typeof(TypeV));
            CheckParameter(V, attr.IsNullableV, typeof(TypeV));
        }
 public AbstractRequirement(GameNPC npc, eRequirementType type, eComparator comp)
 {
     defaultNPC = npc;
     this.type  = type;
     comparator = comp;
 }
 /// <summary>
 /// Creates a new QuestRequirement and does some basich compativilite checks for the parameters
 /// </summary>
 /// <param name="defaultNPC">Parent defaultNPC of this Requirement</param>
 /// <param name="n">First Requirement Variable, meaning depends on RequirementType</param>
 /// <param name="comp">Comparator used if some values are veeing compared</param>
 public RealmLevelRequirement(GameNPC defaultNPC, int n, eComparator comp)
     : this(defaultNPC, (object)n, (object)null, comp)
 {
 }
Esempio n. 8
0
 /// <summary>
 /// Creates a new QuestRequirement and does some basich compativilite checks for the parameters
 /// </summary>
 /// <param name="defaultNpc"></param>
 /// <param name="questType"></param>
 /// <param name="comp"></param>
 public QuestPendingRequirement(GameNPC defaultNpc, Type questType, eComparator comp)
     : this(defaultNpc, questType, null, comp)
 {
 }
Esempio n. 9
0
 /// <summary>
 /// Creates a new QuestRequirement and does some basich compativilite checks for the parameters
 /// </summary>
 /// <param name="defaultNPC"></param>
 /// <param name="n"></param>
 /// <param name="v"></param>
 /// <param name="comp"></param>
 public GroupNumberRequirement(GameNPC defaultNPC, object n, object v, eComparator comp)
     : base(defaultNPC, eRequirementType.GroupNumber, n, v, comp)
 {
 }
Esempio n. 10
0
 /// <summary>
 /// Creates a new QuestRequirement and does some basich compativilite checks for the parameters
 /// </summary>
 /// <param name="defaultNPC">Parent defaultNPC of this Requirement</param>
 /// <param name="n">First Requirement Variable, meaning depends on RequirementType</param>
 /// <param name="comp">Comparator used if some values are veeing compared</param>
 public GroupNumberRequirement(GameNPC defaultNPC, int n, eComparator comp)
     : this(defaultNPC, (object)n, (object)null, comp)
 {
 }
 /// <summary>
 /// Creates a new QuestRequirement and does some basich compativilite checks for the parameters
 /// </summary>
 /// <param name="defaultNPC"></param>
 /// <param name="n"></param>
 /// <param name="v"></param>
 /// <param name="comp"></param>
 public LevelRequirement(GameNPC defaultNPC, Object n, Object v, eComparator comp)
     : base(defaultNPC, eRequirementType.Level, n, v, comp)
 {
 }
Esempio n. 12
0
        /// <summary>
        /// Adds a new Requirement to the QuestPart.
        /// </summary>
        /// <param name="requirementType">RequirementType</param>
        /// <param name="requirementN">First Requirement Variable, meaning depends on RequirementType</param>
        /// <param name="requirementV">Second Requirement Variable, meaning depends on RequirementType</param>
        /// <param name="requirementComparator">Comparator used if some values are veeing compared</param>
        public void AddRequirement(eRequirementType requirementType, object requirementN, object requirementV, eComparator requirementComparator)
        {
            IBehaviourRequirement requ = null;

            Type type = BehaviourMgr.GetTypeForRequirementType(requirementType);

            if (type != null)
            {
                requ = (IBehaviourRequirement)Activator.CreateInstance(type, new object[] { NPC, requirementN, requirementV, requirementComparator });
                AddRequirement(requ);
            }
            else
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("No registered requirement found for RequirementType " + requirementType);
                }
            }
        }
Esempio n. 13
0
 /// <summary>
 /// Adds a new Requirement to the QuestPart.
 /// V will be null
 /// </summary>
 /// <param name="requirementType"></param>
 /// <param name="requirementN">First Requirement Variable, meaning depends on RequirementType</param>
 /// <param name="requirementComparator">Comparator used if some values are veeing compared</param>
 public void AddRequirement(eRequirementType requirementType, object requirementN, eComparator requirementComparator)
 {
     AddRequirement(requirementType, requirementN, null, requirementComparator);
 }
Esempio n. 14
0
 /// <summary>
 /// Creates a new QuestRequirement and does some basich compativilite checks for the parameters
 /// </summary>
 /// <param name="defaultNPC"></param>
 /// <param name="n"></param>
 /// <param name="v"></param>
 /// <param name="comp"></param>
 public EncumbranceRequirement(GameNPC defaultNPC, Object n, Object v, eComparator comp)
     : base(defaultNPC, eRequirementType.Encumbrance, n, v, comp)
 {
 }
Esempio n. 15
0
 /// <summary>
 /// Creates a new QuestRequirement and does some basich compativilite checks for the parameters
 /// </summary>
 /// <param name="defaultNPC"></param>
 /// <param name="n"></param>
 /// <param name="v"></param>
 /// <param name="comp"></param>
 public RealmRequirement(GameNPC defaultNPC, object n, object v, eComparator comp)
     : base(defaultNPC, eRequirementType.Realm, n, v, comp)
 {
 }
 /// <summary>
 /// Creates a new QuestRequirement and does some basich compativilite checks for the parameters
 /// </summary>
 /// <param name="defaultNPC"></param>
 /// <param name="n"></param>
 /// <param name="v"></param>
 /// <param name="comp"></param>
 public HealthRequirement(GameNPC defaultNPC, Object n, Object v, eComparator comp)
     : base(defaultNPC, eRequirementType.Health, n, v, comp)
 {
 }
 /// <summary>
 /// Creates a new QuestRequirement and does some basich compativilite checks for the parameters
 /// </summary>
 /// <param name="defaultNPC">Parent defaultNPC of this Requirement</param>
 /// <param name="n">First Requirement Variable, meaning depends on RequirementType</param>
 /// <param name="comp">Comparator used if some values are veeing compared</param>
 public HealthMaxRequirement(GameNPC defaultNPC, int n, eComparator comp)
     : this(defaultNPC, (object)n, (object)null, comp)
 {
 }
 /// <summary>
 /// Creates a new QuestRequirement and does some basich compativilite checks for the parameters
 /// </summary>
 /// <param name="defaultNPC">Parent defaultNPC of this Requirement</param>
 /// <param name="n">First Requirement Variable, meaning depends on RequirementType</param>
 /// <param name="v">Second Requirement Variable, meaning depends on RequirementType</param>
 /// <param name="comp">Comparator used if some values are veeing compared</param>
 public InventoryItemRequirement(GameNPC defaultNPC, ItemTemplate n, int v, eComparator comp)
     : this(defaultNPC, (object)n, (object)v, comp)
 {
 }
Esempio n. 19
0
 /// <summary>
 /// Creates a new QuestRequirement and does some basich compativilite checks for the parameters
 /// </summary>
 /// <param name="defaultNPC">Parent defaultNPC of this Requirement</param>
 /// <param name="n">First Requirement Variable, meaning depends on RequirementType</param>
 /// <param name="comp">Comparator used if some values are veeing compared</param>
 public GoldRequirement(GameNPC defaultNPC, long n, eComparator comp)
     : this(defaultNPC, (object)n, (object)null, comp)
 {
 }
 /// <summary>
 /// Compares value1 with value2
 /// Allowed Comparators: Less,Greater,Equal, NotEqual, None
 /// </summary>
 /// <param name="value1">Value1 one to compare</param>
 /// <param name="value2">Value2 to cmopare</param>
 /// <param name="comp">Comparator to use for Comparison</param>
 /// <returns>result of comparison</returns>
 protected static bool compare(int value1, int value2, eComparator comp)
 {
     return(compare((long)value1, (long)value2, comp));
 }
Esempio n. 21
0
        public static string RequirementText(eRequirementType Type, string N, string V, eComparator comp)
        {
            string text = null;
            object[] formatParams = null;
            DataRow requirementRow = DB.GetRequirementTypeRowForID((int)Type);
            if (requirementRow != null)
            {

                text = Convert.ToString(requirementRow[DB.COL_REQUIREMENTTYPE_TEXT]);
                string typeN = Convert.ToString(requirementRow[DB.COL_REQUIREMENTTYPE_N]);
                string typeV = Convert.ToString(requirementRow[DB.COL_REQUIREMENTTYPE_V]);
                string comparatorType = Convert.ToString(requirementRow[DB.COL_REQUIREMENTTYPE_COMPARATOR]);

                int startIndex = 0;
                int index;
                int i = 0;
                char param;
                formatParams = new object[3];
                while ((index = text.IndexOf('$', startIndex)) >= 0)
                {
                    param = Convert.ToChar(text.Substring(index + 1, 1));

                    if (param == Const.CODE_N)
                        formatParams[i++] = GenerateParameter(param, typeN, N);
                    else if (param == Const.CODE_V)
                        formatParams[i++] = GenerateParameter(param, typeV, V);
                    else if (param == Const.CODE_COMPARATOR)
                        formatParams[i++] = GenerateParameter(param, comp, comparatorType);

                    startIndex = index + 6; // skip ending $ of param clause
                }
            }

            if (!String.IsNullOrEmpty(text))
            {
                return String.Format(text, formatParams);
            }
            else
            {
                Log.Warning("RequirementType unknown:" + Type);
                return "RequirementType unknown:" + Type;
            }
        }
Esempio n. 22
0
 private static string GenerateParameter(char param, eComparator value, string comparatorType)
 {
     return(ComparatorToText(value, comparatorType));
 }
Esempio n. 23
0
 private static string ComparatorToText(eComparator comp, string comparatorType)
 {
     if (Const.COMPARATOR_QUANTITY.Equals(comparatorType))
     {
         switch (comp)
         {
             case eComparator.Equal:
                 return Resources.comparatorEqual;
             case eComparator.Greater:
                 return Resources.comparatorGreater;
             case eComparator.Less:
                 return Resources.comparatorLess;
             case eComparator.NotEqual:
                 return Resources.comparatorNotEqual;
             case eComparator.Not:
                 throw new ArgumentException("Comparator cannot be \"Not\" if type is quantity.");
             default:
                 return Resources.comparatorNone;
         }
     }
     else if (Const.COMPARATOR_BINARY.Equals(comparatorType))
     {
         switch (comp)
         {
             case eComparator.Equal:
                 throw new ArgumentException("Comparator cannot be \"Equal\" if type is quantity.");
             case eComparator.Greater:
                 throw new ArgumentException("Comparator cannot be \"Greater\" if type is quantity.");
             case eComparator.Less:
                 throw new ArgumentException("Comparator cannot be \"LEss\" if type is quantity.");
             case eComparator.NotEqual:
                 throw new ArgumentException("Comparator cannot be \"NotEquals\" if type is quantity.");
             case eComparator.Not:
                 return Resources.comparatorNot;
             default:
                 return Resources.comparatorIs;
         }
     }
     else
     {
         throw new ArgumentException("Unknown Comparatortype:\""+comparatorType+"\", check requirements config.", "comparatorType");
     }
 }
Esempio n. 24
0
 /// <summary>
 /// Adds a new Requirement to the QuestPart.
 /// V will be null
 /// </summary>
 /// <param name="requirementType"></param>
 /// <param name="requirementN">First Requirement Variable, meaning depends on RequirementType</param>
 /// <param name="requirementComparator">Comparator used if some values are veeing compared</param>
 public void AddRequirement(eRequirementType requirementType, Object requirementN, eComparator requirementComparator)
 {
     AddRequirement(requirementType, requirementN, null, requirementComparator);
 }
Esempio n. 25
0
 private static string GenerateParameter(char param, eComparator value, string comparatorType)
 {
     return ComparatorToText(value,comparatorType);
 }
Esempio n. 26
0
 /// <summary>
 /// Creates a new QuestRequirement and does some basich compativilite checks for the parameters
 /// </summary>
 /// <param name="defaultNPC"></param>
 /// <param name="n"></param>
 /// <param name="v"></param>
 /// <param name="comp"></param>
 public EquippedItemRequirement(GameNPC defaultNPC, Object n, Object v, eComparator comp)
     : base(defaultNPC, eRequirementType.EquippedItem, n, v, comp)
 {
 }
Esempio n. 27
0
 /// <summary>
 /// Creates a new QuestRequirement and does some basich compativilite checks for the parameters
 /// </summary>
 /// <param name="defaultNPC"></param>
 /// <param name="questType"></param>
 /// <param name="comp"></param>
 public QuestPendingRequirement(GameNPC defaultNPC, Type questType, eComparator comp)
     : this(defaultNPC, (object)questType, (object)null, comp)
 {
 }
Esempio n. 28
0
 /// <summary>
 /// Creates a new QuestRequirement and does some basich compativilite checks for the parameters
 /// </summary>
 /// <param name="defaultNPC"></param>
 /// <param name="n"></param>
 /// <param name="v"></param>
 /// <param name="comp"></param>
 public ManaRequirement(GameNPC defaultNPC, object n, object v, eComparator comp)
     : base(defaultNPC, eRequirementType.Mana, n, v, comp)
 {
 }
 /// <summary>
 /// Creates a new QuestRequirement and does some basich compativilite checks for the parameters
 /// </summary>
 /// <param name="defaultNPC">Parent defaultNPC of this Requirement</param>
 /// <param name="npc">First Requirement Variable, meaning depends on RequirementType</param>
 /// <param name="distance">Second Requirement Variable, meaning depends on RequirementType</param>
 /// <param name="comp">Comparator used if some values are veeing compared</param>
 public DistanceRequirement(GameNPC defaultNPC, GameLiving npc, int distance, eComparator comp)
     : this(defaultNPC, (object)npc, (object)distance, comp)
 {
 }
Esempio n. 30
0
 /// <summary>
 /// Creates a new QuestRequirement and does some basich compativilite checks for the parameters
 /// </summary>
 /// <param name="defaultNPC"></param>
 /// <param name="questType"></param>
 /// <param name="v"></param>
 /// <param name="comp"></param>
 public QuestGivableRequirement(GameNPC defaultNPC, Type questType, GameNPC v, eComparator comp)
     : this(defaultNPC, (object)questType, (object)v, comp)
 {
 }
Esempio n. 31
0
 /// <summary>
 /// Creates a new QuestRequirement and does some basich compativilite checks for the parameters
 /// </summary>
 /// <param name="defaultNPC"></param>
 /// <param name="n"></param>
 /// <param name="v"></param>
 /// <param name="comp"></param>
 public GuildRequirement(GameNPC defaultNPC, object n, object v, eComparator comp)
     : base(defaultNPC, eRequirementType.Guild, n, v, comp)
 {
 }
Esempio n. 32
0
 /// <summary>
 /// Creates a new QuestRequirement and does some basich compativilite checks for the parameters
 /// </summary>
 /// <param name="defaultNPC">Parent defaultNPC of this Requirement</param>
 /// <param name="n">First Requirement Variable, meaning depends on RequirementType</param>
 /// <param name="comp">Comparator used if some values are veeing compared</param>
 public EncumbranceRequirement(GameNPC defaultNPC, int n, eComparator comp)
     : this(defaultNPC, (object)n, (object)null, comp)
 {
 }
 /// <summary>
 /// Creates a new QuestRequirement and does some basich compativilite checks for the parameters
 /// </summary>
 /// <param name="defaultNPC"></param>
 /// <param name="n"></param>
 /// <param name="v"></param>
 /// <param name="comp"></param>
 public InventoryItemRequirement(GameNPC defaultNPC, object n, object v, eComparator comp)
     : base(defaultNPC, eRequirementType.InventoryItem, n, v, comp)
 {
 }
Esempio n. 34
0
        public static void AddRequirement(eRequirementType requirementType, int questPartID, eComparator comp)
        {
            if (questPartID < 0)
                return;

            DataRow row = DB.RequirementTable.NewRow();
            row[DB.COL_QUESTPARTREQUIREMENT_QUESTPARTID] = questPartID;
            row[DB.COL_QUESTPARTREQUIREMENT_TYPE] = requirementType;
            row[DB.COL_QUESTPARTREQUIREMENT_COMPARATOR] = (int)comp;
            DB.RequirementTable.Rows.Add(row);
        }
Esempio n. 35
0
 /// <summary>
 /// Creates a new QuestRequirement and does some basich compativilite checks for the parameters
 /// </summary>
 /// <param name="defaultNpc"></param>
 /// <param name="n"></param>
 /// <param name="v"></param>
 /// <param name="comp"></param>
 public QuestPendingRequirement(GameNPC defaultNpc, object n, object v, eComparator comp)
     : base(defaultNpc, eRequirementType.QuestPending, n, v, comp)
 {
 }