Exemplo n.º 1
0
        public async Task <int> PromptBorrow(int MaxLoan)
        {
            var window2 = new TextWindow {
                Location = new Point(8, 7)
            };

            window2.WriteLine("We'd be happy to loan you");
            window2.WriteLine("money at 'friendly' rates");

            var window3 = new TextWindow {
                Location = new Point(7, 11)
            };

            window3.Write("You may borrow up to ");
            window3.Write(MaxLoan.ToString());
            window3.WriteLine(" gold");

            await TextArea.PrintLine();

            await TextArea.PrintLine("Borrow how much?");

            Screen.AddWindow(window2);
            Screen.AddWindow(window3);

            return(await ChooseNumber(MaxLoan));
        }
Exemplo n.º 2
0
        private void SetWindow(double cost)
        {
            Screen.ClearWindows();

            var promptWindow = new TextWindow();

            promptWindow.Location = new Point(9, 4);

            promptWindow.WriteLine("    Food & water");
            promptWindow.WriteLine();
            promptWindow.WriteLine();
            promptWindow.WriteLine("We sell food for travel.");
            promptWindow.WriteLine("Each 'day' of food will ");
            promptWindow.WriteLine("keep you fed for one day");
            promptWindow.WriteLine("of travel (on foot).    ");
            promptWindow.WriteLine();
            promptWindow.WriteLine();

            if (robbing == false)
            {
                promptWindow.Write("Cost is ");
                promptWindow.Write(cost.ToString());
                promptWindow.WriteLine(" gold per 'day'");
            }
            else
            {
                promptWindow.WriteLine("Robbery in progress");
            }

            promptWindow.SetColor(XleColor.Yellow);

            Screen.AddWindow(promptWindow);
        }
Exemplo n.º 3
0
        private void SetDescriptionText()
        {
            TextWindow window = new TextWindow();

            window.Location = new Point(7, 3);
            window.WriteLine("Our sect offers restorative");
            window.WriteLine("    cures for your wounds.");

            Screen.AddWindow(window);
        }
Exemplo n.º 4
0
        private void InitializeOfferWindow()
        {
            TextWindow offerText = new TextWindow();

            offerText.Location = new Point(2, 16);

            Screen.AddWindow(offerText);

            OfferWindow.TextWindow = offerText;
        }
Exemplo n.º 5
0
        public void InitializeWindow()
        {
            Screen.ClearWindows();

            Title = "Friendly";

            var window1 = new TextWindow {
                Location = new Point(10, 2), Text = "Lending Association"
            };

            Screen.AddWindow(window1);
        }
Exemplo n.º 6
0
        public async Task <int> PaymentPrompt(int debt, int timeLeft, int minPayment, int maxPayment)
        {
            string dueDate;

            if (timeLeft > 0)
            {
                dueDate = timeLeft + " days ";
            }
            else
            {
                dueDate = "NOW!!";
            }

            var window2 = new TextWindow {
                Location = new Point(11, 7)
            };

            window2.WriteLine("You owe:  " + debt + " gold!");
            window2.WriteLine();
            window2.WriteLine();
            window2.WriteLine("Due Date: " + dueDate);

            Screen.AddWindow(window2);

            await TextArea.PrintLine();

            await TextArea.Print("Pay how much? ");

            if (minPayment > 0)
            {
                await TextArea.Print("(At Least " + minPayment + " gold)", XleColor.Yellow);
            }

            await TextArea.PrintLine();

            return(await ChooseNumber(maxPayment));
        }
Exemplo n.º 7
0
        private void SetOptionsText(int woundPrice, int herbsPrice)
        {
            TextWindow window = new TextWindow();

            window.Location = new Point(3, 9);

            window.Write("1. Wound Care  -  ");

            if (woundPrice <= 0)
            {
                window.WriteLine("Not needed", XleColor.Yellow);
            }
            else
            {
                window.WriteLine(woundPrice + " gold");
            }

            window.WriteLine();
            window.WriteLine();

            window.WriteLine("2. Healing Herbs -  " + herbsPrice + " apiece");

            Screen.AddWindow(window);
        }
Exemplo n.º 8
0
 public StoreEquipmentExtender()
 {
     Screen.AddWindow(titlePrompt);
     Screen.AddWindow(itemsPrompt);
     Screen.AddWindow(inventoryDisplay);
 }
Exemplo n.º 9
0
        protected override async Task <bool> SpeakImplAsync()
        {
            int choice;

            robbing = false;

            Screen.ClearWindows();

            Title = "Convenience Bank";

            var promptWindow = new TextWindow();

            promptWindow.Location = new Point(14, 3);
            promptWindow.WriteLine("Our Services");
            promptWindow.WriteLine("---------------");

            var optionsWindow = new TextWindow();

            optionsWindow.Location = new Point(10, 7);

            optionsWindow.WriteLine("1.  Deposit Funds");
            optionsWindow.WriteLine();
            optionsWindow.WriteLine("2.  Withdraw Funds");
            optionsWindow.WriteLine();
            optionsWindow.WriteLine("3.  Balance Inquiry");

            Screen.AddWindow(promptWindow);
            Screen.AddWindow(optionsWindow);

            await TextArea.PrintLine();

            await TextArea.PrintLine();

            await TextArea.PrintLine("Make choice (Hit 0 to cancel)");

            await TextArea.PrintLine();

            MenuItemList theList = new MenuItemList("0", "1", "2", "3");

            choice = await QuickMenuService.QuickMenu(theList, 2, 0);

            switch (choice)
            {
            case 1:
                await MakeDeposit();

                break;

            case 2:
                await MakeWithdrawal();

                break;

            case 3:
                await PrintBalance();

                break;
            }


            return(true);
        }
Exemplo n.º 10
0
        private async Task RunStore()
        {
            int i = 0;
            int choice;
            int amount;

            robbing = false;

            Screen.ClearWindows();
            Title = TheEvent.ShopName;

            var wind = new TextWindow();

            wind.Location = new Point(9, 4);

            wind.WriteLine("I will happily purchase");
            wind.WriteLine("your used arms and armor");

            var prompt = new TextWindow();

            prompt.Location = new Point(9, 9);
            prompt.WriteLine("Choose items to sell:");
            prompt.WriteLine();
            prompt.WriteLine(" 1.  Weapons");
            prompt.WriteLine(" 2.  Armor");

            Screen.AddWindow(wind);
            Screen.AddWindow(prompt);

            wind.SetColor(XleColor.Red);
            prompt.SetColor(XleColor.Red);

            await TextArea.PrintLine();

            await TextArea.PrintLine();

            await TextArea.PrintLine("Select (0 to cancel)");

            await TextArea.PrintLine();

            MenuItemList theList = new MenuItemList("0", "1", "2");

            choice = await QuickMenu(theList, 2, 0);

            if (choice == 0)
            {
                return;
            }

            Screen.RemoveWindow(prompt);
            wind.Visible = false;

            ColorScheme.FrameColor             = XleColor.Gray;
            ColorScheme.HorizontalLinePosition = 11;
            Title        = "";
            ShowGoldText = false;

            Equipment item = null;

            TextArea.Clear();

            TextWindow questionWindow = new TextWindow {
                Location = new Point(5, 16)
            };

            Screen.AddWindow(questionWindow);

            switch (choice)
            {
            case 1:
                questionWindow.WriteLine("What weapon will you sell me?");
                item = await EquipmentPicker.PickWeapon(GameState, null, ColorScheme.BackColor);

                break;

            case 2:
                questionWindow.WriteLine("What armor will you sell me?");
                item = await EquipmentPicker.PickArmor(GameState, null, ColorScheme.BackColor);

                break;
            }

            if (item == null)
            {
                return;
            }

            Screen.RemoveWindow(questionWindow);

            ColorScheme.HorizontalLinePosition = 14;
            ColorScheme.TextAreaBackColor      = XleColor.Black;

            Title        = "Buy-back shop";
            wind.Visible = true;
            wind.SetColor(XleColor.White);
            wind.Location = new Point(9, 8);

            var ta = TextArea;

            TextWindow offerText = new TextWindow();

            offerText.Location = new Point(2, 16);

            int charm = Player.Attribute[Attributes.charm];

            charm = Math.Min(charm, 80);

            int maxAccept = (int)(item.Price(Data) * Math.Pow(charm, .7) / 11);
            int offer     = (int)((6 + Random.NextDouble()) * maxAccept / 14.0);

            choice = await MakeOffer(item, offer, false);

            if (choice == 0)
            {
                await CompleteSale(offer, item);

                return;
            }
            int ask = 0;

            Screen.AddWindow(offerText);

            SetOfferText(offerText, offer, ask);

            ask = await GetAskingPrice();

            if (ask == 0)
            {
                await ta.PrintLine("\n\n\n\nSee you later.\n");

                return;
            }
            if (ask < 1.5 * offer)
            {
                await CompleteSale(ask, item);

                return;
            }

            int spread = maxAccept - offer;

            if (ask > spread + maxAccept)
            {
                await ComeBackWhenSerious();

                return;
            }

            spread = ask - offer;
            double scale = maxAccept / (double)spread;

            offer     = (int)(offer + (1 + Random.NextDouble() * 5) * scale);
            maxAccept = spread;

            if (offer >= ask)
            {
                offer = ask - 1;
            }

            int lastAsk = ask;

            do
            {
                bool finalOffer = false;

                SetAskRejectPrice(offerText, ask, WayTooHigh(ask, offer, maxAccept));
                choice = await MakeOffer(item, offer, finalOffer);

                if (choice == 0)
                {
                    await CompleteSale(offer, item);

                    return;
                }
                else if (finalOffer)
                {
                    await MaybeDealLater();

                    return;
                }

                SetOfferText(offerText, offer, lastAsk);
                ask = await GetAskingPrice();

                if (ask == 0)
                {
                    await MaybeDealLater();

                    return;
                }

                if (ask == lastAsk ||
                    (ask > lastAsk && Random.NextDouble() < 0.5))
                {
                    await ComeBackWhenSerious();

                    return;
                }

                double diff = lastAsk - ask;
                if (diff == 0)
                {
                    diff = Random.NextDouble() * 3;
                }

                if (diff / maxAccept < 0.03)
                {
                    diff /= 1.3;
                }

                lastAsk = ask;
                spread  = (int)(offer + diff / 1.2 + Random.NextDouble() * diff / 1.6);

                if (spread > ask - 2 && Random.NextDouble() < .5)
                {
                    await CompleteSale(ask, item);

                    return;
                }
                if (spread >= ask)
                {
                    finalOffer = true;
                }
                else
                {
                    offer = spread;

                    if (ask - offer < 3)
                    {
                        finalOffer = true;
                    }

                    if (offer <= 0)
                    {
                        await ComeBackWhenSerious();

                        return;
                    }
                }
            } while (true);
        }
Exemplo n.º 11
0
        private async Task RunStore()
        {
            robbing = false;

            Screen.ClearWindows();
            Title = TheEvent.ShopName;

            var wind = new TextWindow();

            wind.Location = new Point(9, 4);

            wind.WriteLine("I will happily purchase");
            wind.WriteLine("your used arms and armor");

            var prompt = new TextWindow();

            prompt.Location = new Point(9, 9);
            prompt.WriteLine("Choose items to sell:");
            prompt.WriteLine();
            prompt.WriteLine(" 1.  Weapons");
            prompt.WriteLine(" 2.  Armor");

            Screen.AddWindow(wind);
            Screen.AddWindow(prompt);

            wind.SetColor(XleColor.Red);
            prompt.SetColor(XleColor.Red);

            await BuybackFormatter.InitialMenuPrompt();

            MenuItemList theList = new MenuItemList("0", "1", "2");
            int          choice  = await QuickMenu(theList, 2, 0);

            if (choice == 0)
            {
                return;
            }

            Screen.RemoveWindow(prompt);
            wind.Visible = false;

            ColorScheme.FrameColor             = XleColor.Gray;
            ColorScheme.HorizontalLinePosition = 11;
            Title        = "";
            ShowGoldText = false;

            Equipment item = null;

            TextArea.Clear();

            TextWindow questionWindow = new TextWindow {
                Location = new Point(5, 16)
            };

            Screen.AddWindow(questionWindow);

            switch (choice)
            {
            case 1:
                questionWindow.WriteLine("What weapon will you sell me?");
                item = await EquipmentPicker.PickWeapon(GameState, null, ColorScheme.BackColor);

                break;

            case 2:
                questionWindow.WriteLine("What armor will you sell me?");
                item = await EquipmentPicker.PickArmor(GameState, null, ColorScheme.BackColor);

                break;
            }

            if (item == null)
            {
                return;
            }

            Screen.RemoveWindow(questionWindow);

            wind.Visible = true;
            wind.SetColor(XleColor.White);
            wind.Location = new Point(9, 8);

            ColorScheme.HorizontalLinePosition = 14;
            ColorScheme.TextAreaBackColor      = XleColor.Black;

            Title = "Buy-back shop";

            InitializeOfferWindow();

            await Negotiator.NegotiatePrice(item);
        }
Exemplo n.º 12
0
        protected override async Task <bool> SpeakImplAsync()
        {
            Screen.ClearWindows();

            foreach (var window in CreateStoreWindows())
            {
                Screen.AddWindow(window);
            }

            Title = TheEvent.ShopName;

            TextArea.Clear();
            await TextArea.PrintLine("Make choice (hit 0 to cancel)");

            await TextArea.PrintLine();

            IEnumerable <MagicSpell> magicSpells = AvailableSpells;

            int choice = await QuickMenu(MenuItemList.Numbers(0, magicSpells.Count()), 2);

            if (choice == 0)
            {
                await NothingPurchased("Nothing purchased.");

                return(true);
            }

            var item = magicSpells.ToArray()[choice - 1];

            int maxCarry    = item.MaxCarry - Player.Items[item.ItemID];
            int maxAfford   = Player.Gold / MagicPrice(item);
            int maxPurchase = Math.Min(maxCarry, maxAfford);

            if (maxAfford <= 0)
            {
                await NothingPurchased("You can't afford any " + item.PluralName + ".");

                return(true);
            }

            if (Options.EnhancedUserInterface)
            {
                if (maxCarry == 0)
                {
                    await NothingPurchased("You can't buy any more " + item.PluralName + ".");

                    return(true);
                }
            }
            else
            {
                maxPurchase = maxAfford;
            }

            await TextArea.PrintLine();

            await TextArea.PrintLine("Purchase how many " + item.PluralName + "?");

            int purchaseCount = await ChooseNumber(maxPurchase);

            if (purchaseCount == 0)
            {
                await NothingPurchased("Nothing purchased.");

                return(true);
            }

            if (Player.Items[item.ItemID] + purchaseCount > item.MaxCarry)
            {
                await NothingPurchased("You can't buy this many.");

                return(true);
            }

            int cost = purchaseCount * MagicPrice(choice);

            if (cost > Player.Gold)
            {
                await NothingPurchased("You're short on gold.");

                return(true);
            }

            Player.Items[item.ItemID] += purchaseCount;
            Player.Gold -= purchaseCount * MagicPrice(choice);

            TextArea.Clear();
            await TextArea.PrintLine(" " + purchaseCount.ToString() + " " +
                                     ((purchaseCount != 1) ? item.PluralName : item.Name) + " purchased.");

            await TextArea.PrintLine();

            await StoreSound(LotaSound.Sale);

            return(true);
        }