Esempio n. 1
0
        public BidEntry GetBidEntry(Mobile m, bool create = true)
        {
            BidEntry entry = Bids.FirstOrDefault(e => m == e.Mobile);

            if (entry == null && create && m is PlayerMobile)
            {
                entry = new BidEntry((PlayerMobile)m);
                Bids.Add(entry);
            }

            return(entry);
        }
Esempio n. 2
0
        public Auction(AuctionSafe safe, GenericReader reader)
        {
            Safe = safe;

            int version = reader.ReadInt();

            Owner       = reader.ReadMobile();
            AuctionItem = reader.ReadItem();
            CurrentBid  = reader.ReadLong();
            StartBid    = reader.ReadLong();
            Buyout      = reader.ReadLong();
            Description = reader.ReadString();

            if (version == 1)
            {
                Duration = reader.ReadInt();
            }
            else
            {
                int TempDuration = reader.ReadInt();

                Duration = TempDuration == 7 ? 10080 : TempDuration == 5 ? 7200 : 4320;
            }

            StartTime = reader.ReadDateTime();
            OnGoing   = reader.ReadBool();

            Bids = new List <BidEntry>();

            int count = reader.ReadInt();

            for (int i = 0; i < count; i++)
            {
                PlayerMobile m     = reader.ReadMobile() as PlayerMobile;
                BidEntry     entry = new BidEntry(m, reader);

                if (m != null)
                {
                    Bids.Add(entry);

                    if (entry.CurrentBid > 0 && (HighestBid == null || entry.CurrentBid > HighestBid.CurrentBid))
                    {
                        HighestBid = entry;
                    }
                }
            }

            count = reader.ReadInt();

            if (count > 0)
            {
                BidHistory = new List <HistoryEntry>();
            }

            for (int i = 0; i < count; i++)
            {
                BidHistory.Add(new HistoryEntry(reader));
            }

            if (HasBegun)
            {
                Auctions.Add(this);
            }
        }
Esempio n. 3
0
        public bool TryPlaceBid(Mobile m, long bidTotal)
        {
            if (!OnGoing || InClaimPeriod)
            {
                m.SendLocalizedMessage(1156432); // There is no active auction to complete this action.
                return(false);
            }

            BidEntry entry = GetBidEntry(m);
            Account  acct  = m.Account as Account;

            long highestBid = HighestBid != null ? HighestBid.CurrentBid : CurrentBid;

            if (acct == null || Banker.GetBalance(m) < bidTotal)
            {
                m.SendLocalizedMessage(1155867); // The amount entered is invalid. Verify that there are sufficient funds to complete this transaction.
                return(false);
            }
            else if (bidTotal < entry.CurrentBid || entry == HighestBid)
            {
                m.SendLocalizedMessage(1156445); // You have been out bid.
                return(false);
            }

            if (bidTotal <= highestBid)
            {
                m.SendLocalizedMessage(1156445);                 // You have been out bid.
            }
            else
            {
                acct.WithdrawGold(bidTotal);
                entry.CurrentBid = bidTotal;

                CurrentBid = highestBid + 1;

                if (HighestBid != null)
                {
                    string name = "Unknown Item";

                    if (AuctionItem.Name != null)
                    {
                        name = AuctionItem.Name;
                    }
                    else
                    {
                        name = String.Format("#{0}", AuctionItem.LabelNumber.ToString());
                    }

                    var message = new NewMaginciaMessage(null, new TextDefinition(1156427), String.Format("{0}\t{1}\t{2}",
                                                                                                          name,
                                                                                                          CurrentPlatBid.ToString("N0", CultureInfo.GetCultureInfo("en-US")),
                                                                                                          CurrentGoldBid.ToString("N0", CultureInfo.GetCultureInfo("en-US"))));

                    /*  You have been out bid in an auction for ~1_ITEMNAME~. The current winning bid amount is
                     * ~2_BIDAMT~plat and ~3_BIDAMT~gp.*/
                    MaginciaLottoSystem.SendMessageTo(HighestBid.Mobile, message);

                    Account a = HighestBid.Mobile.Account as Account;

                    if (a != null)
                    {
                        a.DepositGold(HighestBid.CurrentBid);
                    }

                    HighestBid.CurrentBid = 0;
                }

                m.SendLocalizedMessage(1156433);                 // Your bid has been placed.

                AuctionMap map = new AuctionMap(Safe);

                if (m.Backpack == null || !m.Backpack.TryDropItem(m, map, false))
                {
                    map.Delete();
                }
                else
                {
                    m.SendLocalizedMessage(1156478); // The auction safe map has been placed in your backpack.
                }

                HighestBid = entry;
                AddToHistory(m, entry.CurrentBid);
                return(true);
            }

            return(false);
        }
Esempio n. 4
0
        public Auction(AuctionSafe safe, GenericReader reader)
        {
            Safe = safe;

            int version = reader.ReadInt();

            switch (version)
            {
            case 2:
                ClaimPeriod = reader.ReadDateTime();
                goto case 1;

            case 1:
                Owner       = reader.ReadMobile();
                AuctionItem = reader.ReadItem();
                CurrentBid  = reader.ReadLong();
                StartBid    = reader.ReadLong();
                Buyout      = reader.ReadLong();
                Description = reader.ReadString();
                Duration    = reader.ReadInt();

                StartTime = reader.ReadDateTime();
                OnGoing   = reader.ReadBool();

                Bids = new List <BidEntry>();

                int count = reader.ReadInt();
                for (int i = 0; i < count; i++)
                {
                    PlayerMobile m     = reader.ReadMobile() as PlayerMobile;
                    BidEntry     entry = new BidEntry(m, reader);

                    if (m != null)
                    {
                        Bids.Add(entry);

                        if (entry.CurrentBid > 0 && (HighestBid == null || entry.CurrentBid > HighestBid.CurrentBid))
                        {
                            HighestBid = entry;
                        }
                    }
                }

                count = reader.ReadInt();

                if (count > 0)
                {
                    BidHistory = new List <HistoryEntry>();
                }

                for (int i = 0; i < count; i++)
                {
                    BidHistory.Add(new HistoryEntry(reader));
                }

                break;
            }

            if (HasBegun)
            {
                Auctions.Add(this);
            }
        }
Esempio n. 5
0
        public override void AddGumpLayout()
        {
            base.AddGumpLayout();

            TempBid = 0;

            // Display Item
            if (Auction.AuctionItem != null)
            {
                Item i = Auction.AuctionItem;
                AddImage((Length / 2) + 3, 160, 2329);
                Rectangle2D b = ItemBounds.Table[i.ItemID];
                AddItem(((Length / 2) + (50 / 2)) + b.Width / 2 - b.X, (160 + 60 / 2) - b.Height / 2 - b.Y, i.ItemID, i.Hue);
                AddItemProperty(i.Serial);
            }

            // Description
            AddHtmlLocalized(0, 230, (Length / 2) - 3, 16, 1114514, "#1156400", Yellow, false, false); // Description:
            AddHtml((Length / 2) + 5, 230, 145, 130, Auction.Description, true, false);

            // Time
            AddHtmlLocalized(0, 370, (Length / 2) - 3, 16, 1114514, "#1156404", Yellow, false, false); // Time Remaining:

            TimeSpan left = Auction.EndTime - DateTime.Now;
            int      cliloc;
            double   v;

            if (left.TotalDays >= 7)
            {
                cliloc = 1153092; // Lifespan: ~1_val~ weeks
                v      = left.TotalDays / 7;
            }
            else if (left.TotalDays >= 1)
            {
                cliloc = 1153091; // Lifespan: ~1_val~ days
                v      = left.TotalDays;
            }
            else if (left.TotalHours >= 1)
            {
                cliloc = 1153090; // Lifespan: ~1_val~ hours
                v      = left.TotalHours;
            }
            else
            {
                cliloc = 1153089; // Lifespan: ~1_val~ minutes
                v      = left.TotalMinutes;
            }

            BidEntry entry = Auction.GetBidEntry(User, false);

            int platBid = entry == null ? 0 : entry.TotalPlatBid;
            int goldBid = entry == null ? 0 : entry.TotalGoldBid;

            AddHtmlLocalized((Length / 2) + 3, 370, 200, 16, cliloc, ((int)v).ToString(), C32216(Gray), false, false);

            AddHtmlLocalized(0, 395, (Length / 2) - 3, 16, 1114514, "#1156436", Yellow, false, false); // Current Platinum Bid:
            AddLabel((Length / 2) + 3, 395, 1149, Auction.CurrentPlatBid.ToString("N0", CultureInfo.GetCultureInfo("en-US")));

            AddHtmlLocalized(0, 420, (Length / 2) - 3, 16, 1114514, "#1156435", Yellow, false, false); // Current Gold Bid:
            AddLabel((Length / 2) + 3, 420, 1149, Auction.CurrentGoldBid.ToString("N0", CultureInfo.GetCultureInfo("en-US")));

            AddHtmlLocalized(0, 445, (Length / 2) - 3, 16, 1114514, "#1156406", Yellow, false, false); // Your Current Platinum Bid:
            AddBackground((Length / 2) + 3, 445, 200, 20, 9350);
            AddTextEntry((Length / 2) + 5, 445, 198, 20, 0, 1, platBid.ToString("N0", CultureInfo.GetCultureInfo("en-US")));

            AddHtmlLocalized(0, 470, (Length / 2) - 3, 16, 1114514, "#1156405", Yellow, false, false); // Your Current Gold Bid:
            AddBackground((Length / 2) + 3, 470, 200, 20, 9350);
            AddTextEntry((Length / 2) + 5, 470, 198, 20, 0, 2, goldBid.ToString("N0", CultureInfo.GetCultureInfo("en-US")));

            AddHtmlLocalized((Length / 2) + 3, 495, 200, 16, 1156407, Yellow, false, false); // Place Bid
            AddButton((Length / 2) - 33, 495, 4005, 4007, 1, GumpButtonType.Reply, 0);

            AddHtmlLocalized(0, 520, (Length / 2) - 3, 16, 1114514, "#1156413", Yellow, false, false); // Buy Now Plat Price:
            AddLabel((Length / 2) + 3, 520, 1149, Auction.BuyoutPlat.ToString("N0", CultureInfo.GetCultureInfo("en-US")));

            AddHtmlLocalized(0, 545, (Length / 2) - 3, 16, 1114514, "#1156412", Yellow, false, false); // Buy Now Gold Price:
            AddLabel((Length / 2) + 3, 545, 1149, Auction.BuyoutGold.ToString("N0", CultureInfo.GetCultureInfo("en-US")));

            if (Auction.Buyout > 0)
            {
                AddHtmlLocalized((Length / 2) + 3, 570, 200, 16, 1156409, Yellow, false, false); // Buy Now
                AddButton((Length / 2) - 33, 570, 4005, 4007, 2, GumpButtonType.Reply, 0);
            }
        }
Esempio n. 6
0
        public bool TryPlaceBid(Mobile m, long bidTotal)
        {
            if (!OnGoing)
            {
                return(false);
            }

            BidEntry entry = GetBidEntry(m);
            Account  acct  = m.Account as Account;

            if (bidTotal < entry.CurrentBid || entry == HighestBid)
            {
                m.SendMessage("You are already own the leading bid!");
                return(false);
            }

            long actualBid = bidTotal - entry.CurrentBid;

            if (acct == null || Banker.GetBalance(m) < bidTotal)
            {
                m.SendLocalizedMessage(1155867);                 // The amount entered is invalid. Verify that there are sufficient funds to complete this transaction.
                return(false);
            }

            long highestBid = HighestBid != null ? HighestBid.CurrentBid : CurrentBid;

            if (bidTotal <= highestBid)
            {
                //if(BidHistory != null && BidHistory.Count > 0)
                //	BidHistory[BidHistory.Count - 1].ShowRealBid = true;

                m.SendLocalizedMessage(1156445);                 // You have been out bid.
            }
            else
            {
                acct.WithdrawGold(bidTotal);
                entry.CurrentBid = bidTotal;

                CurrentBid = highestBid + 1;

                if (HighestBid != null)
                {
                    string name = "Unknown Item";

                    if (AuctionItem.Name != null)
                    {
                        name = AuctionItem.Name;
                    }
                    else
                    {
                        name = String.Format("#{0}", AuctionItem.LabelNumber.ToString());
                    }

                    var message = new NewMaginciaMessage(null, new TextDefinition(1156427), String.Format("{0}\t{1}\t{2}",
                                                                                                          name,
                                                                                                          CurrentPlatBid.ToString("N0", CultureInfo.GetCultureInfo("en-US")),
                                                                                                          CurrentGoldBid.ToString("N0", CultureInfo.GetCultureInfo("en-US"))));

                    /*  You have been out bid in an auction for ~1_ITEMNAME~. The current winning bid amount is
                     * ~2_BIDAMT~plat and ~3_BIDAMT~gp.*/
                    MaginciaLottoSystem.SendMessageTo(HighestBid.Mobile, message);

                    Account a = HighestBid.Mobile.Account as Account;

                    if (a != null)
                    {
                        a.DepositGold(HighestBid.CurrentBid);
                    }

                    HighestBid.CurrentBid = 0;
                }

                m.SendLocalizedMessage(1156433);                 // Your bid has been placed.
                HighestBid = entry;
                AddToHistory(m, entry.CurrentBid);
                return(true);
            }

            return(false);
        }
Esempio n. 7
0
        public bool TryPlaceBid(Mobile m, long bidTotal)
        {
            if (!OnGoing || InClaimPeriod)
            {
                m.SendLocalizedMessage(1156432); // There is no active auction to complete this action.
                return(false);
            }

            BidEntry entry    = GetBidEntry(m);
            Account  acct     = m.Account as Account;
            bool     firstBid = HighestBid == null;

            long highestBid = firstBid ? CurrentBid : HighestBid.CurrentBid;

            if (acct == null || Banker.GetBalance(m) < bidTotal)
            {
                m.SendLocalizedMessage(1155867); // The amount entered is invalid. Verify that there are sufficient funds to complete this transaction.
                return(false);
            }

            if ((firstBid && bidTotal < highestBid) || (!firstBid && bidTotal <= highestBid))
            {
                m.SendLocalizedMessage(1156445); // You have been out bid.

                if (bidTotal > CurrentBid)
                {
                    CurrentBid = bidTotal;

                    AddToHistory(m, bidTotal);
                }
            }
            else
            {
                acct.WithdrawGold(bidTotal);
                entry.CurrentBid = bidTotal;

                if (!firstBid)
                {
                    if (HighestBid.Mobile != m)
                    {
                        string name = AuctionItemName();

                        if (string.IsNullOrEmpty(name))
                        {
                            name = "the item you bid on";
                        }

                        NewMaginciaMessage message = new NewMaginciaMessage(null, 1156427, String.Format("{0}\t{1}\t{2}",
                                                                                                         name,
                                                                                                         CurrentPlatBid.ToString("N0", CultureInfo.GetCultureInfo("en-US")),
                                                                                                         CurrentGoldBid.ToString("N0", CultureInfo.GetCultureInfo("en-US"))));

                        /*  You have been out bid in an auction for ~1_ITEMNAME~. The current winning bid amount is
                         * ~2_BIDAMT~plat and ~3_BIDAMT~gp.*/
                        MaginciaLottoSystem.SendMessageTo(HighestBid.Mobile, message);
                    }

                    Account a = HighestBid.Mobile.Account as Account;

                    if (a != null)
                    {
                        a.DepositGold(HighestBid.CurrentBid);
                    }
                }
                else
                {
                    AddToHistory(m, bidTotal);
                }

                m.SendLocalizedMessage(1156433); // Your bid has been placed.

                AuctionMap map = new AuctionMap(Safe);

                if (m.Backpack == null || !m.Backpack.TryDropItem(m, map, false))
                {
                    map.Delete();
                }
                else
                {
                    m.SendLocalizedMessage(1156478); // The auction safe map has been placed in your backpack.
                }

                HighestBid = entry;
                return(true);
            }

            return(false);
        }
Esempio n. 8
0
        public bool TryPlaceBid(Mobile m, long bidTotal)
        {
            if (!OnGoing || InClaimPeriod)
            {
                m.SendLocalizedMessage(1156432); // There is no active auction to complete this action.
                return(false);
            }

            BidEntry entry    = GetBidEntry(m);
            Account  acct     = m.Account as Account;
            bool     firstBid = HighestBid == null;

            long highestBid = firstBid ? CurrentBid : HighestBid.CurrentBid;

            if (acct == null || Banker.GetBalance(m) < bidTotal)
            {
                m.SendLocalizedMessage(1155867); // The amount entered is invalid. Verify that there are sufficient funds to complete this transaction.
                return(false);
            }

            if ((firstBid && bidTotal < highestBid) || (!firstBid && bidTotal <= highestBid))
            {
                m.SendLocalizedMessage(1156445); // You have been out bid.

                if (bidTotal > CurrentBid)
                {
                    CurrentBid = bidTotal;
                    AddToHistory(m, bidTotal);
                }
            }
            else
            {
                acct.WithdrawGold(bidTotal);
                entry.CurrentBid = bidTotal;
                var mobile = HighestBid != null ? HighestBid.Mobile : null;

                if (!firstBid)
                {
                    if (mobile != m)
                    {
                        DoOutBidMessage(mobile);
                    }

                    HighestBid.Refund(this, highestBid);
                }
                else
                {
                    AddToHistory(m, bidTotal);
                }

                m.SendLocalizedMessage(1156433); // Your bid has been placed.

                AuctionMap map = new AuctionMap(Safe);

                if (m.Backpack == null || !m.Backpack.TryDropItem(m, map, false))
                {
                    map.Delete();
                }
                else
                {
                    m.SendLocalizedMessage(1156478); // The auction safe map has been placed in your backpack.
                }

                VaultLogging.NewHighBid(this, m, mobile, bidTotal);

                HighestBid = entry;
                return(true);
            }

            return(false);
        }