コード例 #1
0
        public static bool CanExchangeBOD(Mobile from, BaseVendor vendor, IBOD bod, int cost)
        {
            if (bod.BODType != vendor.BODType)
            {
                vendor.SayTo(from, 1152298, 0x3B2); // I don't deal in those goods.
                return(false);
            }

            if ((bod is SmallBOD && ((SmallBOD)bod).AmountCur > 0) ||
                (bod is LargeBOD && ((LargeBOD)bod).Entries != null &&
                 ((LargeBOD)bod).Entries.FirstOrDefault(e => e.Amount > 0) != null))
            {
                vendor.SayTo(from, 1152299, 0x3B2); // I am sorry to say I cannot work with a deed that is even partially filled.
                return(false);
            }

            if (bod.AmountMax == 20 && (!CanBeExceptional(bod) || bod.RequireExceptional) &&
                (!CanUseMaterial(bod) ||
                 (bod.Material == BulkMaterialType.Valorite ||
                  bod.Material == BulkMaterialType.Frostwood ||
                  bod.Material == BulkMaterialType.Barbed)))
            {
                vendor.SayTo(from, 1152291, 0x3B2); // I won't be able to replace that bulk order with a better one.
                return(false);
            }

            if (cost > -1 && !Banker.Withdraw(from, cost, true))
            {
                vendor.SayTo(from, 1152302, 0x3B2); // I am afraid your bank box does not contain the funds needed to complete this transaction.
                return(false);
            }

            return(true);
        }
コード例 #2
0
            public override void OnClick()
            {
                if (m_Vendor.SupportsBulkOrders(m_From))
                {
                    var ts = m_Vendor.GetNextBulkOrder(m_From);

                    var totalSeconds = (int)ts.TotalSeconds;
                    var totalHours   = (totalSeconds + 3599) / 3600;
                    var totalMinutes = (totalSeconds + 59) / 60;

                    if (Core.SE ? totalMinutes == 0 : totalHours == 0)
                    {
                        m_From.SendLocalizedMessage(1049038); // You can get an order now.

                        if (Core.AOS)
                        {
                            var bulkOrder = m_Vendor.CreateBulkOrder(m_From, true);

                            if (bulkOrder is LargeBOD bod)
                            {
                                m_From.SendGump(new LargeBODAcceptGump(m_From, bod));
                            }
                            else if (bulkOrder is SmallBOD smallBod)
                            {
                                m_From.SendGump(new SmallBODAcceptGump(m_From, smallBod));
                            }
                        }
                    }
                    else
                    {
                        var oldSpeechHue = m_Vendor.SpeechHue;
                        m_Vendor.SpeechHue = 0x3B2;

                        if (Core.SE)
                        {
                            m_Vendor.SayTo(
                                m_From,
                                1072058,
                                totalMinutes.ToString()
                                ); // An offer may be available in about ~1_minutes~ minutes.
                        }
                        else
                        {
                            m_Vendor.SayTo(
                                m_From,
                                1049039,
                                totalHours.ToString()
                                ); // An offer may be available in about ~1_hours~ hours.
                        }

                        m_Vendor.SpeechHue = oldSpeechHue;
                    }
                }
            }
コード例 #3
0
        public static bool CanExchangeBOD(Mobile from, BaseVendor vendor, IBOD bod, int cost)
        {
            if (bod.BODType != vendor.BODType)
            {
                vendor.SayTo(from, 1152298, 0x3B2); // I don't deal in those goods.
                return(false);
            }

            if (bod is SmallBOD sb && sb.AmountCur > 0)
            {
                vendor.SayTo(from, 1152299, 0x3B2); // I am sorry to say I cannot work with a deed that is even partially filled.
                return(false);
            }

            if (bod is LargeBOD lb && lb.Entries != null)
            {
                LargeBulkEntry first = null;

                for (var index = 0; index < lb.Entries.Length; index++)
                {
                    var e = lb.Entries[index];

                    if (e.Amount > 0)
                    {
                        first = e;
                        break;
                    }
                }

                if (first != null)
                {
                    vendor.SayTo(from, 1152299, 0x3B2); // I am sorry to say I cannot work with a deed that is even partially filled.
                    return(false);
                }
            }

            if (bod.AmountMax == 20 && (!CanBeExceptional(bod) || bod.RequireExceptional) && (!CanUseMaterial(bod) || bod.Material == BulkMaterialType.Valorite || bod.Material == BulkMaterialType.Frostwood || bod.Material == BulkMaterialType.Barbed))
            {
                vendor.SayTo(from, 1152291, 0x3B2); // I won't be able to replace that bulk order with a better one.
                return(false);
            }

            if (cost > -1 && !Banker.Withdraw(from, cost, true))
            {
                vendor.SayTo(from, 1152302, 0x3B2); // I am afraid your bank box does not contain the funds needed to complete this transaction.
                return(false);
            }

            return(true);
        }
コード例 #4
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                Container cont = from.Backpack;

                if (targeted is Item && cont != null && ((Item)targeted).IsChildOf(cont))
                {
                    IShopSellInfo[] info = m_Vendor.GetSellInfo();
                    Item            item = targeted as Item;

                    int    totalCost = 0;
                    string name      = null;

                    foreach (IShopSellInfo ssi in info)
                    {
                        if (ssi.IsSellable(item))
                        {
                            totalCost = ssi.GetBuyPriceFor(item);
                            name      = ssi.GetNameFor(item);
                            break;
                        }
                    }

                    if (name == null)
                    {
                        m_Vendor.SayTo(from, "I won't buy that.");
                    }
                    else if (totalCost == 0)
                    {
                        m_Vendor.SayTo(from, "I won't negotiate on free items.");
                    }
                    else
                    {
                        int        commerceCost  = totalCost;
                        string     commerceSkill = "non-existent";
                        LokaiSkill lokaiSkill    = (LokaiSkillUtilities.XMLGetSkills(from)).Commerce;

                        SuccessRating rating = LokaiSkillUtilities.CheckLokaiSkill(from, lokaiSkill, 0.0, 100.0);
                        switch (rating)
                        {
                        case SuccessRating.CriticalFailure:
                            commerceCost  = (int)(totalCost / CriticalFailure);
                            commerceSkill = "horrible";
                            break;

                        case SuccessRating.HazzardousFailure:
                            commerceCost  = (int)(totalCost / HazzardousFailure);
                            commerceSkill = "terrible";
                            break;

                        case SuccessRating.Failure:
                            commerceCost  = (int)(totalCost / Failure);
                            commerceSkill = "lousy";
                            break;

                        case SuccessRating.PartialSuccess:
                            commerceCost  = (int)(totalCost / PartialSuccess);
                            commerceSkill = "mediocre";
                            break;

                        case SuccessRating.Success:
                            commerceCost  = (int)(totalCost / Success);
                            commerceSkill = "good";
                            break;

                        case SuccessRating.CompleteSuccess:
                            commerceCost  = (int)(totalCost / CompleteSuccess);
                            commerceSkill = "adept";
                            break;

                        case SuccessRating.ExceptionalSuccess:
                            commerceCost  = (int)(totalCost / ExceptionalSuccess);
                            commerceSkill = "exceptional";
                            break;

                        case SuccessRating.TooEasy:
                            commerceCost  = (int)(totalCost / TooEasy);
                            commerceSkill = "unquestionable";
                            break;

                        default:
                        case SuccessRating.TooDifficult:
                            commerceCost  = (int)(totalCost / TooDifficult);
                            commerceSkill = "non-existent";
                            break;
                        }
                        m_Vendor.SayTo(from, "Normally, I would pay {0} for that (1), but due to your {2} commerce skill, I am paying you {3}.",
                                       totalCost, name, commerceSkill, commerceCost);
                        totalCost = commerceCost;
                        item.Consume();

                        if (totalCost > 1000)
                        {
                            from.AddToBackpack(new BankCheck(totalCost));
                        }
                        else if (totalCost > 0)
                        {
                            from.AddToBackpack(new Gold(totalCost));
                        }
                    }
                }
                else
                {
                    from.SendMessage("You can only sell items in your backpack.");
                }
            }