Пример #1
0
        public static bool CheckMatch(Item item, int price, SearchCriteria searchCriteria)
        {
            if (item is CommodityDeed && ((CommodityDeed)item).Commodity != null)
            {
                item = ((CommodityDeed)item).Commodity;
            }

            if (searchCriteria.MinPrice > -1 && price < searchCriteria.MinPrice)
            {
                return(false);
            }

            if (searchCriteria.MaxPrice > -1 && price > searchCriteria.MaxPrice)
            {
                return(false);
            }

            if (!string.IsNullOrEmpty(searchCriteria.SearchName))
            {
                string name;

                if (item is CommodityDeed && ((CommodityDeed)item).Commodity is ICommodity)
                {
                    var commodity = (ICommodity)((CommodityDeed)item).Commodity;

                    if (!string.IsNullOrEmpty(commodity.Description.String))
                    {
                        name = commodity.Description.String;
                    }
                    else
                    {
                        name = StringList.GetString(commodity.Description.Number);
                    }
                }
                else
                {
                    name = GetItemName(item);
                }

                if (name == null)
                {
                    return(false); // TODO? REturn null names?
                }

                if (!CheckKeyword(searchCriteria.SearchName, item) && name.ToLower().IndexOf(searchCriteria.SearchName.ToLower()) < 0)
                {
                    return(false);
                }
            }

            if (searchCriteria.SearchType != Layer.Invalid && searchCriteria.SearchType != item.Layer)
            {
                return(false);
            }

            if (searchCriteria.Details.Count == 0)
            {
                return(true);
            }

            foreach (SearchDetail detail in searchCriteria.Details)
            {
                object o     = detail.Attribute;
                int    value = detail.Value;

                if (value == 0)
                {
                    value = 1;
                }

                if (o is AosAttribute)
                {
                    AosAttributes attrs = RunicReforging.GetAosAttributes(item);

                    if (attrs == null || attrs[(AosAttribute)o] < value)
                    {
                        return(false);
                    }
                }
                else if (o is AosWeaponAttribute)
                {
                    AosWeaponAttributes attrs = RunicReforging.GetAosWeaponAttributes(item);

                    if ((AosWeaponAttribute)o == AosWeaponAttribute.MageWeapon)
                    {
                        if (attrs == null || attrs[(AosWeaponAttribute)o] == 0 || attrs[(AosWeaponAttribute)o] > Math.Max(0, 30 - value))
                        {
                            return(false);
                        }
                    }
                    else if (attrs == null || attrs[(AosWeaponAttribute)o] < value)
                    {
                        return(false);
                    }
                }
                else if (o is SAAbsorptionAttribute)
                {
                    SAAbsorptionAttributes attrs = RunicReforging.GetSAAbsorptionAttributes(item);

                    if (attrs == null || attrs[(SAAbsorptionAttribute)o] < value)
                    {
                        return(false);
                    }
                }
                else if (o is AosArmorAttribute)
                {
                    AosArmorAttributes attrs = RunicReforging.GetAosArmorAttributes(item);

                    if (attrs == null || attrs[(AosArmorAttribute)o] < value)
                    {
                        return(false);
                    }
                }
                else if (o is SkillName)
                {
                    if (detail.Category != Category.RequiredSkill)
                    {
                        AosSkillBonuses skillbonuses = RunicReforging.GetAosSkillBonuses(item);

                        if (skillbonuses != null)
                        {
                            bool hasSkill = false;

                            for (int i = 0; i < 5; i++)
                            {
                                if (skillbonuses.GetValues(i, out SkillName check, out double bonus) && check == (SkillName)o && bonus >= value)
                                {
                                    hasSkill = true;
                                    break;
                                }
                            }

                            if (!hasSkill)
                            {
                                return(false);
                            }
                        }
                        else if (item is SpecialScroll && value >= 105)
                        {
                            if (((SpecialScroll)item).Skill != (SkillName)o || ((SpecialScroll)item).Value < value)
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else if (!(item is BaseWeapon) || ((BaseWeapon)item).DefSkill != (SkillName)o)
                    {
                        return(false);
                    }
                }
                else if (!CheckSlayer(item, o))
                {
                    return(false);
                }
                else if (o is AosElementAttribute)
                {
                    if (item is BaseWeapon)
                    {
                        BaseWeapon wep = item as BaseWeapon;

                        if (detail.Category == Category.DamageType)
                        {
                            wep.GetDamageTypes(null, out int phys, out int fire, out int cold, out int pois, out int nrgy, out int chaos, out int direct);

                            switch ((AosElementAttribute)o)
                            {
                            case AosElementAttribute.Physical: if (phys < value)
                                {
                                    return(false);
                                }
                                break;

                            case AosElementAttribute.Fire: if (fire < value)
                                {
                                    return(false);
                                }
                                break;

                            case AosElementAttribute.Cold: if (cold < value)
                                {
                                    return(false);
                                }
                                break;

                            case AosElementAttribute.Poison: if (pois < value)
                                {
                                    return(false);
                                }
                                break;

                            case AosElementAttribute.Energy: if (nrgy < value)
                                {
                                    return(false);
                                }
                                break;

                            case AosElementAttribute.Chaos: if (chaos < value)
                                {
                                    return(false);
                                }
                                break;

                            case AosElementAttribute.Direct: if (direct < value)
                                {
                                    return(false);
                                }
                                break;
                            }
                        }
                        else
                        {
                            switch ((AosElementAttribute)o)
                            {
                            case AosElementAttribute.Physical:
                                if (wep.WeaponAttributes.ResistPhysicalBonus < value)
                                {
                                    return(false);
                                }

                                break;

                            case AosElementAttribute.Fire:
                                if (wep.WeaponAttributes.ResistFireBonus < value)
                                {
                                    return(false);
                                }

                                break;

                            case AosElementAttribute.Cold:
                                if (wep.WeaponAttributes.ResistColdBonus < value)
                                {
                                    return(false);
                                }

                                break;

                            case AosElementAttribute.Poison:
                                if (wep.WeaponAttributes.ResistPoisonBonus < value)
                                {
                                    return(false);
                                }

                                break;

                            case AosElementAttribute.Energy:
                                if (wep.WeaponAttributes.ResistEnergyBonus < value)
                                {
                                    return(false);
                                }

                                break;
                            }
                        }
                    }
                    else if (item is BaseArmor && detail.Category == Category.Resists)
                    {
                        BaseArmor armor = item as BaseArmor;

                        switch ((AosElementAttribute)o)
                        {
                        case AosElementAttribute.Physical:
                            if (armor.PhysicalResistance < value)
                            {
                                return(false);
                            }

                            break;

                        case AosElementAttribute.Fire:
                            if (armor.FireResistance < value)
                            {
                                return(false);
                            }

                            break;

                        case AosElementAttribute.Cold:
                            if (armor.ColdResistance < value)
                            {
                                return(false);
                            }

                            break;

                        case AosElementAttribute.Poison:
                            if (armor.PoisonResistance < value)
                            {
                                return(false);
                            }

                            break;

                        case AosElementAttribute.Energy:
                            if (armor.EnergyResistance < value)
                            {
                                return(false);
                            }

                            break;
                        }
                    }
                    else if (detail.Category != Category.DamageType)
                    {
                        AosElementAttributes attrs = RunicReforging.GetElementalAttributes(item);

                        if (attrs == null || attrs[(AosElementAttribute)o] < value)
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (o is Misc)
                {
                    switch ((Misc)o)
                    {
                    case Misc.ExcludeFel: break;

                    case Misc.GargoyleOnly:
                        if (!IsGargoyle(item))
                        {
                            return(false);
                        }

                        break;

                    case Misc.NotGargoyleOnly:
                        if (IsGargoyle(item))
                        {
                            return(false);
                        }

                        break;

                    case Misc.ElvesOnly:
                        if (!IsElf(item))
                        {
                            return(false);
                        }

                        break;

                    case Misc.NotElvesOnly:
                        if (IsElf(item))
                        {
                            return(false);
                        }

                        break;

                    case Misc.FactionItem:
                        if (!(item is Factions.IFactionItem))
                        {
                            return(false);
                        }

                        break;

                    case Misc.PromotionalToken:
                        if (!(item is PromotionalToken))
                        {
                            return(false);
                        }

                        break;

                    case Misc.Cursed:
                        if (item.LootType != LootType.Cursed)
                        {
                            return(false);
                        }

                        break;

                    case Misc.NotCursed:
                        if (item.LootType == LootType.Cursed)
                        {
                            return(false);
                        }

                        break;

                    case Misc.CannotRepair:
                        if (CheckCanRepair(item))
                        {
                            return(false);
                        }

                        break;

                    case Misc.NotCannotBeRepaired:
                        if (!CheckCanRepair(item))
                        {
                            return(false);
                        }

                        break;

                    case Misc.Brittle:
                        NegativeAttributes neg2 = RunicReforging.GetNegativeAttributes(item);
                        if (neg2 == null || neg2.Brittle == 0)
                        {
                            return(false);
                        }

                        break;

                    case Misc.NotBrittle:
                        NegativeAttributes neg3 = RunicReforging.GetNegativeAttributes(item);
                        if (neg3 != null && neg3.Brittle > 0)
                        {
                            return(false);
                        }

                        break;

                    case Misc.Antique:
                        NegativeAttributes neg4 = RunicReforging.GetNegativeAttributes(item);
                        if (neg4 == null || neg4.Antique == 0)
                        {
                            return(false);
                        }

                        break;

                    case Misc.NotAntique:
                        NegativeAttributes neg5 = RunicReforging.GetNegativeAttributes(item);
                        if (neg5 != null && neg5.Antique > 0)
                        {
                            return(false);
                        }

                        break;
                    }
                }
                else if (o is string)
                {
                    string str = o as string;

                    if (str == "WeaponVelocity" && (!(item is BaseRanged) || ((BaseRanged)item).Velocity < value))
                    {
                        return(false);
                    }

                    if (str == "SearingWeapon" && (!(item is BaseWeapon) || !((BaseWeapon)item).SearingWeapon))
                    {
                        return(false);
                    }

                    if (str == "ArtifactRarity" && (!(item is IArtifact) || ((IArtifact)item).ArtifactRarity < value))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Пример #2
0
        public override void AddGumpLayout()
        {
            AddAlphaRegion(50, 50, 50, 50);
            AddImage(0, 0, 5400);

            AddHtmlLocalized(150, 37, 190, 16, CenterLoc, "#1116689", darkHue, false, false);  // WANTED FOR PIRACY
            AddHtmlLocalized(150, 320, 190, 16, CenterLoc, "#1116703", darkHue, false, false); // WANTED DEAD OR ALIVE

            AddHtmlLocalized(180, 135, 200, 16, 1116704, lightHue, false, false);              //Notice to all sailors
            AddHtmlLocalized(130, 150, 300, 16, 1116705, lightHue, false, false);              //There be a bounty on these lowlifes!
            AddHtmlLocalized(150, 170, 300, 16, 1116706, lightHue, false, false);              //See officers fer information.
            AddHtmlLocalized(195, 190, 300, 16, 1116707, lightHue, false, false);              //********

            if (Index < 0)
            {
                Index = 0;
            }
            if (Index >= BountyQuestSpawner.Bounties.Count)
            {
                Index = BountyQuestSpawner.Bounties.Count - 1;
            }

            List <Mobile> mobs = new List <Mobile>(BountyQuestSpawner.Bounties.Keys);

            if (mobs.Count == 0)
            {
                return;
            }

            int y   = 210;
            int idx = 0;

            for (int i = Index; i < mobs.Count; i++)
            {
                if (idx++ > 4)
                {
                    break;
                }

                Mobile mob      = mobs[i];
                int    toReward = 1000;

                BountyQuestSpawner.Bounties.TryGetValue(mob, out toReward);
                PirateCaptain capt = mob as PirateCaptain;

                if (capt == null)
                {
                    continue;
                }

                string args;

                if (User.NetState != null && User.NetState.IsEnhancedClient && VendorSearch.StringList != null)
                {
                    Ultima.StringList strList = VendorSearch.StringList;

                    args = String.Format("{0} {1} {2}", strList.GetString(capt.Adjective), strList.GetString(capt.Noun), capt.PirateName > 0 ? strList.GetString(capt.PirateName) : capt.Name);

                    AddHtml(110, y, 400, 16, Color(C16232(lightHue), args), false, false);
                }
                else
                {
                    if (capt.PirateName > 0)
                    {
                        args = String.Format("#{0}\t#{1}\t#{2}", capt.Adjective, capt.Noun, capt.PirateName);
                    }
                    else
                    {
                        args = String.Format("#{0}\t#{1}\t{2}", capt.Adjective, capt.Noun, capt.Name);
                    }

                    AddHtmlLocalized(110, y, 400, 16, 1116690 + (idx - 1), args, lightHue, false, false); // ~1_val~ ~2_val~ ~3_val~
                }

                AddHtmlLocalized(280, y, 125, 16, 1116696 + (idx - 1), toReward.ToString(), lightHue, false, false); // Reward: ~1_val~

                y += 16;
            }

            AddButton(362, 115, 2084, 2084, 1 + Index, GumpButtonType.Reply, 0);
            AddButton(362, 342, 2085, 2085, 500 + Index, GumpButtonType.Reply, 0);
        }