// Limitation on the item property public override bool Guage(object o, ref ArrayList Fallthroughs) { if (o == null || !(o is HeldItem)) // wea: 28/Feb/2007 Added safety check { return(false); } // We'll be dealing with a helditem object then HeldItem ipi = (HeldItem)o; // Limit // -1 - Fall through : if the item matches, passes all checks // 0 - Require the value to be at least this / require this property // 1 - Limit the value to a max of this / only this if (ipi.m_Type == ItemType || ipi.m_Type.IsSubclassOf(ItemType)) { PlayerMobile FakeGM = new PlayerMobile(); FakeGM.AccessLevel = AccessLevel.GameMaster; int FailCount = 0; foreach (Item item in ipi.Ref) { if (Fallthroughs.Contains(item)) { continue; // Fallthrough } string PropTest = Properties.GetValue(FakeGM, item, Property); if (PropertyVal != "") { Regex IPMatch = new Regex("= \"*" + PropertyVal, RegexOptions.IgnoreCase); if (IPMatch.IsMatch(PropTest)) { switch (Limit) { case -1: // Not required, but has fallthrough and matches so skip to next item reference Fallthroughs.Add(item); continue; case 1: // It's limited to this and has matched, so that's fine continue; case 0: // Required, matched, so fine continue; } } else { switch (Limit) { case -1: // Not required, so don't worry but don't fallthrough either continue; case 1: // It's limited to this and doesn't match, so it fails break; case 0: // Required, not matched so not cool break; } } } else { // Ascertain numeric value string sNum = ""; int iStrPos = Property.Length + 3; while (PropTest[iStrPos] != ' ') { sNum += PropTest[iStrPos++]; } int iCompareTo; try { iCompareTo = Convert.ToInt32(sNum); } catch (Exception exc) { Console.WriteLine("TourneyStoneAddon: Exception - (trying to convert {1} to integer)", exc, sNum); continue; } switch (Limit) { case 0: if (iCompareTo >= Quantity) { continue; } break; case 1: if (iCompareTo <= Quantity) { continue; } break; case -1: if (iCompareTo <= Quantity) { Fallthroughs.Add(item); continue; } break; } } // FAILED!!! Otherwise we would have continued FailCount++; } // Loop Item if (FailCount > 0) { ClassNameTranslator cnt = new ClassNameTranslator(); Rule.FailTextDyn = string.Format("{0} x {1}", FailCount, cnt.TranslateClass(ipi.m_Type)); return(false); } else { return(true); } } return(true); }
// Item type + amount kind of rule public override bool Guage(object o, ref ArrayList Fallthroughs) { if (o == null || o.GetType() != typeof(ArrayList)) { return(false); } // wea: 25/Feb/2007 Modified to receive CurrentHeld list as opposed // to individual HeldItem int RuleItemMatchQty = 0; foreach (HeldItem hi in ((ArrayList)o)) { if (hi.m_Type == ItemType || hi.m_Type.IsSubclassOf(ItemType)) { RuleItemMatchQty += hi.m_Count; } } // Limit // -1 - Fall through : if the item count matches, all conditions pass // 0 - Require the count to be at least this // 1 - Limit the count to a maximum of this switch (Limit) { case -1: if (RuleItemMatchQty >= Quantity) { foreach (HeldItem hi in ((ArrayList)o)) { foreach (Item item in hi.Ref) { Fallthroughs.Add(item); } } } return(true); case 1: if (RuleItemMatchQty > Quantity) { break; } return(true); case 0: if (RuleItemMatchQty < Quantity) { break; } return(true); } // FAILED!! ClassNameTranslator cnt = new ClassNameTranslator(); Rule.FailTextDyn = string.Format("{0} x {1}", RuleItemMatchQty, cnt.TranslateClass(this.ItemType)); return(false); }
public virtual void GenerateiProps(object miref) { // Item type ItemType = miref.GetType(); // Approximate label ClassNameTranslator cnt = new ClassNameTranslator(); sApproxLabel = cnt.TranslateClass(ItemType); // Magical properties iProps = new int[4]; // Default to blacksmithing requirement for enhancement iMajorSkill = (int)SkillName.Blacksmith; if (miref is BaseArmor) { BaseArmor ba = (BaseArmor)miref; // Stored : Protection / Durability iProps[0] = ba.GetProtOffset() + 1; iProps[1] = (int)ba.Durability; iProps[2] = 0; // Figure out what kind of material was used if (ba.MaterialType == ArmorMaterialType.Leather || ba.MaterialType == ArmorMaterialType.Studded || ba.MaterialType == ArmorMaterialType.Bone) { iMajorSkill = (int)SkillName.Tailoring; } else if (miref is WoodenShield) { iMajorSkill = (int)SkillName.Carpentry; } } else if (miref is BaseWeapon) { BaseWeapon bw = (BaseWeapon)miref; // Stored : Damage / Durability / Accuracy / Silver iProps[0] = (int)bw.DamageLevel; iProps[1] = (int)bw.DurabilityLevel; iProps[2] = (int)bw.AccuracyLevel; iProps[3] = (int)bw.Slayer; // If it's a bow or a staff, a carpenter made it. // Blackstaffs are made by tinkers. if (miref is BaseRanged || (miref is BaseStaff && !(miref is BlackStaff)) || miref is Club) { iMajorSkill = (int)SkillName.Carpentry; } else if (miref is BlackStaff || miref is Pitchfork) { iMajorSkill = (int)SkillName.Tinkering; } } else if (miref is BaseClothing) { // Store : // [0] - int representing the type of charge // [1] - int representing the number of charges BaseClothing bc = (BaseClothing)miref; iProps[0] = (int)bc.MagicType; iProps[1] = (int)bc.MagicCharges; iMajorSkill = (int)SkillName.Tailoring; } else if (miref is BaseJewel) { // Store : // [0] - int representing the type of charge // [1] - int representing the number of charges BaseJewel bj = (BaseJewel)miref; iProps[0] = (int)bj.MagicType; iProps[1] = (int)bj.MagicCharges; iMajorSkill = (int)SkillName.Tinkering; } else { // We've been passed an object that cannot be handled... // don't drop this enchanted item! this.Delete(); return; } // Skill requirements SkillReq = new int[52]; // all enhancements require these SkillReq[(int)SkillName.Magery] = 80; if (ItemType.IsSubclassOf(typeof(BaseJewel)) || ItemType.IsSubclassOf(typeof(BaseClothing))) { SkillReq[(int)SkillName.ItemID] = 80; } else { SkillReq[(int)SkillName.ArmsLore] = 80; } // base final skill on what kind of object we're dealing with SkillReq[iMajorSkill] = 90; }
// Attempt to encode a commodity deed with new data public static bool RCDEncode(CommodityDeed cd, string sData) { ClassNameTranslator cnt = new ClassNameTranslator(); // Make sure there isn't already a resource attached to the deed if (cd.CommodityAmount > 0) { RCDLogger.Log(LogType.Text, string.Format("{0}:{1}:{2}:{3}:{4}", cd.Serial.ToString(), cnt.TranslateClass(cd.Type), cd.CommodityAmount.ToString(), cd.Location, "ALREADY FILLED")); RCDCaller.SendMessage("Warning! Filled deed detected... see logfile!"); return(false); } // Perform the replacement int iStartIDX = sData.IndexOf("\""); int iEndIDX = sData.IndexOf("\"", iStartIDX + 1); string sType = sData.Substring((iStartIDX + 1), (iEndIDX - iStartIDX - 1)); Type tType = ScriptCompiler.FindTypeByName(sType); if (tType == null) { // Invalid RCDLogger.Log(LogType.Text, string.Format("{0}:{1}:{2}:{3}:{4}", cd.Serial.ToString(), sType, "", cd.Location, "INVALID")); RCDCaller.SendMessage("Warning! Invalid type detected... see logfile!"); return(false); } // Next work out the quantity of the data we're going to map to the deed iStartIDX = sData.IndexOf(",", iEndIDX) + 1; iEndIDX = sData.Length; string sQuantity = sData.Substring(iStartIDX, (iEndIDX - iStartIDX)); int iQuantity; try { iQuantity = Convert.ToInt32(sQuantity); } catch (Exception e) { Console.WriteLine("RemapCommDeeds: Exception - (trying to convert {0} to an integer)", sQuantity); RCDLogger.Log(LogType.Text, string.Format("{0}:{1}:{2}:{3}:{4}", cd.Serial.ToString(), cd.Type.ToString(), sQuantity, cd.Location, "INVALID")); RCDCaller.SendMessage("Warning! Invalid quantity detected (non numeric)... see logfile!"); return(false); } // All good, encode it... cd.Type = tType; cd.CommodityAmount = iQuantity; cd.Description = string.Format("{0} {1}", iQuantity, cnt.TranslateClass(tType)); RCDLogger.Log(LogType.Text, string.Format("{0}:{1}:{2}:{3}:{4}", cd.Serial.ToString(), sType, iQuantity, cd.Location, "PATCHED")); return(true); }