public void BeforeAll()
 {
     var residentialFactory = new ResidentialFactory();
     _tradeableProperty = residentialFactory.create("Test Residential", 200, 50, 50,"Red");
     _player = new Player("Josh", 500);
     _banker = Banker.Access();
 }
예제 #2
0
 public RealEstate(Banker banker, Int32 price, Int32 baseRent, RentStrategy rentStrategy)
 {
     this.banker = banker;
     this.price = price;
     this.baseRent = baseRent;
     this.rentStrategy = rentStrategy;
 }
예제 #3
0
        public static Game CreateGame(IEnumerable<IPlayer> players)
        {
            var dice = new MonopolyDice();

            var banker = new Banker(players);
            var realEstateHandler = new OwnableHandler(BoardFactory.CreateRealEstate(dice), banker);
            var spaces = BoardFactory.CreateNonRealEstateSpaces(banker);
            var spaceHandler = new UnownableHandler(spaces);

            var boardHandler = new BoardHandler(players, realEstateHandler, spaceHandler, banker);
            var jailHandler = new JailHandler(dice, boardHandler, banker);
            var turnHandler = new TurnHandler(dice, boardHandler, jailHandler, realEstateHandler, banker);

            var deckFactory = new DeckFactory(players, jailHandler, boardHandler, realEstateHandler, banker);
            var communityChest = deckFactory.BuildCommunityChestDeck();
            var chance = deckFactory.BuildChanceDeck(dice);

            foreach (var space in spaces.Values.OfType<DrawCard>())
            {
                if (space.ToString() == "Community Chest")
                    space.AddDeck(communityChest);
                else
                    space.AddDeck(chance);
            }

            return new Game(players, turnHandler, banker);
        }
예제 #4
0
        private static void ConsoleBanker()
        {
            var banker = new Banker(new ConsoleLogger());

            banker.Deposit("12345", 500);
            banker.Withdraw("12345", 1500);
        }
예제 #5
0
        private static void MessageBoxBanker()
        {
            var banker = new Banker(new MessageBoxLogger());

            banker.Deposit("12345", 500);
            banker.Withdraw("12345", 1500);
        }
예제 #6
0
 public IncomeTax(Int32 index, Int32 taxPercentage, Int32 maximumTaxPayment, Banker banker)
     : base(index)
 {
     this.taxPercentage = taxPercentage;
     this.maximumTaxPayment = maximumTaxPayment;
     this.banker = banker;
 }
예제 #7
0
 public void SetUp()
 {
     player = "Horse";
     players = new List<String> { player };
     banker = new Banker(players, 1500);
     incomeTax = new IncomeTax(banker, 200, 10);
 }
        public void Setup()
        {
            player = new Player("name");
            var players = new[] { player };
            var realEstateHandler = FakeHandlerFactory.CreateEmptyRealEstateHandler(players);
            var banker = new Banker(players);
            boardHandler = FakeHandlerFactory.CreateBoardHandlerForFakeBoard(players, realEstateHandler, banker);

            moveBackCard = new MoveBackThreeCard(boardHandler);
        }
예제 #9
0
 public void SetUp()
 {
     dice = new LoadedDice();
     player1 = "Horse";
     players = new List<String> { player1 };
     banker = new Banker(players, 1500);
     var boardFactory = new BoardFactory();
     var guard = new PrisonGuard(banker, dice);
     board = boardFactory.Create(banker, players, dice, guard);
 }
예제 #10
0
        public void ChairmanOfTheBoardMakesThePlayerPayEachOtherPlayer50Dollars()
        {
            var player3 = "Dog";
            players.Add(player3);
            banker = new Banker(players, 1500);
            var chairmanOfTheBoard = new PayEachPlayer(banker, 50);
            var previousBalance = banker.GetBalance(player1);

            chairmanOfTheBoard.Play(player1);

            Assert.That(banker.GetBalance(player1), Is.EqualTo(previousBalance - 100));
        }
예제 #11
0
        public void LuxuryTaxTakes75DollarsFromAPlayer()
        {
            var player = "Horse";
            var players = new List<String> { player };
            var banker = new Banker(players, 1500);
            var luxuryTax = new LuxuryTax(banker, 75);

            luxuryTax.LandOnSpace(player);
            var afterTaxMoney = banker.GetBalance(player);

            Assert.That(afterTaxMoney, Is.EqualTo(1425));
        }
        public void GrandOperaLetsThePlayerCollect50DollarsFromEachPlayer()
        {
            var player2 = "Car";
            var player3 = "Dog";
            players.AddRange(new[] { player2, player3 });
            banker = new Banker(players, 1500);
            var grandOpera = new CollectFromEachPlayer(banker, 50);
            var previousBalance = banker.GetBalance(player1);

            grandOpera.Play(player1);

            Assert.That(banker.GetBalance(player1), Is.EqualTo(previousBalance + 100));
        }
        public void Setup()
        {
            player = new Player("name");

            var dice = new ControlledDice();
            var players = new[] { player };
            var banker = new Banker(players);
            var realEstateHandler = FakeHandlerFactory.CreateEmptyRealEstateHandler(players);
            boardHandler = FakeHandlerFactory.CreateBoardHandlerForFakeBoard(players, realEstateHandler, banker);
            jailHandler = new JailHandler(dice, boardHandler, banker);

            goToJailCard = new GoToJailCard(jailHandler);
        }
예제 #14
0
        public void SetUp()
        {
            player1 = "Horse";
            player2 = "Car";
            player3 = "Dog";
            players = new List<String> { player1, player2, player3 };
            banker = new Banker(players, 1500);
            var utilities = new List<RealEstate>();
            dice = new LoadedDice();
            var utilityRentStrategy = new UtilityRentStrategy(utilities, dice);
            electric = new RealEstate(banker, 150, 0, utilityRentStrategy);
            water = new RealEstate(banker, 150, 0, utilityRentStrategy);

            utilities.AddRange(new[] { electric, water });
        }
예제 #15
0
        public void IfAPlayerLandsOnGoToJailTheyGoToJail()
        {
            var jail = 10;
            var player = "Horse";
            var players = new List<String> { player };
            var banker = new Banker(players, 1500);
            var boardFactory = new BoardFactory();
            var dice = new LoadedDice();
            var guard = new PrisonGuard(banker, dice);
            var board = boardFactory.Create(banker, players, dice, guard);
            var goToJail = new GoToJail(board, jail, guard);

            goToJail.LandOnSpace(player);

            Assert.That(board.GetPosition(player), Is.EqualTo(10));
        }
예제 #16
0
        public void GameShouldNotAllowMoreThan8Players()
        {
            var player3 = "Dog";
            var player4 = "Thimble";
            var player5 = "Top Hat";
            var player6 = "Cat";
            var player7 = "Shoe";
            var player8 = "Ship";
            var player9 = "Wheelbarrow";
            var players = new List<String>() { player1, player2, player3, player4, player5, player6, player7, player8, player9 };
            banker = new Banker(players, 1500);
            var guard = new PrisonGuard(banker, dice);
            board = new Board(players);

            Assert.That(() => new Game(players, dice, board, turns, guard), Throws.Exception.TypeOf<Game.TooManyPlayersException>());
        }
예제 #17
0
        public void MoveToNearestGivesTheOwner10TimesDiceAmount()
        {
            banker = new Banker(players, 1500);
            board = boardFactory.Create(banker, players, dice, guard);

            var utilities = new List<RealEstate>();
            var utilityRentStrategy = new UtilityRentStrategy(utilities, dice);
            var electric = new RealEstate(banker, 150, 0, utilityRentStrategy);
            var water = new RealEstate(banker, 150, 0, utilityRentStrategy);
            utilities.AddRange(new[] { electric, water });

            var spaces = new Dictionary<Int32, IBoardSpace>
            {
                { 12, electric },
                { 28, water }
            };

            board.SetSpaces(spaces);
            board.MoveTo(player2, 12);
            board.MoveTo(player1, 7);
            var previousBalance = banker.GetBalance(player2);

            dice.SetNumberToRoll(new[] { 4, 1 });
            dice.Roll();
            var MoveToNearest = new AdvanceToNearest(board, new[] { 12, 28 }, utilityRentStrategy);

            MoveToNearest.Play(player1);

            Assert.That(banker.GetBalance(player2), Is.EqualTo(previousBalance + 50));
        }
예제 #18
0
        private void RentDue()
        {
            if (!Owned || c_House.Owner == null)
            {
                return;
            }

            if (!c_RecurRent)
            {
                c_House.Owner.SendMessage(
                    "Your town house rental contract has expired, and the bank has once again taken possession.");
                PackUpHouse();
                return;
            }

            if (!c_Free && c_House.Owner.AccessLevel == AccessLevel.Player && !Banker.Withdraw(c_House.Owner, c_Price))
            {
                c_House.Owner.SendMessage("Since you can not afford the rent, the bank has reclaimed your town house.");
                PackUpHouse();
                return;
            }

            if (!c_Free)
            {
                c_House.Owner.SendMessage("The bank has withdrawn {0} gold rent for your town house.", c_Price);
            }

            OnRentPaid();

            if (c_RentToOwn)
            {
                c_RTOPayments++;

                bool complete = false;

                if (c_RentByTime == TimeSpan.FromDays(1) && c_RTOPayments >= 60)
                {
                    complete      = true;
                    c_House.Price = c_Price * 60;
                }

                if (c_RentByTime == TimeSpan.FromDays(7) && c_RTOPayments >= 9)
                {
                    complete      = true;
                    c_House.Price = c_Price * 9;
                }

                if (c_RentByTime == TimeSpan.FromDays(30) && c_RTOPayments >= 2)
                {
                    complete      = true;
                    c_House.Price = c_Price * 2;
                }

                if (complete)
                {
                    c_House.Owner.SendMessage("You now own your rental home.");
                    c_RentByTime = TimeSpan.FromDays(0);
                    return;
                }
            }

            BeginRentTimer(c_RentByTime);
        }
예제 #19
0
        public void Purchase(Mobile m, bool sellitems = false)
        {
            try
            {
                if (Owned)
                {
                    m.SendMessage("Someone already owns this house!");
                    return;
                }

                if (!PriceReady)
                {
                    m.SendMessage("The setup for this house is not yet complete.");
                    return;
                }

                int price = c_Price + (sellitems ? c_ItemsPrice : 0);

                if (c_Free)
                {
                    price = 0;
                }

                if (m.AccessLevel == AccessLevel.Player && !Banker.Withdraw(m, price))
                {
                    m.SendMessage("You cannot afford this house.");
                    return;
                }

                if (m.AccessLevel == AccessLevel.Player)
                {
                    m.SendLocalizedMessage(1060398, price.ToString());
                    // ~1_AMOUNT~ gold has been withdrawn from your bank box.
                }

                Visible = false;

                int minX = c_Blocks[0].Start.X;
                int minY = c_Blocks[0].Start.Y;
                int maxX = c_Blocks[0].End.X;
                int maxY = c_Blocks[0].End.Y;

                foreach (Rectangle2D rect in c_Blocks)
                {
                    if (rect.Start.X < minX)
                    {
                        minX = rect.Start.X;
                    }
                    if (rect.Start.Y < minY)
                    {
                        minY = rect.Start.Y;
                    }
                    if (rect.End.X > maxX)
                    {
                        maxX = rect.End.X;
                    }
                    if (rect.End.Y > maxY)
                    {
                        maxY = rect.End.Y;
                    }
                }

                c_House = new TownHouse(m, this, c_Locks, c_Secures);

                c_House.Components.Resize(maxX - minX, maxY - minY);
                c_House.Components.Add(0x520, c_House.Components.Width - 1, c_House.Components.Height - 1, -5);

                c_House.Location          = new Point3D(minX, minY, Map.GetAverageZ(minX, minY));
                c_House.Map               = Map;
                c_House.Region.GoLocation = c_BanLoc;
                c_House.Sign.Location     = c_SignLoc;
                c_House.Hanger            = new Item(0xB98)
                {
                    Location = c_SignLoc, Map = Map, Movable = false
                };

                if (c_ForcePublic)
                {
                    c_House.Public = true;
                }

                c_House.Price = (RentByTime == TimeSpan.FromDays(0) ? c_Price : 1);

                RUOVersion.UpdateRegion(this);

                if (c_House.Price == 0)
                {
                    c_House.Price = 1;
                }

                if (c_RentByTime != TimeSpan.Zero)
                {
                    BeginRentTimer(c_RentByTime);
                }

                c_RTOPayments = 1;

                HideOtherSigns();

                c_DecoreItemInfos = new List <DecoreItemInfo>();

                ConvertItems(sellitems);
            }
            catch (Exception e)
            {
                Errors.Report(
                    String.Format(
                        "An error occurred during home purchasing.  More information available on the console."));
                Console.WriteLine(e.Message);
                Console.WriteLine(e.Source);
                Console.WriteLine(e.StackTrace);
            }
        }
예제 #20
0
 public PayEachPlayer(Banker banker, Int32 amount)
 {
     this.banker = banker;
     this.amount = amount;
 }
예제 #21
0
        public void BeginStable(Mobile from)
        {
            if (this.Deleted || !from.CheckAlive())
            {
                return;
            }

            if ((from.Backpack == null || from.Backpack.GetAmount(typeof(Gold)) < 30) && Banker.GetBalance(from) < 30)
            {
                from.SendLocalizedMessage(502677); // But thou hast not the funds in thy bank account!
            }
            else
            {
                from.SendLocalizedMessage(1042558); /* I charge 30 gold per pet for a real week's stable time.
                                                     * I will withdraw it from thy bank account.
                                                     * Which animal wouldst thou like to stable here?
                                                     */

                from.Target = new StableTarget(this);
            }
        }
예제 #22
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;

            from.CloseGump(typeof(ResurrectGump));

            if (info.ButtonID == 1 || info.ButtonID == 2)
            {
                if (from.Map == null || !from.Map.CanFit(from.Location, 16, false, false))
                {
                    from.SendLocalizedMessage(502391);                       // Thou can not be resurrected there!
                    return;
                }

                if (m_Price > 0)
                {
                    if (info.IsSwitched(1))
                    {
                        if (Banker.Withdraw(from, m_Price))
                        {
                            from.SendLocalizedMessage(1060398, m_Price.ToString());                               // ~1_AMOUNT~ gold has been withdrawn from your bank box.
                            from.SendLocalizedMessage(1060022, Banker.GetBalance(from).ToString());               // You have ~1_AMOUNT~ gold in cash remaining in your bank box.
                        }
                        else
                        {
                            from.SendLocalizedMessage(1060020);                               // Unfortunately, you do not have enough cash in your bank to cover the cost of the healing.
                            return;
                        }
                    }
                    else
                    {
                        from.SendLocalizedMessage(1060019);                           // You decide against paying the healer, and thus remain dead.
                        return;
                    }
                }

                from.PlaySound(0x214);
                from.FixedEffect(0x376A, 10, 16);

                from.Resurrect();

                if (m_Healer != null && from != m_Healer)
                {
                    VirtueLevel level = VirtueHelper.GetLevel(m_Healer, VirtueName.Compassion);

                    switch (level)
                    {
                    case VirtueLevel.Seeker: from.Hits = AOS.Scale(from.HitsMax, 20); break;

                    case VirtueLevel.Follower: from.Hits = AOS.Scale(from.HitsMax, 40); break;

                    case VirtueLevel.Knight: from.Hits = AOS.Scale(from.HitsMax, 80); break;
                    }
                }

                if (m_FromSacrifice && from is PlayerMobile)
                {
                    ((PlayerMobile)from).AvailableResurrects -= 1;

                    Container pack   = from.Backpack;
                    Container corpse = from.Corpse;

                    if (pack != null && corpse != null)
                    {
                        List <Item> items = new List <Item>(corpse.Items);

                        for (int i = 0; i < items.Count; ++i)
                        {
                            Item item = items[i];

                            if (item.Layer != Layer.Hair && item.Layer != Layer.FacialHair && item.Movable)
                            {
                                pack.DropItem(item);
                            }
                        }
                    }
                }

                if (from.Fame > 0)
                {
                    int amount = from.Fame / 10;

                    Misc.Titles.AwardFame(from, -amount, true);
                }

                if (Core.AOS && from.ShortTermMurders >= 5)
                {
                    double loss = (100.0 - (4.0 + (from.ShortTermMurders / 5.0))) / 100.0;                     // 5 to 15% loss

                    if (loss < 0.85)
                    {
                        loss = 0.85;
                    }
                    else if (loss > 0.95)
                    {
                        loss = 0.95;
                    }

                    if (from.RawStr * loss > 10)
                    {
                        from.RawStr = (int)(from.RawStr * loss);
                    }
                    if (from.RawInt * loss > 10)
                    {
                        from.RawInt = (int)(from.RawInt * loss);
                    }
                    if (from.RawDex * loss > 10)
                    {
                        from.RawDex = (int)(from.RawDex * loss);
                    }

                    for (int s = 0; s < from.Skills.Length; s++)
                    {
                        if (from.Skills[s].Base * loss > 35)
                        {
                            from.Skills[s].Base *= loss;
                        }
                    }
                }

                if (from.Alive && m_HitsScalar > 0)
                {
                    from.Hits = (int)(from.HitsMax * m_HitsScalar);
                }
            }
        }
예제 #23
0
 public Pay(Banker banker, Int32 amount)
 {
     this.banker = banker;
     this.amount = amount;
 }
예제 #24
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (info.ButtonID != 2)
            {
                m_From.SendLocalizedMessage(503207); // Cancelled purchase.
                return;
            }

            if (m_Book.RootParent is not PlayerVendor pv)
            {
                m_From.SendLocalizedMessage(1062382); // The deed selected is not available.
                return;
            }

            if (!m_Book.Entries.Contains(m_Entry))
            {
                pv.SayTo(m_From, 1062382); // The deed selected is not available.
                return;
            }

            var price = 0;

            if (pv.GetVendorItem(m_Book)?.IsForSale == false)
            {
                price = m_Entry.Price;
            }

            if (price != m_Price)
            {
                pv.SayTo(
                    m_From,
                    "The price has been been changed. If you like, you may offer to purchase the item again."
                    );
                return;
            }

            if (price == 0)
            {
                pv.SayTo(m_From, 1062382); // The deed selected is not available.
                return;
            }

            var item = m_Entry.Reconstruct();

            pv.Say(m_From.Name);

            var pack = m_From.Backpack;

            if (pack?.CheckHold(
                    m_From,
                    item,
                    true,
                    true,
                    0,
                    item.PileWeight + item.TotalWeight
                    ) != true)
            {
                pv.SayTo(m_From, 503204); // You do not have room in your backpack for this
                m_From.SendGump(new BOBGump(m_From, m_Book, m_Page));
                item.Delete();
            }
            else
            {
                if (pack.ConsumeTotal(typeof(Gold), price) || Banker.Withdraw(m_From, price))
                {
                    m_Book.Entries.Remove(m_Entry);
                    m_Book.InvalidateProperties();
                    pv.HoldGold += price;
                    m_From.AddToBackpack(item);

                    // The bulk order deed has been placed in your backpack.
                    m_From.SendLocalizedMessage(1045152);

                    if (m_Book.Entries.Count / 5 < m_Book.ItemCount)
                    {
                        m_Book.ItemCount--;
                        m_Book.InvalidateItems();
                    }

                    if (m_Book.Entries.Count > 0)
                    {
                        m_From.SendGump(new BOBGump(m_From, m_Book, m_Page));
                    }
                    else
                    {
                        m_From.SendLocalizedMessage(1062381); // The book is empty.
                    }
                }
                else
                {
                    pv.SayTo(m_From, 503205); // You cannot afford this item.
                    item.Delete();
                }
            }
        }
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;

            from.CloseGump(typeof(ResurrectGump));

            if (info.ButtonID == 1 || info.ButtonID == 2)
            {
                if (from.Map == null || !from.Map.CanFit(from.Location, 16, false, false))
                {
                    from.SendLocalizedMessage(502391);                       // Thou can not be resurrected there!
                    return;
                }

                if (m_Price > 0)
                {
                    if (info.IsSwitched(1))
                    {
                        if (Banker.Withdraw(from, m_Price))
                        {
                            from.SendLocalizedMessage(1060398, m_Price.ToString());                               // ~1_AMOUNT~ gold has been withdrawn from your bank box.
                            from.SendLocalizedMessage(1060022, Banker.GetBalance(from).ToString());               // You have ~1_AMOUNT~ gold in cash remaining in your bank box.
                        }
                        else
                        {
                            from.SendLocalizedMessage(1060020);                               // Unfortunately, you do not have enough cash in your bank to cover the cost of the healing.
                            return;
                        }
                    }
                    else
                    {
                        from.SendLocalizedMessage(1060019);                           // You decide against paying the healer, and thus remain dead.
                        return;
                    }
                }

                from.PlaySound(0x214);

                from.Resurrect();

                Effects.SendLocationParticles(EffectItem.Create(from.Location, from.Map, EffectItem.DefaultDuration), 0, 0, 0, 0, 0, 5060, 0);

                Effects.SendMovingParticles(new Entity(0, new Point3D(from.X - 6, from.Y - 6, from.Z + 15), from.Map), from, 0x36D4, 7, 0, false, true, 0x497, 0, 9502, 1, 0, (EffectLayer)255, 0x100);
                Effects.SendMovingParticles(new Entity(0, new Point3D(from.X - 4, from.Y - 6, from.Z + 15), from.Map), from, 0x36D4, 7, 0, false, true, 0x497, 0, 9502, 1, 0, (EffectLayer)255, 0x100);
                Effects.SendMovingParticles(new Entity(0, new Point3D(from.X - 6, from.Y - 4, from.Z + 15), from.Map), from, 0x36D4, 7, 0, false, true, 0x497, 0, 9502, 1, 0, (EffectLayer)255, 0x100);

                Effects.SendTargetParticles(from, 0x375A, 35, 90, 0x00, 0x00, 9502, (EffectLayer)255, 0x100);

                if (m_Healer != null && from != m_Healer)
                {
                    VirtueLevel level = VirtueHelper.GetLevel(m_Healer, VirtueName.Compassion);

                    switch (level)
                    {
                    case VirtueLevel.Seeker:
                        from.Hits = AOS.Scale(from.HitsMax, 20);
                        break;

                    case VirtueLevel.Follower:
                        from.Hits = AOS.Scale(from.HitsMax, 40);
                        break;

                    case VirtueLevel.Knight:
                        from.Hits = AOS.Scale(from.HitsMax, 80);
                        break;
                    }
                }

                Mobile m = from;

                Misc.Titles.AwardFame(from, -100, true);                   // TODO: Proper fame loss

                if (!Core.AOS && from.ShortTermMurders >= 5)
                {
                    double loss = (100.0 - (4.0 + (from.ShortTermMurders / 5.0))) / 100.0;                 //5 to 15% loss
                    if (loss < 0.85)
                    {
                        loss = 0.85;
                    }
                    else if (loss > 0.95)
                    {
                        loss = 0.95;
                    }

                    if (from.RawStr * loss > 10)
                    {
                        from.RawStr = (int)(from.RawStr * loss);
                    }
                    if (from.RawInt * loss > 10)
                    {
                        from.RawInt = (int)(from.RawInt * loss);
                    }
                    if (from.RawDex * loss > 10)
                    {
                        from.RawDex = (int)(from.RawDex * loss);
                    }

                    for (int s = 0; s < from.Skills.Length; s++)
                    {
                        if (from.Skills[s].Base * loss > 35)
                        {
                            from.Skills[s].Base *= loss;
                        }
                    }
                }
            }
        }
예제 #26
0
        public CommodityBrokerGump(CommodityBroker broker, Mobile from)
            : base(520, 520)
        {
            m_Broker = broker;

            AddHtmlLocalized(10, 10, 500, 18, 1114513, "#1150636", RedColor16, false, false);  // Commodity Broker

            if (!string.IsNullOrEmpty(m_Broker.Plot.ShopName))
            {
                AddHtml(10, 37, 500, 18, Color(FormatStallName(m_Broker.Plot.ShopName), BlueColor), false, false);
            }
            else
            {
                AddHtmlLocalized(10, 37, 500, 18, 1114513, "#1150314", BlueColor16, false, false); // This Shop Has No Name
            }

            AddHtmlLocalized(10, 55, 260, 18, 1114514, "#1150313", BlueColor16, false, false); // Proprietor:
            AddHtml(280, 55, 260, 18, Color(string.Format("{0}", broker.Name), BlueColor), false, false);

            AddHtmlLocalized(10, 100, 500, 18, 1114513, "#1150328", GreenColor16, false, false); // OWNER MENU

            AddButton(150, 150, 4005, 4007, 1, GumpButtonType.Reply, 0);
            AddHtmlLocalized(190, 150, 200, 18, 1150392, OrangeColor16, false, false); // INFORMATION

            AddHtmlLocalized(38, 180, 200, 18, 1150199, RedColor16, false, false);     // Broker Account Balance
            AddHtml(190, 180, 300, 18, FormatAmt(broker.BankBalance), false, false);

            int balance = Banker.GetBalance(from);

            AddHtmlLocalized(68, 200, 200, 18, 1150149, GreenColor16, false, false); // Your Bank Balance:
            AddHtml(190, 200, 200, 18, FormatAmt(balance), false, false);

            AddHtmlLocalized(32, 230, 200, 18, 1150329, OrangeColor16, false, false);  // Broker Sales Comission
            AddHtmlLocalized(190, 230, 100, 18, 1150330, OrangeColor16, false, false); // 5%

            AddHtmlLocalized(109, 250, 200, 18, 1150331, OrangeColor16, false, false); // Weekly Fee:
            AddHtml(190, 250, 100, 18, FormatAmt(broker.GetWeeklyFee()), false, false);

            AddHtmlLocalized(113, 280, 200, 18, 1150332, OrangeColor16, false, false); // Shop Name:
            AddBackground(190, 280, 285, 22, 9350);
            AddTextEntry(191, 280, 285, 20, LabelHueBlue, 0, m_Broker.Plot.ShopName == null ? "" : m_Broker.Plot.ShopName);
            AddButton(480, 280, 4014, 4016, 2, GumpButtonType.Reply, 0);

            AddHtmlLocalized(85, 305, 150, 18, 1150195, OrangeColor16, false, false); // Withdraw Funds
            AddBackground(190, 305, 285, 22, 9350);
            AddTextEntry(191, 305, 285, 20, LabelHueBlue, 1, "");
            AddButton(480, 305, 4014, 4016, 3, GumpButtonType.Reply, 0);

            AddHtmlLocalized(97, 330, 150, 18, 1150196, OrangeColor16, false, false); // Deposit Funds
            AddBackground(190, 330, 285, 22, 9350);
            AddTextEntry(191, 330, 285, 20, LabelHueBlue, 2, "");
            AddButton(480, 330, 4014, 4016, 4, GumpButtonType.Reply, 0);

            AddButton(150, 365, 4005, 4007, 5, GumpButtonType.Reply, 0);
            AddHtmlLocalized(190, 365, 200, 18, 1150192, OrangeColor16, false, false); // ADD TO INVENTORY

            AddButton(150, 390, 4005, 4007, 6, GumpButtonType.Reply, 0);
            AddHtmlLocalized(190, 390, 300, 18, 1150193, OrangeColor16, false, false); // VIEW INVENTORY / REMOVE ITEMS

            AddButton(150, 415, 4005, 4007, 7, GumpButtonType.Reply, 0);
            AddHtmlLocalized(190, 415, 300, 18, 1150194, OrangeColor16, false, false); // SET PRICES AND LIMITS
        }
예제 #27
0
        public static void export()
        {
            Console.Out.WriteLine("");
            Banker bank = new Banker(FS);

            int[] bankTotals    = bank.countCoins(FS.BankFolder);
            int[] frackedTotals = bank.countCoins(FS.FrackedFolder);
            Console.Out.WriteLine("  Your Bank Inventory:");
            //int grandTotal = (bankTotals[0] + frackedTotals[0]);
            showCoins();
            // state how many 1, 5, 25, 100 and 250
            int exp_1   = 0;
            int exp_5   = 0;
            int exp_25  = 0;
            int exp_100 = 0;
            int exp_250 = 0;

            //Warn if too many coins
            Console.WriteLine(bankTotals[1] + frackedTotals[1] + bankTotals[2] + frackedTotals[2] + bankTotals[3] + frackedTotals[3] + bankTotals[4] + frackedTotals[4] + bankTotals[5] + frackedTotals[5]);
            if (((bankTotals[1] + frackedTotals[1]) + (bankTotals[2] + frackedTotals[2]) + (bankTotals[3] + frackedTotals[3]) + (bankTotals[4] + frackedTotals[4]) + (bankTotals[5] + frackedTotals[5])) > 1000)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Out.WriteLine("Warning: You have more than 1000 Notes in your bank. Stack files should not have more than 1000 Notes in them.");
                Console.Out.WriteLine("Do not export stack files with more than 1000 notes. .");
                Console.ForegroundColor = ConsoleColor.White;
            }//end if they have more than 1000 coins

            Console.Out.WriteLine("  Do you want to export your CloudCoin to (1)jpgs , (2) stack (JSON) , (3) QR Code (4) 2D Bar code file (5) MP3?");
            int file_type = reader.readInt(1, 5);

            // 1 jpg 2 stack
            if (onesTotalCount > 0)
            {
                Console.Out.WriteLine("  How many 1s do you want to export?");
                exp_1 = reader.readInt(0, (onesTotalCount));
            }

            // if 1s not zero
            if (fivesTotalCount > 0)
            {
                Console.Out.WriteLine("  How many 5s do you want to export?");
                exp_5 = reader.readInt(0, (fivesTotalCount));
            }

            // if 1s not zero
            if ((qtrTotalCount > 0))
            {
                Console.Out.WriteLine("  How many 25s do you want to export?");
                exp_25 = reader.readInt(0, (qtrTotalCount));
            }

            // if 1s not zero
            if (hundredsTotalCount > 0)
            {
                Console.Out.WriteLine("  How many 100s do you want to export?");
                exp_100 = reader.readInt(0, (hundredsTotalCount));
            }

            // if 1s not zero
            if (twoFiftiesTotalCount > 0)
            {
                Console.Out.WriteLine("  How many 250s do you want to export?");
                exp_250 = reader.readInt(0, (twoFiftiesTotalCount));
            }

            // if 1s not zero
            // move to export
            Exporter exporter = new Exporter(FS);

            if (file_type == 1)
            {
                Console.Out.WriteLine("  Tag your jpegs with 'random' to give them a random number.");
            }
            Console.Out.WriteLine("  What tag will you add to the file name?");
            String tag = reader.readString();

            //Console.Out.WriteLine(("Exporting to:" + exportFolder));
            if (file_type == 1)
            {
                exporter.writeJPEGFiles(exp_1, exp_5, exp_25, exp_100, exp_250, tag);
                // stringToFile( json, "test.txt");
            }
            else if (file_type == 2)
            {
                exporter.writeJSONFile(exp_1, exp_5, exp_25, exp_100, exp_250, tag);
            }
            else if (file_type == 3)
            {
                exporter.writeQRCodeFiles(exp_1, exp_5, exp_25, exp_100, exp_250, tag);
                // stringToFile( json, "test.txt");
            }
            else if (file_type == 4)
            {
                exporter.writeBarCode417CodeFiles(exp_1, exp_5, exp_25, exp_100, exp_250, tag);
                // stringToFile( json, "test.txt");
            }
            else if (file_type == 5)
            {
                Console.WriteLine("MP3");
                exporter.writeMp3Files(exp_1, exp_5, exp_25, exp_100, exp_250, tag);
                Console.WriteLine("End mp3");
            }


            // end if type jpge or stack
            Console.Out.WriteLine("  Exporting CloudCoins Completed.");
        }// end export One
예제 #28
0
        private static void showCoins()
        {
            Console.Out.WriteLine("");
            // This is for consol apps.
            Banker bank = new Banker(FS);

            int[] bankTotals    = bank.countCoins(FS.BankFolder);
            int[] frackedTotals = bank.countCoins(FS.FrackedFolder);
            // int[] counterfeitTotals = bank.countCoins( counterfeitFolder );

            var bankCoins = FS.LoadFolderCoins(FS.BankFolder);


            onesCount = (from x in bankCoins
                         where x.denomination == 1
                         select x).Count();
            fivesCount = (from x in bankCoins
                          where x.denomination == 5
                          select x).Count();
            qtrCount = (from x in bankCoins
                        where x.denomination == 25
                        select x).Count();
            hundredsCount = (from x in bankCoins
                             where x.denomination == 100
                             select x).Count();
            twoFiftiesCount = (from x in bankCoins
                               where x.denomination == 250
                               select x).Count();

            var frackedCoins = FS.LoadFolderCoins(FS.FrackedFolder);

            bankCoins.AddRange(frackedCoins);

            onesFrackedCount = (from x in frackedCoins
                                where x.denomination == 1
                                select x).Count();
            fivesFrackedCount = (from x in frackedCoins
                                 where x.denomination == 5
                                 select x).Count();
            qtrFrackedCount = (from x in frackedCoins
                               where x.denomination == 25
                               select x).Count();
            hundredsFrackedCount = (from x in frackedCoins
                                    where x.denomination == 100
                                    select x).Count();
            twoFrackedFiftiesCount = (from x in frackedCoins
                                      where x.denomination == 250
                                      select x).Count();

            onesTotalCount       = onesCount + onesFrackedCount;
            fivesTotalCount      = fivesCount + fivesFrackedCount;
            qtrTotalCount        = qtrCount + qtrFrackedCount;
            hundredsTotalCount   = hundredsCount + hundredsFrackedCount;
            twoFiftiesTotalCount = twoFiftiesCount + twoFrackedFiftiesCount;


            int totalAmount = onesTotalCount + (fivesTotalCount * 5) + (qtrTotalCount * 25) + (hundredsTotalCount * 100) + (twoFiftiesTotalCount * 250);

            //Output  " 12.3"
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.BackgroundColor = ConsoleColor.Blue;
            Console.Out.WriteLine("                                                                    ");
            Console.Out.WriteLine("    Total Coins in Bank:    " + string.Format("{0,8:N0}", totalAmount) + "                                ");
            Console.Out.WriteLine("                                                                    ");
            Console.Out.WriteLine("                 1s         5s         25s       100s       250s    ");
            Console.Out.WriteLine("                                                                    ");
            Console.Out.WriteLine("   Perfect:   " + string.Format("{0,7}", onesCount) + "    " + string.Format("{0,7}", fivesCount) + "    " + string.Format("{0,7}", qtrCount) + "    " + string.Format("{0,7}", hundredsCount) + "    " + string.Format("{0,7}", twoFiftiesCount) + "   ");
            Console.Out.WriteLine("                                                                    ");
            Console.Out.WriteLine("   Fracked:   " + string.Format("{0,7}", onesFrackedCount) + "    " + string.Format("{0,7}", fivesFrackedCount) + "    " + string.Format("{0,7}", qtrFrackedCount) + "    " + string.Format("{0,7}", hundredsFrackedCount) + "    " + string.Format("{0,7}", twoFrackedFiftiesCount) + "   ");
            Console.Out.WriteLine("                                                                    ");
            Console.ForegroundColor = ConsoleColor.White;
            Console.BackgroundColor = ConsoleColor.Black;
        }
예제 #29
0
        public PokerJoinGump(Mobile from, PokerGame game)
            : base(50, 50)
        {
            m_Game = game;

            this.Closable   = true;
            this.Disposable = true;
            this.Draggable  = true;
            this.Resizable  = false;
            this.AddPage(0);
            this.AddBackground(0, 0, 385, 393, 9270);
            this.AddImageTiled(18, 15, 350, 320, 9274);
            //this.AddAlphaRegion( 23, 19, 340, 310 );
            this.AddLabel(125, 10, 28, @"The Shard's Texas Hold-em");
            this.AddLabel(133, 25, 28, @" Join Poker Table");
            this.AddImageTiled(42, 47, 301, 3, 96);
            this.AddLabel(65, 62, 68, @"You are about to join a game of Poker.");
            this.AddImage(33, 38, 95, 68);
            this.AddImage(342, 38, 97, 68);
            this.AddLabel(52, 80, 68, @"All bets involve real gold and no refunds will be");
            this.AddLabel(54, 98, 68, @"given. If you feel uncomfortable losing gold or");
            this.AddLabel(40, 116, 68, @"are unfamiliar with the rules of Texas Hold'em, you");
            this.AddLabel(100, 134, 68, @"are advised against proceeding.");

            this.AddLabel(122, 161, 1149, @"Small Blind:");
            this.AddLabel(129, 181, 1149, @"Big Blind:");
            this.AddLabel(123, 201, 1149, @"Min Buy-In:");
            this.AddLabel(120, 221, 1149, @"Max Buy-In:");
            this.AddLabel(110, 241, 1149, @"Bank Balance:");
            this.AddLabel(101, 261, 1149, @"Buy-In Amount:");

            this.AddLabel(200, 161, 148, m_Game.Dealer.SmallBlind.ToString("#,###") + "gp");
            this.AddLabel(200, 181, 148, m_Game.Dealer.BigBlind.ToString("#,###") + "gp");
            this.AddLabel(200, 201, 148, m_Game.Dealer.MinBuyIn.ToString("#,###") + "gp");
            this.AddLabel(200, 221, 148, m_Game.Dealer.MaxBuyIn.ToString("#,###") + "gp");

            int balance    = Banker.GetBalance(from);
            int balancehue = 28;
            int layout     = 0;

            if (balance >= m_Game.Dealer.MinBuyIn)
            {
                balancehue = 266;
                layout     = 1;
            }

            this.AddLabel(200, 241, balancehue, balance.ToString("#,###") + "gp");

            if (layout == 0)
            {
                this.AddLabel(200, 261, 1149, "(not enough gold)");
                this.AddButton(163, 292, 242, 241, (int)Handlers.btnCancel, GumpButtonType.Reply, 0);
            }
            else if (layout == 1)
            {
                this.AddImageTiled(200, 261, 80, 19, 0xBBC);
                this.AddAlphaRegion(200, 261, 80, 19);
                this.AddTextEntry(203, 261, 77, 19, 68, (int)Handlers.txtBuyInAmount, m_Game.Dealer.MinBuyIn.ToString());
                this.AddButton(123, 292, 247, 248, (int)Handlers.btnOkay, GumpButtonType.Reply, 0);
                this.AddButton(200, 292, 242, 241, (int)Handlers.btnCancel, GumpButtonType.Reply, 0);
            }
        }
예제 #30
0
        public void MoveToTheNextRailroadWrapsAroundTheBoard()
        {
            banker = new Banker(players, 1500);
            var railroads = new List<RealEstate>();
            var railroadRentStrategy = new RailroadRentStrategy(railroads);
            var moveToNearestRailroad = new AdvanceToNearest(board, new[] { 5, 15, 25, 35 }, railroadRentStrategy);
            board.MoveTo(player1, 36);

            moveToNearestRailroad.Play(player1);

            Assert.That(board.GetPosition(player1), Is.EqualTo(5));
        }
예제 #31
0
 public IncomeTax(Banker banker, Int32 maxAmount, Int32 percent)
 {
     this.banker = banker;
     this.maxAmount = maxAmount;
     this.percent = percent;
 }
예제 #32
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;

            from.CloseGump <ResurrectGump>();;

            if (info.ButtonID == 1 || info.ButtonID == 2)
            {
                if (from.Map == null || !from.Map.CanFit(from.Location, 16, false, false))
                {
                    from.SendLocalizedMessage(502391);                       // Thou can not be resurrected there!
                    return;
                }

                if (m_Price > 0)
                {
                    if (info.IsSwitched(1))
                    {
                        if (Banker.Withdraw(from, m_Price))
                        {
                            from.SendLocalizedMessage(1060398, m_Price.ToString());                               // ~1_AMOUNT~ gold has been withdrawn from your bank box.
                            from.SendLocalizedMessage(1060022, Banker.GetBalance(from).ToString());               // You have ~1_AMOUNT~ gold in cash remaining in your bank box.
                        }
                        else
                        {
                            from.SendLocalizedMessage(1060020);                               // Unfortunately, you do not have enough cash in your bank to cover the cost of the healing.
                            return;
                        }
                    }
                    else
                    {
                        from.SendLocalizedMessage(1060019);                           // You decide against paying the healer, and thus remain dead.
                        return;
                    }
                }

                from.PlaySound(0x214);
                from.FixedEffect(0x376A, 10, 16);

                from.Resurrect();

                if (from.Fame > 0)
                {
                    int amount = from.Fame / 10;

                    Misc.Titles.AwardFame(from, -amount, true);
                }

                if (from.ShortTermMurders >= 5)
                {
                    double loss = (100.0 - (4.0 + @from.ShortTermMurders / 5.0)) / 100.0;                     // 5 to 15% loss

                    if (loss < 0.85)
                    {
                        loss = 0.85;
                    }
                    else if (loss > 0.95)
                    {
                        loss = 0.95;
                    }

                    if (from.RawStr * loss > 10)
                    {
                        from.RawStr = (int)(from.RawStr * loss);
                    }
                    if (from.RawInt * loss > 10)
                    {
                        from.RawInt = (int)(from.RawInt * loss);
                    }
                    if (from.RawDex * loss > 10)
                    {
                        from.RawDex = (int)(from.RawDex * loss);
                    }

                    for (int s = 0; s < from.Skills.Length; s++)
                    {
                        if (from.Skills[s].Base * loss > 35)
                        {
                            from.Skills[s].Base *= loss;
                        }
                    }
                }

                if (from.Alive && m_HitsScalar > 0)
                {
                    from.Hits = (int)(from.HitsMax * m_HitsScalar);
                }
            }
        }
예제 #33
0
        public override Item Construct(Type type, Mobile from, Item _i, HarvestDefinition _d, HarvestBank _b, HarvestResource _r)
        {
            if (type == typeof(TreasureMap))
            {
                int level = 1;

                return(new TreasureMap(level, Map.Felucca));
            }

            else if (type == typeof(MessageInABottle))
            {
                return(new MessageInABottle(Map.Felucca));
            }

            Container pack = from.Backpack;

            if (pack != null)
            {
                List <SOS> messages = pack.FindItemsByType <SOS>();

                for (int i = 0; i < messages.Count; ++i)
                {
                    SOS sos = messages[i];

                    if (from.Map == sos.TargetMap && from.InRange(sos.TargetLocation, 60) && !sos.Completed)
                    {
                        Item preLoot = null;

                        switch (Utility.Random(7))
                        {
                        case 0:     // Body parts
                        {
                            int[] list = new int[]
                            {
                                0x1CDD, 0x1CE5,                                        // arm
                                0x1CE0, 0x1CE8,                                        // torso
                                0x1CE1, 0x1CE9,                                        // head
                                0x1CE2, 0x1CEC                                         // leg
                            };

                            preLoot = new ShipwreckedItem(Utility.RandomList(list));
                            break;
                        }

                        case 1:     // Bone parts
                        {
                            int[] list = new int[]
                            {
                                0x1AE0, 0x1AE1, 0x1AE2, 0x1AE3, 0x1AE4,                         // skulls
                                0x1B09, 0x1B0A, 0x1B0B, 0x1B0C, 0x1B0D, 0x1B0E, 0x1B0F, 0x1B10, // bone piles
                                0x1B15, 0x1B16                                                  // pelvis bones
                            };

                            preLoot = new ShipwreckedItem(Utility.RandomList(list));
                            break;
                        }

                        case 2:     // Pillows
                        {
                            preLoot = new ShipwreckedItem(Utility.Random(0x13A4, 11));
                            break;
                        }

                        case 3:     // Shells
                        {
                            preLoot = new ShipwreckedItem(Utility.Random(0xFC4, 9));
                            break;
                        }

                        case 4:         //Hats
                        {
                            if (Utility.RandomBool())
                            {
                                preLoot = new SkullCap();
                            }
                            else
                            {
                                preLoot = new TricorneHat();
                            }

                            break;
                        }

                        case 5:     // Misc
                        {
                            int[] list = new int[]
                            {
                                0x1EB5,                                        // unfinished barrel
                                0xA2A,                                         // stool
                                0xC1F,                                         // broken clock
                                0x1EB1, 0x1EB2, 0x1EB3, 0x1EB4                 // barrel staves
                            };

                            if (Utility.Random(list.Length + 1) == 0)
                            {
                                preLoot = new Candelabra();
                            }
                            else
                            {
                                preLoot = new ShipwreckedItem(Utility.RandomList(list));
                            }

                            break;
                        }
                        }

                        if (preLoot != null)
                        {
                            if (preLoot is IShipwreckedItem)
                            {
                                ((IShipwreckedItem)preLoot).IsShipwreckedItem = true;
                            }

                            return(preLoot);
                        }

                        LockableContainer chest;

                        if (Utility.RandomBool())
                        {
                            chest = new MetalGoldenChest();
                        }
                        else
                        {
                            chest = new WoodenChest();
                        }

                        if (sos.IsAncient)
                        {
                            chest.Hue = 0x481;
                        }

                        TreasureMapChest.Fill(chest, Math.Max(1, Math.Min(3, (sos.Level + 1))));

                        if (sos.IsAncient)
                        {
                            chest.DropItem(new FabledFishingNet());
                        }
                        else
                        {
                            chest.DropItem(new SpecialFishingNet());
                        }

                        switch (Utility.Random(300))
                        {
                        case 0:
                        {
                            Item rustedchest = new PlateChest();
                            rustedchest.Hue  = 2718;
                            rustedchest.Name = "a rusted platemail chest recovered from a shipwreck";

                            chest.DropItem(rustedchest);
                            break;
                        }

                        case 1:
                        {
                            Item rustedarms = new PlateArms();
                            rustedarms.Hue  = 2718;
                            rustedarms.Name = "rusted platemail arms recovered from a shipwreck";

                            chest.DropItem(rustedarms);
                            break;
                        }

                        case 2:
                        {
                            Item rustedlegs = new PlateLegs();
                            rustedlegs.Hue  = 2718;
                            rustedlegs.Name = "rusted platemail legguards recovered from a shipwreck";

                            chest.DropItem(rustedlegs);
                            break;
                        }

                        case 3:
                        {
                            Item rustedgloves = new PlateGloves();
                            rustedgloves.Hue  = 2718;
                            rustedgloves.Name = "rusted platemail gloves recovered from a shipwreck";

                            chest.DropItem(rustedgloves);
                            break;
                        }

                        case 4:
                        {
                            Item rustedgorget = new PlateGorget();
                            rustedgorget.Hue  = 2718;
                            rustedgorget.Name = "rusted platemail gorget recovered from a shipwreck";

                            chest.DropItem(rustedgorget);
                            break;
                        }

                        case 5:
                        {
                            Item rustedhelm = new PlateHelm();
                            rustedhelm.Hue  = 2718;
                            rustedhelm.Name = "a rusted platemail helmet recovered from a shipwreck";

                            chest.DropItem(rustedhelm);
                            break;
                        }
                        }

                        switch (Utility.Random(400))
                        {
                        case 0:
                        {
                            Item lamp = new LampPost1();
                            lamp.Name = "Britannia Head Light";
                            lamp.Hue  = 2601;

                            chest.DropItem(lamp);
                            break;
                        }

                        case 1:
                        {
                            Item lantern = new HangingLantern();
                            lantern.Name    = "Fog Lamp";
                            lantern.Hue     = 2601;
                            lantern.Movable = true;

                            chest.DropItem(lantern);
                            break;
                        }
                        }

                        chest.Movable   = true;
                        chest.Locked    = false;
                        chest.TrapType  = TrapType.None;
                        chest.TrapPower = 0;
                        chest.TrapLevel = 0;

                        sos.Completed = true;

                        BaseShip ownerShip = BaseShip.FindShipAt(from.Location, from.Map);

                        PlayerMobile player = from as PlayerMobile;

                        if (ownerShip != null && player != null)
                        {
                            if (ownerShip.IsFriend(player) || ownerShip.IsOwner(player) || ownerShip.IsCoOwner(player))
                            {
                                double doubloonValue = Utility.RandomMinMax(25, 50);

                                int finalDoubloonAmount = (int)doubloonValue;

                                bool shipOwner          = ownerShip.IsOwner(player);
                                bool bankDoubloonsValid = false;
                                bool holdPlacementValid = false;

                                //Deposit Half In Player's Bank
                                if (Banker.DepositUniqueCurrency(player, typeof(Doubloon), finalDoubloonAmount))
                                {
                                    Doubloon doubloonPile = new Doubloon(finalDoubloonAmount);
                                    player.SendSound(doubloonPile.GetDropSound());
                                    doubloonPile.Delete();

                                    bankDoubloonsValid = true;
                                }

                                //Deposit Other Half in Ship
                                if (ownerShip.DepositDoubloons(finalDoubloonAmount))
                                {
                                    Doubloon doubloonPile = new Doubloon(finalDoubloonAmount);
                                    player.SendSound(doubloonPile.GetDropSound());
                                    doubloonPile.Delete();

                                    holdPlacementValid = true;
                                }

                                if (shipOwner)
                                {
                                    player.PirateScore += finalDoubloonAmount;
                                    //ownerShip.doubloonsEarned += finalDoubloonAmount * 2;

                                    if (bankDoubloonsValid && holdPlacementValid)
                                    {
                                        player.SendMessage("You've received " + (finalDoubloonAmount * 2).ToString() + " doubloons for completing a message in a bottle! They have been evenly split between your bank box and your ship's hold.");
                                    }

                                    else if (bankDoubloonsValid && !holdPlacementValid)
                                    {
                                        player.SendMessage("You've earned " + (finalDoubloonAmount * 2).ToString() + " doubloons, however there was not enough room to place all of them in your ship's hold.");
                                    }

                                    else if (!bankDoubloonsValid && holdPlacementValid)
                                    {
                                        player.SendMessage("You've earned " + (finalDoubloonAmount * 2).ToString() + " doubloons, however there was not enough room to place all of them in your bank box.");
                                    }
                                }

                                else
                                {
                                    //ownerShip.doubloonsEarned += finalDoubloonAmount;
                                    player.PirateScore += finalDoubloonAmount;

                                    if (bankDoubloonsValid)
                                    {
                                        player.SendMessage("You've earned " + finalDoubloonAmount.ToString() + " doubloons for completing a message in a bottle! They have been placed in your bank box.");
                                    }

                                    else
                                    {
                                        player.SendMessage("You've earned doubloons, but there was not enough room to place all of them in your bank box.");
                                    }
                                }
                            }
                        }

                        return(chest);
                    }
                }
            }

            return(base.Construct(type, from, _i, _d, _b, _r));
        }
예제 #34
0
        protected override void AcceptOffer(Mobile from)
        {
            m_Contract.Offeree = null;

            if (!m_Contract.Map.CanFit(m_Contract.Location, 16, false, false))
            {
                m_Landlord.SendLocalizedMessage(1062486); // A vendor cannot exist at that location.  Please try again.
                return;
            }

            var house = BaseHouse.FindHouseAt(m_Contract);

            if (house == null)
            {
                return;
            }

            var price = m_Contract.Price;
            int goldToGive;

            if (price > 0)
            {
                if (Banker.Withdraw(from, price))
                {
                    from.SendLocalizedMessage(
                        1060398,
                        price.ToString()
                        ); // ~1_AMOUNT~ gold has been withdrawn from your bank box.

                    var depositedGold = Banker.DepositUpTo(m_Landlord, price);
                    goldToGive = price - depositedGold;

                    if (depositedGold > 0)
                    {
                        m_Landlord.SendLocalizedMessage(
                            1060397,
                            price.ToString()
                            ); // ~1_AMOUNT~ gold has been deposited into your bank box.
                    }

                    if (goldToGive > 0)
                    {
                        m_Landlord.SendLocalizedMessage(500390); // Your bank box is full.
                    }
                }
                else
                {
                    from.SendLocalizedMessage(
                        1062378
                        );                                               // You do not have enough gold in your bank account to cover the cost of the contract.
                    m_Landlord.SendLocalizedMessage(1062374, from.Name); // ~1_NAME~ has declined your vendor rental offer.

                    return;
                }
            }
            else
            {
                goldToGive = 0;
            }

            PlayerVendor vendor = new RentedVendor(
                from,
                house,
                m_Contract.Duration,
                price,
                m_Contract.LandlordRenew,
                goldToGive
                );

            vendor.MoveToWorld(m_Contract.Location, m_Contract.Map);

            m_Contract.Delete();

            from.SendLocalizedMessage(
                1062377
                ); // You have accepted the offer and now own a vendor in this house.  Rental contract options and details may be viewed on this vendor via the 'Contract Options' context menu.
            m_Landlord.SendLocalizedMessage(
                1062376,
                from.Name
                ); // ~1_NAME~ has accepted your vendor rental offer.  Rental contract details and options may be viewed on this vendor via the 'Contract Options' context menu.
        }
예제 #35
0
        public void EndStable(Mobile from, BaseCreature pet)
        {
            if (Deleted || !from.CheckAlive())
            {
                return;
            }

            if (pet.Body.IsHuman)
            {
                from.SendLocalizedMessage(502672); // HA HA HA! Sorry, I am not an inn.
            }
            else if (!pet.Controlled)
            {
                from.SendLocalizedMessage(1048053); // You can't stable that!
            }
            else if (pet.ControlMaster != from)
            {
                from.SendLocalizedMessage(1042562); // You do not own that pet!
            }
            else if (pet.IsDeadPet)
            {
                from.SendLocalizedMessage(1049668); // Living pets only, please.
            }
            else if (pet.Summoned)
            {
                from.SendLocalizedMessage(502673); // I can not stable summoned creatures.
            }
            else if (pet.Allured)
            {
                from.SendLocalizedMessage(1048053); // You can't stable that!
            }
            else if ((pet is PackLlama || pet is PackHorse || pet is Beetle) &&
                     (pet.Backpack != null && pet.Backpack.Items.Count > 0))
            {
                from.SendLocalizedMessage(1042563); // You need to unload your pet.
            }
            else if (pet.Combatant != null && pet.InRange(pet.Combatant, 12) && pet.Map == pet.Combatant.Map)
            {
                from.SendLocalizedMessage(1042564); // I'm sorry.  Your pet seems to be busy.
            }
            else if (from.Stabled.Count >= AnimalTrainer.GetMaxStabled(from))
            {
                from.SendLocalizedMessage(1042565); // You have too many pets in the stables!
            }
            else if ((from.Backpack != null && from.Backpack.ConsumeTotal(typeof(Gold), 30)) || Banker.Withdraw(from, 30))
            {
                pet.ControlTarget = null;
                pet.ControlOrder  = OrderType.Stay;
                pet.Internalize();

                pet.SetControlMaster(null);
                pet.SummonMaster = null;

                pet.IsStabled = true;
                pet.StabledBy = from;

                if (Core.SE)
                {
                    pet.Loyalty = BaseCreature.MaxLoyalty; // Wonderfully happy
                }

                from.Stabled.Add(pet);

                from.SendLocalizedMessage(Core.AOS ? 1049677 : 502679);
                // [AOS: Your pet has been stabled.] Very well, thy pet is stabled.
                // Thou mayst recover it by saying 'claim' to me. In one real world week,
                // I shall sell it off if it is not claimed!
            }
            else
            {
                from.SendLocalizedMessage(502677); // But thou hast not the funds in thy bank account!
            }
        }
예제 #36
0
        public HousePlacementListGump(Mobile from, HousePlacementEntry[] entries)
            : base(50, 50)
        {
            this.m_From    = from;
            this.m_Entries = entries;

            from.CloseGump(typeof(HousePlacementCategoryGump));
            from.CloseGump(typeof(HousePlacementListGump));

            this.AddPage(0);

            this.AddBackground(0, 0, 520, 420, 5054);

            this.AddImageTiled(10, 10, 500, 20, 2624);
            this.AddAlphaRegion(10, 10, 500, 20);

            this.AddHtmlLocalized(10, 10, 500, 20, 1060239, LabelColor, false, false); // <CENTER>HOUSE PLACEMENT TOOL</CENTER>

            this.AddImageTiled(10, 40, 500, 20, 2624);
            this.AddAlphaRegion(10, 40, 500, 20);

            this.AddHtmlLocalized(50, 40, 225, 20, 1060235, LabelColor, false, false); // House Description
            this.AddHtmlLocalized(275, 40, 75, 20, 1060236, LabelColor, false, false); // Storage
            this.AddHtmlLocalized(350, 40, 75, 20, 1060237, LabelColor, false, false); // Lockdowns
            this.AddHtmlLocalized(425, 40, 75, 20, 1060034, LabelColor, false, false); // Cost

            this.AddImageTiled(10, 70, 500, 280, 2624);
            this.AddAlphaRegion(10, 70, 500, 280);

            this.AddImageTiled(10, 360, 500, 20, 2624);
            this.AddAlphaRegion(10, 360, 500, 20);

            this.AddHtmlLocalized(10, 360, 250, 20, 1060645, LabelColor, false, false); // Bank Balance:
            this.AddLabel(250, 360, LabelHue, Banker.GetBalance(from).ToString());

            this.AddImageTiled(10, 390, 500, 20, 2624);
            this.AddAlphaRegion(10, 390, 500, 20);

            this.AddButton(10, 390, 4017, 4019, 0, GumpButtonType.Reply, 0);
            this.AddHtmlLocalized(50, 390, 100, 20, 3000363, LabelColor, false, false); // Close

            for (int i = 0; i < entries.Length; ++i)
            {
                int page  = 1 + (i / 14);
                int index = i % 14;

                if (index == 0)
                {
                    if (page > 1)
                    {
                        this.AddButton(450, 390, 4005, 4007, 0, GumpButtonType.Page, page);
                        this.AddHtmlLocalized(400, 390, 100, 20, 3000406, LabelColor, false, false); // Next
                    }

                    this.AddPage(page);

                    if (page > 1)
                    {
                        this.AddButton(200, 390, 4014, 4016, 0, GumpButtonType.Page, page - 1);
                        this.AddHtmlLocalized(250, 390, 100, 20, 3000405, LabelColor, false, false); // Previous
                    }
                }

                HousePlacementEntry entry = entries[i];

                int y = 70 + (index * 20);

                this.AddButton(10, y, 4005, 4007, 1 + i, GumpButtonType.Reply, 0);
                this.AddHtmlLocalized(50, y, 225, 20, entry.Description, LabelColor, false, false);
                this.AddLabel(275, y, LabelHue, entry.Storage.ToString());
                this.AddLabel(350, y, LabelHue, entry.Lockdowns.ToString());
                this.AddLabel(425, y, LabelHue, entry.Cost.ToString());
            }
        }
예제 #37
0
        public void OnTarget(Mobile from, object obj)
        {
            if (Deleted || m_InUse)
            {
                return;
            }

            IPoint3D p3D = obj as IPoint3D;

            if (p3D == null)
            {
                return;
            }

            Map map = from.Map;

            if (map == null || map == Map.Internal)
            {
                return;
            }

            int x = p3D.X, y = p3D.Y, z = map.GetAverageZ(x, y); // OSI just takes the targeted Z

            if (!from.InRange(p3D, 6))
            {
                from.SendLocalizedMessage(500976); // You need to be closer to the water to fish!
            }
            else if (!from.InLOS(obj))
            {
                from.SendLocalizedMessage(500979); // You cannot see that location.
            }
            else if (RequireDeepWater ? FullValidation(map, x, y) : (ValidateDeepWater(map, x, y) || ValidateUndeepWater(map, obj, ref z)))
            {
                Point3D p = new Point3D(x, y, z);

                if (GetType() == typeof(SpecialFishingNet))
                {
                    for (int i = 1; i < Amount; ++i) // these were stackable before, doh
                    {
                        from.AddToBackpack(new SpecialFishingNet());
                    }
                }

                BaseBoat ownerBoat = BaseBoat.FindBoatAt(from.Location, from.Map);

                PlayerMobile player = from as PlayerMobile;

                if (ownerBoat != null && player != null)
                {
                    if (ownerBoat.IsFriend(player) || ownerBoat.IsOwner(player) || ownerBoat.IsCoOwner(player))
                    {
                        double doubloonValue = Utility.RandomMinMax(5, 10);

                        int finalDoubloonAmount = (int)doubloonValue;

                        bool shipOwner          = ownerBoat.IsOwner(player);
                        bool bankDoubloonsValid = false;
                        bool holdPlacementValid = false;

                        //Deposit Half In Player's Bank
                        if (Banker.DepositUniqueCurrency(player, typeof(Doubloon), finalDoubloonAmount))
                        {
                            Doubloon doubloonPile = new Doubloon(finalDoubloonAmount);
                            player.SendSound(doubloonPile.GetDropSound());
                            doubloonPile.Delete();

                            bankDoubloonsValid = true;
                        }

                        //Deposit Other Half in Ship
                        if (ownerBoat.DepositDoubloons(finalDoubloonAmount))
                        {
                            Doubloon doubloonPile = new Doubloon(finalDoubloonAmount);
                            player.SendSound(doubloonPile.GetDropSound());
                            doubloonPile.Delete();

                            holdPlacementValid = true;
                        }

                        if (shipOwner)
                        {
                            player.PirateScore += finalDoubloonAmount;
                            //ownerBoat.doubloonsEarned += finalDoubloonAmount * 2;

                            if (bankDoubloonsValid && holdPlacementValid)
                            {
                                player.SendMessage("You've received " + (finalDoubloonAmount * 2).ToString() + " doubloons for using a net! They have been evenly split between your bank box and your ship's hold.");
                            }

                            else if (bankDoubloonsValid && !holdPlacementValid)
                            {
                                player.SendMessage("You've earned " + (finalDoubloonAmount * 2).ToString() + " doubloons, however there was not enough room to place all of them in your ship's hold.");
                            }

                            else if (!bankDoubloonsValid && holdPlacementValid)
                            {
                                player.SendMessage("You've earned " + (finalDoubloonAmount * 2).ToString() + " doubloons, however there was not enough room to place all of them in your bank box.");
                            }
                        }

                        else
                        {
                            player.PirateScore += finalDoubloonAmount;
                            //ownerBoat.doubloonsEarned += finalDoubloonAmount;

                            if (bankDoubloonsValid)
                            {
                                player.SendMessage("You've earned " + finalDoubloonAmount.ToString() + " doubloons for using a net! They have been placed in your bank box.");
                            }
                            else
                            {
                                player.SendMessage("You've earned doubloons, but there was not enough room to place all of them in your bank box.");
                            }
                        }
                    }
                }

                m_InUse = true;
                Movable = false;
                MoveToWorld(p, map);

                SpellHelper.Turn(from, p);
                from.Animate(12, 5, 1, true, false, 0);

                Effects.SendLocationEffect(p, map, 0x352D, 16, 4);
                Effects.PlaySound(p, map, 0x364);

                Timer.DelayCall(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.25), 14, new TimerStateCallback(DoEffect), new object[] { p, 0, from });

                from.SendLocalizedMessage(RequireDeepWater ? 1010487 : 1074492); // You plunge the net into the sea... / You plunge the net into the water...
            }
            else
            {
                from.SendLocalizedMessage(RequireDeepWater ? 1010485 : 1074491); // You can only use this net in deep water! / You can only use this net in water!
            }
        }
예제 #38
0
 public Railroad(Int32 index, Int32 price, Int32 baseRent, String group, Banker banker, PropertyManager propertyManager)
     : base(index, price, baseRent, group, banker, propertyManager)
 {
 }
 public CollectFromEachPlayer(Banker banker, Int32 amount)
 {
     this.banker = banker;
     this.amount = amount;
 }
예제 #40
0
        public void SetUp()
        {
            player1 = "Horse";
            player2 = "Car";
            players = new List<String> { player1, player2 };
            banker = new Banker(players, 1500);
            railroads = new List<RealEstate>();
            railroadRentStrategy = new RailroadRentStrategy(railroads);
            reading = new RealEstate(banker, 200, 25, railroadRentStrategy);
            pennsylvania = new RealEstate(banker, 200, 25, railroadRentStrategy);
            bAndO = new RealEstate(banker, 200, 25, railroadRentStrategy);
            shortLine = new RealEstate(banker, 200, 25, railroadRentStrategy);

            railroads.AddRange(new[] { reading, pennsylvania, bAndO, shortLine });
        }
예제 #41
0
        public void RunBanker()
        {
            var banker = new Banker(new ConsoleLogger());

            banker.Deposit("12345", 500);
        }
예제 #42
0
파일: TestCenter.cs 프로젝트: ygtkms/ServUO
        public static void FillBank(Mobile m)
        {
            BankBox bank = m.BankBox;

            for (int i = 0; i < PowerScroll.Skills.Count; ++i)
            {
                m.Skills[PowerScroll.Skills[i]].Cap = 120.0;
            }

            m.StatCap = 250;

            var book = new Runebook(9999);

            book.CurCharges = book.MaxCharges;
            book.Entries.Add(new RunebookEntry(new Point3D(1438, 1695, 0), Map.Trammel, "Britain Bank", null));
            book.Entries.Add(new RunebookEntry(new Point3D(1821, 2821, 0), Map.Trammel, "Trinsic Bank", null));
            book.Entries.Add(new RunebookEntry(new Point3D(1492, 1628, 13), Map.Trammel, "Britain Sweet Dreams", null));
            book.Entries.Add(new RunebookEntry(new Point3D(1388, 1507, 10), Map.Trammel, "Britain Graveyard", null));
            book.Entries.Add(new RunebookEntry(new Point3D(1300, 1080, 0), Map.Trammel, "Dungeon Despise", null));
            book.Entries.Add(new RunebookEntry(new Point3D(1171, 2639, 0), Map.Trammel, "Dungeon Destard", null));
            book.Entries.Add(new RunebookEntry(new Point3D(1260, 2296, 0), Map.Trammel, "Hedge Maze", null));

            m.AddToBackpack(book);

            #region Gold
            var account = m.Account as Account;

            if (account != null && account.GetTag("TCGold") == null)
            {
                account.AddTag("TCGold", "Gold Given");

                Banker.Deposit(m, 30000000, false);
            }
            #endregion

            #region Bank Level Items
            bank.DropItem(new Robe(443));
            bank.DropItem(new Dagger());
            bank.DropItem(new Candle());
            bank.DropItem(new FireworksWand()
            {
                Name = "Mininova Fireworks Wand"
            });
            #endregion

            Container cont;

            #region TMaps
            cont      = new Bag();
            cont.Name = "Bag of Treasure Maps";

            for (int i = 0; i < 10; i++)
            {
                PlaceItemIn(cont, 30 + (i * 6), 35, new TreasureMap(Utility.Random(3), Map.Trammel));
            }

            for (int i = 0; i < 10; i++)
            {
                PlaceItemIn(cont, 30 + (i * 6), 51, new TreasureMap(Utility.Random(3), Map.Trammel));
            }

            for (int i = 0; i < 20; i++)
            {
                PlaceItemIn(cont, 76, 91, new MessageInABottle());
            }

            PlaceItemIn(cont, 22, 77, new Shovel(30000));
            PlaceItemIn(cont, 57, 97, new Lockpick(3));

            PlaceItemIn(bank, 98, 124, cont);
            #endregion

            #region Trans Powder
            cont = new Bag();

            PlaceItemIn(cont, 117, 147, new PowderOfTranslocation(100));
            PlaceItemIn(bank, 117, 147, cont);
            #endregion

            #region Magery Items
            cont      = new WoodenBox();
            cont.Hue  = 1195;
            cont.Name = "Magery Items";

            PlaceItemIn(cont, 78, 88, new CrimsonCincture()
            {
                Hue = 232
            });
            PlaceItemIn(cont, 102, 90, new CrystallineRing());

            var brac = new GoldBracelet();
            brac.Name = "Farmer's Bank of Mastery";
            brac.Attributes.CastRecovery = 3;
            brac.Attributes.CastSpeed    = 1;
            PlaceItemIn(cont, 139, 30, brac);

            Container bag = new Backpack();
            bag.Hue  = 1152;
            bag.Name = "Spell Casting Stuff";

            PlaceItemIn(bag, 45, 107, new Spellbook(UInt64.MaxValue));
            PlaceItemIn(bag, 65, 107, new NecromancerSpellbook((UInt64)0xFFFF));
            PlaceItemIn(bag, 85, 107, new BookOfChivalry((UInt64)0x3FF));
            PlaceItemIn(bag, 105, 107, new BookOfBushido());  //Default ctor = full
            PlaceItemIn(bag, 125, 107, new BookOfNinjitsu()); //Default ctor = full

            PlaceItemIn(bag, 102, 122, new SpellweavingBook((1ul << 16) - 1));
            PlaceItemIn(bag, 122, 122, new MysticBook((1ul << 16) - 1));

            Runebook runebook = new Runebook(20);
            runebook.CurCharges = runebook.MaxCharges;
            PlaceItemIn(bag, 145, 105, runebook);

            Item toHue = new BagOfReagents(5000);
            toHue.Hue = 0x2D;
            PlaceItemIn(bag, 45, 128, toHue);

            toHue     = new BagOfNecroReagents(3000);
            toHue.Hue = 0x488;
            PlaceItemIn(bag, 64, 125, toHue);

            toHue     = new BagOfMysticReagents(3000);
            toHue.Hue = 1167;
            PlaceItemIn(bag, 141, 128, toHue);

            for (int i = 0; i < 9; ++i)
            {
                PlaceItemIn(bag, 45 + (i * 10), 74, new RecallRune());
            }

            PlaceItemIn(cont, 47, 91, bag);

            bag      = new Backpack();
            bag.Name = "Various Potion Kegs";

            PlaceItemIn(bag, 45, 149, MakePotionKeg(PotionEffect.CureGreater, 0x2D));
            PlaceItemIn(bag, 69, 149, MakePotionKeg(PotionEffect.HealGreater, 0x499));
            PlaceItemIn(bag, 93, 149, MakePotionKeg(PotionEffect.PoisonDeadly, 0x46));
            PlaceItemIn(bag, 117, 149, MakePotionKeg(PotionEffect.RefreshTotal, 0x21));
            PlaceItemIn(bag, 141, 149, MakePotionKeg(PotionEffect.ExplosionGreater, 0x74));

            PlaceItemIn(bag, 93, 82, new Bottle(1000));

            PlaceItemIn(cont, 53, 169, bag);

            PlaceItemIn(bank, 63, 142, cont);
            #endregion

            #region Silver - No Mas Silver

            /*cont = new WoodenBox();
             * cont.Hue = 1161;
             *
             * PlaceItemIn(cont, 47, 91, new Silver(9000));
             * PlaceItemIn(bank, 38, 142, cont);*/
            #endregion

            #region Ethys
            cont      = new Backpack();
            cont.Hue  = 0x490;
            cont.Name = "Bag Of Ethy's!";

            PlaceItemIn(cont, 45, 66, new EtherealHorse());
            PlaceItemIn(cont, 93, 99, new EtherealLlama());
            PlaceItemIn(cont, 45, 132, new EtherealUnicorn());
            PlaceItemIn(cont, 117, 99, new EtherealBeetle());

            PlaceItemIn(bank, 38, 124, cont);
            #endregion
        }
예제 #43
0
 public Go(Banker banker)
 {
     this.banker = banker;
 }
예제 #44
0
        public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
        {
            if (info.ButtonID == 2)
            {
                PlayerVendor pv = m_Book.RootParent as PlayerVendor;

                if (m_Book.Entries.Contains(m_Object) && pv != null)
                {
                    int price = 0;

                    VendorItem vi = pv.GetVendorItem(m_Book);

                    if (vi != null && !vi.IsForSale)
                    {
                        if (m_Object is BOBLargeEntry)
                        {
                            price = ((BOBLargeEntry)m_Object).Price;
                        }
                        else if (m_Object is BOBSmallEntry)
                        {
                            price = ((BOBSmallEntry)m_Object).Price;
                        }
                    }

                    if (price != m_Price)
                    {
                        pv.SayTo(m_From, "The price has been been changed. If you like, you may offer to purchase the item again.");
                    }
                    else if (price == 0)
                    {
                        pv.SayTo(m_From, 1062382);                           // The deed selected is not available.
                    }
                    else
                    {
                        Item item = null;

                        if (m_Object is BOBLargeEntry)
                        {
                            item = ((BOBLargeEntry)m_Object).Reconstruct();
                        }
                        else if (m_Object is BOBSmallEntry)
                        {
                            item = ((BOBSmallEntry)m_Object).Reconstruct();
                        }

                        if (item == null)
                        {
                            m_From.SendMessage("Internal error. The bulk order deed could not be reconstructed.");
                        }
                        else
                        {
                            pv.Say(m_From.Name);

                            Container pack = m_From.Backpack;

                            if ((pack == null) || ((pack != null) && (!pack.CheckHold(m_From, item, true, true, 0, item.PileWeight + item.TotalWeight))))
                            {
                                pv.SayTo(m_From, 503204);                                 // You do not have room in your backpack for this
                                m_From.SendGump(new BOBGump(m_From, m_Book, m_Page, null));
                            }
                            else
                            {
                                if ((pack != null && pack.ConsumeTotal(typeof(Gold), price)) || Banker.Withdraw(m_From, price))
                                {
                                    m_Book.Entries.Remove(m_Object);
                                    m_Book.InvalidateProperties();
                                    pv.HoldGold += price;
                                    m_From.AddToBackpack(item);
                                    m_From.SendLocalizedMessage(1045152);                                       // The bulk order deed has been placed in your backpack.

                                    if (m_Book.Entries.Count / 5 < m_Book.ItemCount)
                                    {
                                        m_Book.ItemCount--;
                                        m_Book.InvalidateItems();
                                    }

                                    if (m_Book.Entries.Count > 0)
                                    {
                                        m_From.SendGump(new BOBGump(m_From, m_Book, m_Page, null));
                                    }
                                    else
                                    {
                                        m_From.SendLocalizedMessage(1062381);                                           // The book is empty.
                                    }
                                }
                                else
                                {
                                    pv.SayTo(m_From, 503205);                                       // You cannot afford this item.
                                    item.Delete();
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (pv == null)
                    {
                        m_From.SendLocalizedMessage(1062382);                           // The deed selected is not available.
                    }
                    else
                    {
                        pv.SayTo(m_From, 1062382);                           // The deed selected is not available.
                    }
                }
            }
            else
            {
                m_From.SendLocalizedMessage(503207);                   // Cancelled purchase.
            }
        }
예제 #45
0
        public void MoveToTheNextRailroadDoublesRent()
        {
            banker = new Banker(players, 1500);

            var railroads = new List<RealEstate>();
            var railroadRentStrategy = new RailroadRentStrategy(railroads);
            var readingRailroad = new RealEstate(banker, 200, 25, railroadRentStrategy);
            var pennsylvaniaRailroad = new RealEstate(banker, 200, 25, railroadRentStrategy);
            var bORailroad = new RealEstate(banker, 200, 25, railroadRentStrategy);
            var shortLineRailroad = new RealEstate(banker, 200, 25, railroadRentStrategy);
            railroads.AddRange(new[] { readingRailroad, pennsylvaniaRailroad, bORailroad, shortLineRailroad });

            var spaces = new Dictionary<Int32, IBoardSpace>
            {
                { 5, readingRailroad },
                { 15, pennsylvaniaRailroad },
                { 25, bORailroad },
                { 35, shortLineRailroad }
            };

            var moveToNearestRailroad = new AdvanceToNearest(board, new[] { 5, 15, 25, 35 }, railroadRentStrategy);
            board.SetSpaces(spaces);
            board.MoveTo(player2, 15);
            board.MoveTo(player1, 7);
            var previousBalance = banker.GetBalance(player1);

            moveToNearestRailroad.Play(player1);

            Assert.That(banker.GetBalance(player1), Is.EqualTo(previousBalance - 50));
        }
예제 #46
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (info.ButtonID == 0)
            {
                return;
            }

            Mobile    from = sender.Mobile;
            HouseSign sign = this.m_House.Sign;

            if (this.m_House.Deleted || sign == null || sign.Deleted || !from.CheckAlive())
            {
                return;
            }

            if (from.Map != sign.Map || !from.InRange(sign, 5))
            {
                from.SendLocalizedMessage(1062429); // You must be within five paces of the house sign to use this option.
                return;
            }

            int index = info.ButtonID - 1;

            if (index < 0 || index >= this.m_Inventories.Count)
            {
                return;
            }

            VendorInventory inventory = (VendorInventory)this.m_Inventories[index];

            if (inventory.Owner != from || !this.m_House.VendorInventories.Contains(inventory))
            {
                return;
            }

            int totalItems      = 0;
            int givenToBackpack = 0;
            int givenToBankBox  = 0;

            for (int i = inventory.Items.Count - 1; i >= 0; i--)
            {
                Item item = inventory.Items[i];

                if (item.Deleted)
                {
                    inventory.Items.RemoveAt(i);
                    continue;
                }

                totalItems += 1 + item.TotalItems;

                if (from.PlaceInBackpack(item))
                {
                    inventory.Items.RemoveAt(i);
                    givenToBackpack += 1 + item.TotalItems;
                }
                else if (from.BankBox.TryDropItem(from, item, false))
                {
                    inventory.Items.RemoveAt(i);
                    givenToBankBox += 1 + item.TotalItems;
                }
            }

            from.SendLocalizedMessage(1062436, totalItems.ToString() + "\t" + inventory.Gold.ToString()); // The vendor you selected had ~1_COUNT~ items in its inventory, and ~2_AMOUNT~ gold in its account.

            int givenGold = Banker.DepositUpTo(from, inventory.Gold);

            inventory.Gold -= givenGold;

            from.SendLocalizedMessage(1060397, givenGold.ToString());                                          // ~1_AMOUNT~ gold has been deposited into your bank box.
            from.SendLocalizedMessage(1062437, givenToBackpack.ToString() + "\t" + givenToBankBox.ToString()); // ~1_COUNT~ items have been removed from the shop inventory and placed in your backpack.  ~2_BANKCOUNT~ items were removed from the shop inventory and placed in your bank box.

            if (inventory.Gold > 0 || inventory.Items.Count > 0)
            {
                from.SendLocalizedMessage(1062440); // Some of the shop inventory would not fit in your backpack or bank box.  Please free up some room and try again.
            }
            else
            {
                inventory.Delete();
                from.SendLocalizedMessage(1062438); // The shop is now empty of inventory and funds, so it has been deleted.
            }
        }
예제 #47
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;

            from.CloseGump(typeof(ResurrectGump));

            if (ResurrectMessage.SilverSapling == m_Msg && 1 == info.ButtonID)
            {
                PlayerMobile pm = from as PlayerMobile;
                if (null != pm && pm.Region.IsPartOf("Abyss"))
                {
                    pm.Location = pm.SSSeedLocation;
                    pm.Map      = pm.SSSeedMap;
                    if (null != pm.Corpse)
                    {
                        pm.Corpse.Location = pm.Location;
                        pm.Corpse.Map      = pm.Map;
                    }
                    pm.Resurrect();
                }
                return;
            }

            if (info.ButtonID == 1 || info.ButtonID == 2)
            {
                if (from.Map == null || !from.Map.CanFit(from.Location, 16, false, false))
                {
                    from.SendLocalizedMessage(502391); // Thou can not be resurrected there!
                    return;
                }

                if (m_Price > 0)
                {
                    if (info.IsSwitched(1))
                    {
                        if (Banker.Withdraw(from, m_Price))
                        {
                            from.SendLocalizedMessage(1060398, m_Price.ToString());                 // ~1_AMOUNT~ gold has been withdrawn from your bank box.
                            from.SendLocalizedMessage(1060022, Banker.GetBalance(from).ToString()); // You have ~1_AMOUNT~ gold in cash remaining in your bank box.
                        }
                        else
                        {
                            from.SendLocalizedMessage(1060020); // Unfortunately, you do not have enough cash in your bank to cover the cost of the healing.
                            return;
                        }
                    }
                    else
                    {
                        from.SendLocalizedMessage(1060019); // You decide against paying the healer, and thus remain dead.
                        return;
                    }
                }

                from.PlaySound(0x214);
                from.FixedEffect(0x376A, 10, 16);

                from.Resurrect();

                if (m_Healer != null && from != m_Healer)
                {
                    VirtueLevel level = VirtueHelper.GetLevel(m_Healer, VirtueName.Compassion);

                    switch (level)
                    {
                    case VirtueLevel.Seeker:
                        from.Hits = AOS.Scale(from.HitsMax, 20);
                        break;

                    case VirtueLevel.Follower:
                        from.Hits = AOS.Scale(from.HitsMax, 40);
                        break;

                    case VirtueLevel.Knight:
                        from.Hits = AOS.Scale(from.HitsMax, 80);
                        break;
                    }
                }

                if (m_FromSacrifice && from is PlayerMobile)
                {
                    ((PlayerMobile)from).AvailableResurrects -= 1;

                    Container pack   = from.Backpack;
                    Container corpse = from.Corpse;

                    if (pack != null && corpse != null)
                    {
                        List <Item> items = new List <Item>(corpse.Items);

                        for (int i = 0; i < items.Count; ++i)
                        {
                            Item item = items[i];

                            if (item.Layer != Layer.Hair && item.Layer != Layer.FacialHair && item.Movable)
                            {
                                pack.DropItem(item);
                            }
                        }
                    }
                }

                if (m_Healer != from && m_Healer is PlayerMobile && from is PlayerMobile)
                {
                    SpiritualityVirtue.OnHeal(m_Healer, 50);
                }

                if (from.Fame > 0)
                {
                    int amount = from.Fame / 10;

                    Misc.Titles.AwardFame(from, -amount, true);
                }

                if (from.Alive && m_HitsScalar > 0)
                {
                    from.Hits = (int)(from.HitsMax * m_HitsScalar);
                }

                if (m_Callback != null)
                {
                    m_Callback(from);
                }
            }
        }
예제 #48
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (!(sender.Mobile is PlayerMobile pm) || pm.Guild != null)
            {
                return; // Sanity
            }
            switch (info.ButtonID)
            {
            case 1:
            {
                TextRelay tName   = info.GetTextEntry(5);
                TextRelay tAbbrev = info.GetTextEntry(6);

                string guildName   = tName == null ? "" : tName.Text;
                string guildAbbrev = tAbbrev == null ? "" : tAbbrev.Text;

                guildName   = Utility.FixHtml(guildName.Trim());
                guildAbbrev = Utility.FixHtml(guildAbbrev.Trim());

                if (guildName.Length <= 0)
                {
                    pm.SendLocalizedMessage(1070884); // Guild name cannot be blank.
                }
                else if (guildAbbrev.Length <= 0)
                {
                    pm.SendLocalizedMessage(1070885); // You must provide a guild abbreviation.
                }
                else if (guildName.Length > Guild.NameLimit)
                {
                    pm.SendLocalizedMessage(1063036,
                                            Guild.NameLimit.ToString()); // A guild name cannot be more than ~1_val~ characters in length.
                }
                else if (guildAbbrev.Length > Guild.AbbrevLimit)
                {
                    pm.SendLocalizedMessage(1063037,
                                            Guild.AbbrevLimit.ToString()); // An abbreviation cannot exceed ~1_val~ characters in length.
                }
                else if (BaseGuild.FindByAbbrev(guildAbbrev) != null || !BaseGuildGump.CheckProfanity(guildAbbrev))
                {
                    pm.SendLocalizedMessage(501153); // That abbreviation is not available.
                }
                else if (BaseGuild.FindByName(guildName) != null || !BaseGuildGump.CheckProfanity(guildName))
                {
                    pm.SendLocalizedMessage(1063000); // That guild name is not available.
                }
                else if (!Banker.Withdraw(pm, Guild.RegistrationFee))
                {
                    pm.SendLocalizedMessage(1063001,
                                            Guild.RegistrationFee
                                            .ToString()); // You do not possess the ~1_val~ gold piece fee required to create a guild.
                }
                else
                {
                    pm.SendLocalizedMessage(1060398,
                                            Guild.RegistrationFee.ToString()); // ~1_AMOUNT~ gold has been withdrawn from your bank box.
                    pm.SendLocalizedMessage(1063238);                          // Your new guild has been founded.
                    pm.Guild = new Guild(pm, guildName, guildAbbrev);
                }

                break;
            }

            case 2:
            {
                pm.AcceptGuildInvites = !pm.AcceptGuildInvites;

                if (pm.AcceptGuildInvites)
                {
                    pm.SendLocalizedMessage(1070699); // You are now accepting guild invitations.
                }
                else
                {
                    pm.SendLocalizedMessage(1070698); // You are now ignoring guild invitations.
                }
                break;
            }
            }
        }
예제 #49
0
        public void SetUp()
        {
            player1 = "Horse";
            player2 = "Car";
            players = new List<String> { player1, player2 };
            banker = new Banker(players, 1500);
            var purples = new List<RealEstate>();
            var purpleRentStrategy = new PropertyRentStrategy(purples);
            mediterranean = new RealEstate(banker, 60, 2, purpleRentStrategy);
            baltic = new RealEstate(banker, 60, 4, purpleRentStrategy);

            purples.AddRange(new[] { mediterranean, baltic });
        }
예제 #50
0
            private void HandleResponse(Mobile from, string text)
            {
                int amount = Utility.ToInt32(text);

                if (amount <= 0)
                {
                    from.SendLocalizedMessage(1073181); // That is not a valid donation quantity.
                    return;
                }

                if (from.Backpack == null)
                {
                    return;
                }

                if (m_Selected.Type == typeof(Gold))
                {
                    if (amount * m_Selected.Points < 1)
                    {
                        from.SendLocalizedMessage(1073167); // You do not have enough of that item to make a donation!
                        from.SendGump(new CommunityCollectionGump((PlayerMobile)from, m_Collection, m_Location));
                        return;
                    }

                    Item[]  items = from.Backpack.FindItemsByType(m_Selected.Type, true);
                    Account acct  = from.Account as Account;

                    int goldcount       = 0;
                    int accountcount    = acct == null ? 0 : acct.TotalGold;
                    int amountRemaining = amount;
                    foreach (Item item in items)
                    {
                        goldcount += item.Amount;
                    }

                    if (goldcount >= amountRemaining)
                    {
                        foreach (Item item in items)
                        {
                            if (item.Amount <= amountRemaining)
                            {
                                item.Delete();
                                amountRemaining -= item.Amount;
                            }
                            else
                            {
                                item.Amount    -= amountRemaining;
                                amountRemaining = 0;
                            }

                            if (amountRemaining == 0)
                            {
                                break;
                            }
                        }
                    }
                    else if (goldcount + accountcount >= amountRemaining)
                    {
                        foreach (Item item in items)
                        {
                            amountRemaining -= item.Amount;
                            item.Delete();
                        }

                        Banker.Withdraw(from, amountRemaining);
                    }
                    else
                    {
                        from.SendLocalizedMessage(1073182); // You do not have enough to make a donation of that magnitude!
                        from.SendGump(new CommunityCollectionGump((PlayerMobile)from, m_Collection, m_Location));
                        return;
                    }

                    from.Backpack.ConsumeTotal(m_Selected.Type, amount, true, true);
                    m_Collection.Donate((PlayerMobile)from, m_Selected, amount);
                }
                else
                {
                    if (amount * m_Selected.Points < 1)
                    {
                        from.SendLocalizedMessage(1073167); // You do not have enough of that item to make a donation!
                        from.SendGump(new CommunityCollectionGump((PlayerMobile)from, m_Collection, m_Location));
                        return;
                    }

                    List <Item> items = FindTypes((PlayerMobile)from, m_Selected);

                    if (items.Count > 0)
                    {
                        // count items
                        int count = 0;

                        for (int i = 0; i < items.Count; i++)
                        {
                            Item item = GetActual(items[i]);

                            if (item != null && !item.Deleted)
                            {
                                count += item.Amount;
                            }
                        }

                        // check
                        if (amount > count)
                        {
                            from.SendLocalizedMessage(1073182); // You do not have enough to make a donation of that magnitude!
                            from.SendGump(new CommunityCollectionGump((PlayerMobile)from, m_Collection, m_Location));
                            return;
                        }
                        else if (amount * m_Selected.Points < 1)
                        {
                            from.SendLocalizedMessage(m_Selected.Type == typeof(Gold) ? 1073182 : 1073167); // You do not have enough of that item to make a donation!
                            from.SendGump(new CommunityCollectionGump((PlayerMobile)from, m_Collection, m_Location));
                            return;
                        }

                        // donate
                        int deleted = 0;

                        for (int i = 0; i < items.Count && deleted < amount; i++)
                        {
                            Item item = GetActual(items[i]);

                            if (item == null || item.Deleted)
                            {
                                continue;
                            }

                            if (item.Stackable && item.Amount + deleted > amount && !item.Deleted)
                            {
                                item.Amount -= amount - deleted;
                                deleted     += amount - deleted;
                            }
                            else if (!item.Deleted)
                            {
                                deleted += item.Amount;
                                items[i].Delete();
                            }

                            if (items[i] is CommodityDeed && !items[i].Deleted)
                            {
                                items[i].InvalidateProperties();
                            }
                        }

                        m_Collection.Donate((PlayerMobile)from, m_Selected, amount);
                    }
                    else
                    {
                        from.SendLocalizedMessage(1073182); // You do not have enough to make a donation of that magnitude!
                    }

                    ColUtility.Free(items);
                }
            }
예제 #51
0
 public Utility(Int32 index, Int32 price, String group, Banker banker, PropertyManager propertyManager, Dice dice)
     : base(index, price, 0, group, banker, propertyManager)
 {
     this.dice = dice;
 }
예제 #52
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;

            if (!this.m_Vendor.CanInteractWith(from, false))
            {
                return;
            }

            if (this.m_Vendor.IsOwner(from))
            {
                this.m_Vendor.SayTo(from, 503212); // You own this shop, just take what you want.
                return;
            }

            if (info.ButtonID == 1)
            {
                this.m_Vendor.Say(from.Name);

                if (!this.m_VI.Valid || !this.m_VI.Item.IsChildOf(this.m_Vendor.Backpack))
                {
                    this.m_Vendor.SayTo(from, 503216); // You can't buy that.
                    return;
                }

                int totalGold = 0;

                if (from.Backpack != null)
                {
                    totalGold += from.Backpack.GetAmount(typeof(Gold));
                }

                totalGold += Banker.GetBalance(from);

                if (totalGold < this.m_VI.Price)
                {
                    this.m_Vendor.SayTo(from, 503205); // You cannot afford this item.
                }
                else if (!from.PlaceInBackpack(this.m_VI.Item))
                {
                    this.m_Vendor.SayTo(from, 503204); // You do not have room in your backpack for this.
                }
                else
                {
                    int leftPrice = this.m_VI.Price;

                    if (from.Backpack != null)
                    {
                        leftPrice -= from.Backpack.ConsumeUpTo(typeof(Gold), leftPrice);
                    }

                    if (leftPrice > 0)
                    {
                        Banker.Withdraw(from, leftPrice);
                    }

                    /* BEGIN TRANSACTION TAX */
                    int    goldAfterCharge = 0;
                    double amountToCharge  = 0;
                    amountToCharge  = (double)this.m_VI.Price * m_Vendor.ChargePerTransaction;
                    goldAfterCharge = this.m_VI.Price - (int)amountToCharge;

                    this.m_Vendor.HoldGold += goldAfterCharge; //this.m_VI.Price;

                    from.SendLocalizedMessage(503201);         // You take the item.
                }
            }
            else
            {
                from.SendLocalizedMessage(503207); // Cancelled purchase.
            }
        }
예제 #53
0
        public void PlacementWarning_Callback(Mobile from, bool okay, object state)
        {
            if (!from.CheckAlive() || from.Backpack == null || from.Backpack.FindItemByType(typeof(HousePlacementTool)) == null)
            {
                return;
            }

            PreviewHouse prevHouse = (PreviewHouse)state;

            if (!okay)
            {
                prevHouse.Delete();
                return;
            }

            if (prevHouse.Deleted)
            {
                /* Too much time has passed and the test house you created has been deleted.
                 * Please try again!
                 */
                from.SendGump(new NoticeGump(1060637, 30720, 1060647, 32512, 320, 180, null, null));

                return;
            }

            Point3D center = prevHouse.Location;
            Map     map    = prevHouse.Map;

            prevHouse.Delete();

            ArrayList toMove;
            //Point3D center = new Point3D( p.X - m_Offset.X, p.Y - m_Offset.Y, p.Z - m_Offset.Z );
            HousePlacementResult res = HousePlacement.Check(from, this.m_MultiID, center, out toMove);

            switch (res)
            {
            case HousePlacementResult.Valid:
            {
                if (from.AccessLevel < AccessLevel.GameMaster && BaseHouse.HasAccountHouse(from))
                {
                    from.SendLocalizedMessage(501271);         // You already own a house, you may not place another!
                }
                else
                {
                    BaseHouse house = this.ConstructHouse(from);

                    if (house == null)
                    {
                        return;
                    }

                    house.Price = this.m_Cost;

                    if (from.AccessLevel >= AccessLevel.GameMaster)
                    {
                        from.SendMessage("{0} gold would have been withdrawn from your bank if you were not a GM.", this.m_Cost.ToString());
                    }
                    else
                    {
                        if (Banker.Withdraw(from, this.m_Cost))
                        {
                            from.SendLocalizedMessage(1060398, this.m_Cost.ToString());         // ~1_AMOUNT~ gold has been withdrawn from your bank box.
                        }
                        else
                        {
                            house.RemoveKeys(from);
                            house.Delete();
                            from.SendLocalizedMessage(1060646);         // You do not have the funds available in your bank box to purchase this house.  Try placing a smaller house, or adding gold or checks to your bank box.
                            return;
                        }
                    }

                    house.MoveToWorld(center, from.Map);

                    for (int i = 0; i < toMove.Count; ++i)
                    {
                        object o = toMove[i];

                        if (o is Mobile)
                        {
                            ((Mobile)o).Location = house.BanLocation;
                        }
                        else if (o is Item)
                        {
                            ((Item)o).Location = house.BanLocation;
                        }
                    }
                }

                break;
            }

            case HousePlacementResult.BadItem:
            case HousePlacementResult.BadLand:
            case HousePlacementResult.BadStatic:
            case HousePlacementResult.BadRegionHidden:
            case HousePlacementResult.NoSurface:
            {
                from.SendLocalizedMessage(1043287);         // The house could not be created here.  Either something is blocking the house, or the house would not be on valid terrain.
                break;
            }

            case HousePlacementResult.BadRegion:
            {
                from.SendLocalizedMessage(501265);         // Housing cannot be created in this area.
                break;
            }

            case HousePlacementResult.BadRegionTemp:
            {
                from.SendLocalizedMessage(501270);         // Lord British has decreed a 'no build' period, thus you cannot build this house at this time.
                break;
            }

            case HousePlacementResult.BadRegionRaffle:
            {
                from.SendLocalizedMessage(1150493);         // You must have a deed for this plot of land in order to build here.
                break;
            }

            case HousePlacementResult.InvalidCastleKeep:
            {
                from.SendLocalizedMessage(1061122);         // Castles and keeps cannot be created here.
                break;
            }
            }
        }
예제 #54
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;

            from.CloseGump <ResurrectGump>();

            if (info.ButtonID == 2)
            {
                if (from.Map == null || !from.Map.CanFit(from.Location, 16, false, false))
                {
                    from.SendLocalizedMessage(502391);                       // Thou can not be resurrected there!
                    return;
                }

                if (m_Price > 0)
                {
                    if (info.IsSwitched(1))
                    {
                        if (Banker.Withdraw(from, m_Price))
                        {
                            from.SendLocalizedMessage(1060398, m_Price.ToString());                               // ~1_AMOUNT~ gold has been withdrawn from your bank box.
                            from.SendLocalizedMessage(1060022, Banker.GetBalance(from).ToString());               // You have ~1_AMOUNT~ gold in cash remaining in your bank box.
                        }
                        else
                        {
                            from.SendLocalizedMessage(1060020);                               // Unfortunately, you do not have enough cash in your bank to cover the cost of the healing.
                            return;
                        }
                    }
                    else
                    {
                        from.SendLocalizedMessage(1060019);                           // You decide against paying the healer, and thus remain dead.
                        return;
                    }
                }

                from.PlaySound(0x214);

                from.Resurrect(m_Healer);

                if (from is PlayerMobile)
                {
                    ((PlayerMobile)from).CheckKRStartingQuestStep(26);
                }

                if (m_Healer != null && from != m_Healer)
                {
                    VirtueLevel level = VirtueHelper.GetLevel(m_Healer, VirtueName.Compassion);

                    switch (level)
                    {
                    case VirtueLevel.Seeker:
                        from.Hits = AOS.Scale(from.HitsMax, 20);
                        break;

                    case VirtueLevel.Follower:
                        from.Hits = AOS.Scale(from.HitsMax, 40);
                        break;

                    case VirtueLevel.Knight:
                        from.Hits = AOS.Scale(from.HitsMax, 80);
                        break;
                    }
                }

                if (m_FromSacrifice && from is PlayerMobile)
                {
                    ((PlayerMobile)from).AvailableResurrects -= 1;

                    Container pack   = from.Backpack;
                    Container corpse = from.Corpse;

                    if (pack != null && corpse != null)
                    {
                        ArrayList items = new ArrayList(corpse.Items);

                        for (int i = 0; i < items.Count; ++i)
                        {
                            Item item = (Item)items[i];

                            if (item.Movable && item.LootType != LootType.Cursed)
                            {
                                pack.DropItem(item);
                            }
                        }
                    }
                }

                if (from.Fame > 0)
                {
                    int amount = from.Fame / 10;

                    Misc.Titles.AwardFame(from, -amount, true);
                }
            }
        }
예제 #55
0
 public Advance(Board board, Banker banker, Int32 spaceIndex)
 {
     this.board = board;
     this.banker = banker;
     this.spaceIndex = spaceIndex;
 }
예제 #56
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;

            if (!m_Vendor.CanInteractWith(from, false))
            {
                return;
            }

            if (m_Vendor.IsOwner(from))
            {
                m_Vendor.SayTo(from, 503212);                   // You own this shop, just take what you want.
                return;
            }

            if (info.ButtonID == 1)
            {
                if (!m_VI.Valid || !m_VI.Item.IsChildOf(m_Vendor.Backpack))
                {
                    m_Vendor.SayTo(from, 503216);                       // You can't buy that.
                    return;
                }

                int totalGold = 0;

                if (from.Backpack != null)
                {
                    totalGold += from.Backpack.GetAmount(typeof(Gold));
                }

                totalGold += Banker.GetBalance(from);

                if (totalGold < m_VI.Price)
                {
                    m_Vendor.SayTo(from, 503205);                       // You cannot afford this item.
                }
                else if (!from.PlaceInBackpack(m_VI.Item))
                {
                    m_Vendor.SayTo(from, 503204);                       // You do not have room in your backpack for this.
                }
                else
                {
                    int leftPrice = m_VI.Price;

                    if (from.Backpack != null)
                    {
                        leftPrice -= from.Backpack.ConsumeUpTo(typeof(Gold), leftPrice);
                    }

                    if (leftPrice > 0)
                    {
                        Banker.Withdraw(from, leftPrice);
                    }

                    m_Vendor.HoldGold += m_VI.Price;

                    from.SendLocalizedMessage(503201);                       // You take the item.
                }
            }
            else
            {
                from.SendLocalizedMessage(503207);                   // Cancelled purchase.
            }
        }
예제 #57
0
        public static void loadGlobalList()
        {
            if (!System.IO.File.Exists(xmlSchema))
            {
                Console.WriteLine("Could not open {0}.", xmlSchema);
                Console.WriteLine("{0} must be in .\\Data\\Bounty System", xmlSchema);
                Console.WriteLine("Cannot save bounties.");
                return;
            }

            if (!System.IO.File.Exists(xmlFile))
            {
                Console.WriteLine("Could not open {0}.", xmlFile);
                Console.WriteLine("{0} must be in .\\Data\\Bounty System", xmlFile);
                Console.WriteLine("This is okay if this is the first run after installation of the Bounty system.");
                return;
            }

            DataSet ds = new DataSet();

            try
            {
                ds.ReadXmlSchema(xmlSchema);
                ds.ReadXml(xmlFile);
            }
            catch
            {
                Console.WriteLine("Error reading {0}.  File may be corrupt.", xmlFile);
                return;
            }

            Mobile           Owner     = null;
            Mobile           Wanted    = null;
            Mobile           requested = null;
            Mobile           accepted  = null;
            int              price;
            DateTime         expireTime;
            BountyBoardEntry entry;

            foreach (DataRow bountyRow in ds.Tables["Bounty"].Rows)
            {
                foreach (DataRow childRow in bountyRow.GetChildRows("Bounty_Owner"))
                {
                    Owner = World.FindMobile((int)childRow["Serial"]);
                }

                if (Owner == null || Owner.Deleted || !(Owner is PlayerMobile))
                {
                    continue;
                }

                foreach (DataRow childRow in bountyRow.GetChildRows("Bounty_Wanted"))
                {
                    Wanted = World.FindMobile((int)childRow["Serial"]);
                }

                price      = (int)bountyRow["Price"];
                expireTime = (DateTime)bountyRow["ExpireTime"];

                entry = new BountyBoardEntry(Owner, Wanted, price, expireTime);

                foreach (DataRow childRow in bountyRow.GetChildRows("Bounty_requested"))
                {
                    requested = World.FindMobile((int)childRow["Serial"]);
                    if (requested != null && !requested.Deleted && requested is PlayerMobile)
                    {
                        entry.Requested.Add(requested);
                    }
                }

                foreach (DataRow childRow in bountyRow.GetChildRows("Bounty_accepted"))
                {
                    accepted = World.FindMobile((int)childRow["Serial"]);
                    if (accepted != null && !accepted.Deleted && accepted is PlayerMobile)
                    {
                        entry.Accepted.Add(accepted);
                    }
                }

                if (!entry.Expired)
                {
                    BountyBoard.AddEntry(entry);
                }
                else
                {
                    NotifyBountyEnd(entry);
                    if (!Banker.Deposit(entry.Owner, price))
                    {
                        entry.Owner.AddToBackpack(new Gold(price));
                    }
                }

                if (Wanted == null || Wanted.Deleted || !(Wanted is PlayerMobile))
                {
                    BountyBoard.RemoveEntry(entry, true);
                }
            }
        }
예제 #58
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Account acct = User.Account as Account;

            switch (info.ButtonID)
            {
            case 0: break;

            case 1:
                User.SendLocalizedMessage(1155866);     // Enter amount to withdraw:
                User.BeginPrompt(
                    (from, text, ac) =>
                {
                    int v    = 0;
                    double z = 0;

                    if (ac != null)
                    {
                        if (text != null && !String.IsNullOrEmpty(text))
                        {
                            v = Utility.ToInt32(text);

                            if (ac != null)
                            {
                                if (v <= 0 || v > from.TotalGold)
                                {
                                    from.SendLocalizedMessage(
                                        1155867);         // The amount entered is invalid. Verify that there are sufficient funds to complete this transaction.
                                }
                                else
                                {
                                    Item[] gold, checks;
                                    var balance = Banker.GetBalance(from, out gold, out checks);
                                    Gold Golds  = new Gold();
                                    var golds   = from.Backpack.FindItemsByType <Gold>(true);



                                    Console.WriteLine(golds.Count);
                                    Console.WriteLine(golds);


                                    if (balance < v)
                                    {
                                        from.SendLocalizedMessage(3000285);
                                    }

                                    Banker.Deposit(from, v, true);
                                    // ((PlayerMobile) from).AccountSovereigns;

                                    for (var i = 0; v > 0 && i < golds.Count; ++i)
                                    {
                                        if (golds[i].Amount <= v)
                                        {
                                            v -= golds[i].Amount;
                                            golds[i].Delete();
                                        }
                                        else
                                        {
                                            golds[i].Amount -= v;
                                            v = 0;
                                        }
                                    }

                                    from.SendLocalizedMessage(1153188);         // Transaction successful:
                                }

                                Timer.DelayCall(TimeSpan.FromSeconds(2), SendGump);
                            }
                        }
                        else
                        {
                            from.SendLocalizedMessage(
                                1155867);         // The amount entered is invalid. Verify that there are sufficient funds to complete this transaction.
                        }
                    }
                },
                    (from, text, act) =>
                {
                    User.SendLocalizedMessage(
                        1155867);         // The amount entered is invalid. Verify that there are sufficient funds to complete this transaction.
                    User.SendGump(new BankerGump(User));
                }, acct);
                break;

            case 2: break;

            case 3:
                User.SendLocalizedMessage(1155866);     // Enter amount to withdraw:
                User.BeginPrompt(
                    (from, text, ac) =>
                {
                    int v    = 0;
                    double z = 0;

                    if (ac != null)
                    {
                        if (text != null && !String.IsNullOrEmpty(text))
                        {
                            v = Utility.ToInt32(text);

                            if (ac != null)
                            {
                                if (v <= 0 || v > Banker.GetBalance(from))
                                {
                                    from.SendLocalizedMessage(
                                        1155867);         // The amount entered is invalid. Verify that there are sufficient funds to complete this transaction.
                                }
                                else
                                {
                                    Banker.Withdraw(from, v, true);

                                    Item backpack = from.FindItemOnLayer(Layer.Backpack);
                                    Gold gold     = new Gold();
                                    gold.Amount   = v;

                                    backpack.AddItem(gold);


                                    from.SendLocalizedMessage(1153188);         // Transaction successful:
                                }

                                Timer.DelayCall(TimeSpan.FromSeconds(2), SendGump);
                            }
                        }
                        else
                        {
                            from.SendLocalizedMessage(
                                1155867);         // The amount entered is invalid. Verify that there are sufficient funds to complete this transaction.
                        }
                    }
                },
                    (from, text, act) =>
                {
                    User.SendLocalizedMessage(
                        1155867);         // The amount entered is invalid. Verify that there are sufficient funds to complete this transaction.
                    User.SendGump(new BankerGump(User));
                }, acct);
                break;

            case 4:
                break;

            case 5:
                User.SendLocalizedMessage(1155865);     // Enter amount to deposit:
                User.BeginPrompt <Account>(
                    (from, text, account) =>
                {
                    int v = 0;

                    if (account != null)
                    {
                        int canHold = Account.MaxSecureAmount - account.GetSecureAccountAmount(from);

                        if (text != null && !String.IsNullOrEmpty(text))
                        {
                            v = Utility.ToInt32(text);

                            if (v <= 0 || v > canHold || v > Banker.GetBalance(from))
                            {
                                from.SendLocalizedMessage(
                                    1155867);         // The amount entered is invalid. Verify that there are sufficient funds to complete this transaction.
                            }
                            else if (account != null)
                            {
                                if (v > canHold)
                                {
                                    v = canHold;
                                }

                                Banker.Withdraw(from, v, true);
                                account.DepositToSecure(from, v);

                                from.SendLocalizedMessage(1153188);         // Transaction successful:

                                Timer.DelayCall(TimeSpan.FromSeconds(2), SendGump);
                            }
                        }
                        else
                        {
                            from.SendLocalizedMessage(
                                1155867);         // The amount entered is invalid. Verify that there are sufficient funds to complete this transaction.
                        }
                    }
                },
                    (from, text, a) =>
                {
                    User.SendLocalizedMessage(
                        1155867);         // The amount entered is invalid. Verify that there are sufficient funds to complete this transaction.
                    User.SendGump(new BankerGump(User));
                }, acct);
                break;

            case 6:
                User.SendLocalizedMessage(1155866);     // Enter amount to withdraw:
                User.BeginPrompt(
                    (from, text, ac) =>
                {
                    int v = 0;

                    if (ac != null)
                    {
                        if (text != null && !String.IsNullOrEmpty(text))
                        {
                            v = Utility.ToInt32(text);

                            if (ac != null)
                            {
                                if (v <= 0 || v > acct.GetSecureAccountAmount(from))
                                {
                                    from.SendLocalizedMessage(
                                        1155867);         // The amount entered is invalid. Verify that there are sufficient funds to complete this transaction.
                                }
                                else
                                {
                                    Banker.Deposit(from, v, true);
                                    ac.WithdrawFromSecure(from, v);

                                    from.SendLocalizedMessage(1153188);         // Transaction successful:
                                }

                                Timer.DelayCall(TimeSpan.FromSeconds(2), SendGump);
                            }
                        }
                        else
                        {
                            from.SendLocalizedMessage(
                                1155867);         // The amount entered is invalid. Verify that there are sufficient funds to complete this transaction.
                        }
                    }
                },
                    (from, text, act) =>
                {
                    User.SendLocalizedMessage(
                        1155867);         // The amount entered is invalid. Verify that there are sufficient funds to complete this transaction.
                    User.SendGump(new BankerGump(User));
                }, acct);
                break;

            case 7:
                User.CloseGump(typeof(NewCurrencyHelpGump));
                User.SendGump(new NewCurrencyHelpGump());
                Refresh();
                break;

            // 1kk check
            case 8:
                if (Banker.GetBalance(User) >= 1000000)
                {
                    Banker.Withdraw(User, 1000000, true);

                    Item     backpack = User.FindItemOnLayer(Layer.Backpack);
                    Check1kk check1kk = new Check1kk();
                    check1kk.Amount = 1;
                    backpack.AddItem(check1kk);

                    User.SendMessage("Вы получили чек.");
                }
                else
                {
                    User.SendMessage("Вам не хватает gold.");
                }
                Refresh();
                break;

            // 500k check
            case 9:
                if (Banker.GetBalance(User) >= 500000)
                {
                    Banker.Withdraw(User, 500000, true);

                    Item      backpack  = User.FindItemOnLayer(Layer.Backpack);
                    Check500k check500k = new Check500k();
                    check500k.Amount = 1;
                    backpack.AddItem(check500k);

                    User.SendMessage("Вы получили чек.");
                }
                else
                {
                    User.SendMessage("Вам не хватает gold.");
                }
                Refresh();
                break;

            // 200k check
            case 10:
                if (Banker.GetBalance(User) >= 200000)
                {
                    Banker.Withdraw(User, 200000, true);

                    Item      backpack  = User.FindItemOnLayer(Layer.Backpack);
                    Check200k check200k = new Check200k();
                    check200k.Amount = 1;
                    backpack.AddItem(check200k);

                    User.SendMessage("Вы получили чек.");
                }
                else
                {
                    User.SendMessage("Вам не хватает gold.");
                }
                Refresh();
                break;

            // 100k check
            case 11:
                if (Banker.GetBalance(User) >= 100000)
                {
                    Banker.Withdraw(User, 100000, true);

                    Item      backpack  = User.FindItemOnLayer(Layer.Backpack);
                    Check100k check100k = new Check100k();
                    check100k.Amount = 1;
                    backpack.AddItem(check100k);

                    User.SendMessage("Вы получили чек.");
                }
                else
                {
                    User.SendMessage("Вам не хватает gold.");
                }
                Refresh();
                break;
            }
        }