예제 #1
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);
        }
예제 #2
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);
        }
예제 #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;
            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);
        }