Beispiel #1
0
        public override void Delete()
        {
            base.Delete();

            if (Auction != null)
            {
                Auction.Cancel();
                Auction = null;
            }
        }
Beispiel #2
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            base.OnResponse(state, info);

            switch (info.ButtonID)
            {
            case 1:
                if (Auction.CheckModifyAuction(User, true))
                {
                    User.BeginTarget(-1, false, TargetFlags.None, (from, targeted) =>
                    {
                        Item item = targeted as Item;

                        if (!IsBadItem(item))
                        {
                            if (item == Auction.AuctionItem)
                            {
                                User.SendMessage("You have removed the item from the auction.");
                                Auction.AuctionItem = null;
                                item.Movable        = true;
                                User.AddToBackpack(item);
                            }
                            else if (item.IsChildOf(User.Backpack))
                            {
                                if (Auction.AuctionItem != null)
                                {
                                    Auction.AuctionItem.Movable = true;
                                    User.AddToBackpack(Auction.AuctionItem);
                                    Auction.AuctionItem = null;

                                    User.SendMessage("You swap out auction items.");
                                }
                                else
                                {
                                    User.SendMessage("You have selected an auction item.");
                                }

                                Auction.AuctionItem = item;
                                item.Movable        = false;
                                item.MoveToWorld(new Point3D(Safe.X, Safe.Y, Safe.Z + Safe.Components[0].ItemData.CalcHeight), Safe.Map);
                            }
                        }
                        else
                        {
                            User.SendMessage("You cannot add that to your auction.");
                        }
                        Refresh();
                    });
                }
                break;

            case 2:
                TextRelay relay = info.GetTextEntry(1);
                string    str   = null;

                if (relay != null)
                {
                    str = relay.Text;
                }

                if (str == null || str.Trim().Length > 150 || !Server.Guilds.BaseGuildGump.CheckProfanity(str))
                {
                    User.SendMessage(0x22, "Invalid description.");
                }
                else
                {
                    Auction.Description = Utility.FixHtml(str.Trim());
                }
                Refresh();
                break;

            case 3:
                if (Auction.CheckModifyAuction(User))
                {
                    Auction.Duration = 3;
                }
                Refresh();
                break;

            case 4:
                if (Auction.CheckModifyAuction(User))
                {
                    Auction.Duration = 5;
                }
                Refresh();
                break;

            case 5:
                if (Auction.CheckModifyAuction(User))
                {
                    Auction.Duration = 7;
                }
                Refresh();
                break;

            case 6:
                TextRelay relay1 = info.GetTextEntry(2);

                string plat1 = null;
                string gold1 = null;

                if (relay1 != null)
                {
                    plat1 = relay1.Text;
                }

                relay1 = info.GetTextEntry(3);

                if (relay1 != null)
                {
                    gold1 = relay1.Text;
                }

                long platAmnt = Utility.ToInt64(plat1);
                long goldAmnt = Utility.ToInt64(gold1);

                if (Auction.CheckModifyAuction(User) && platAmnt >= 0 && goldAmnt >= 0)
                {
                    if (platAmnt > long.MaxValue)
                    {
                        User.SendMessage("Who in Sosaria has that much gold? Try a lower amount.");
                        break;
                    }

                    _TempBid += platAmnt * Account.CurrencyThreshold;

                    if (goldAmnt > long.MaxValue)
                    {
                        User.SendMessage("That bid is too high. Try converting some of your gold bid into a plat bid.");
                        return;
                    }

                    _TempBid += goldAmnt;
                }
                else
                {
                    _NoBid = true;
                }

                if (!_NoBid)
                {
                    Auction.CurrentBid = _TempBid;
                }

                Refresh();
                break;

            case 7:
                TextRelay relay2 = info.GetTextEntry(4);

                string plat2 = null;
                string gold2 = null;

                if (relay2 != null)
                {
                    plat2 = relay2.Text;
                }

                relay2 = info.GetTextEntry(5);

                if (relay2 != null)
                {
                    gold2 = relay2.Text;
                }

                long platAmnt2 = Utility.ToInt64(plat2);
                long goldAmnt2 = Utility.ToInt64(gold2);

                if (Auction.CheckModifyAuction(User) && platAmnt2 >= 0 && goldAmnt2 >= 0)
                {
                    if (platAmnt2 > long.MaxValue)
                    {
                        User.SendMessage("Who in Sosaria has that much gold? Try a lower amount.");
                        return;
                    }

                    _TempBuyout += platAmnt2 * Account.CurrencyThreshold;

                    if (goldAmnt2 > long.MaxValue)
                    {
                        User.SendMessage("That bid is too high. Try converting some of your gold bid into a plat bid.");
                        return;
                    }

                    _TempBuyout += goldAmnt2;
                }

                Auction.Buyout = _TempBuyout;

                Refresh();
                break;

            case 8:
                if (Auction.CurrentBid <= 0)
                {
                    User.SendLocalizedMessage(1156434);     // You must set a starting bid.
                }
                else
                {
                    Auction.OnBegin();
                }

                Refresh();
                break;

            case 23:
                if (Auction.OnGoing && Auction.HighestBid == null)
                {
                    Auction.Cancel();
                }
                break;
            }
        }