예제 #1
0
파일: Shop.cs 프로젝트: james-d12/Text-RPG
        public static void Shop_Purchase(Player _player, Friendly _Merchant, string sentence01, string sentence02)
        {
            int           x          = 0;
            List <string> item_names = new List <string>();
            string        itemchoice;

            Console.Clear();
            Draw_UI.Draw_UI_Shop_Buy(_Merchant, _player);
            Console.WriteLine("Back - (Type 'back')");
            while (x < _Merchant.NPC_Inventory.Count())
            {
                do
                {
                    Console.Write("Purchase Item:  ");
                    itemchoice = Console.ReadLine();
                } while (itemchoice.Any(char.IsLetter) == false);
                if (itemchoice == "Back" || itemchoice == "back" || itemchoice == "BACK")
                {
                    Shop_Show_Items(_player, _Merchant, sentence01, sentence02);
                }
                else
                {
                    foreach (Item item in _Merchant.NPC_Inventory)
                    {
                        item_names.Add(item.Item_Name);
                    }
                    if (item_names.Contains(itemchoice))
                    {
                        foreach (Item item in _Merchant.NPC_Inventory)
                        {
                            if (itemchoice == item.Item_Name)
                            {
                                x = x + 1;
                                if (_player.Char_Gold >= item.Item_Buy)
                                {
                                    Console.WriteLine("You have purchased " + item.Item_Name + " for " + item.Item_Buy + " Gold coins");
                                    Remove_Merchant_Items(_Merchant, itemchoice);
                                    _player.Char_Gold   -= item.Item_Buy;
                                    _Merchant.Shop_Gold += item.Item_Buy;
                                }
                                else
                                {
                                    Console.WriteLine("You do not have enough gold.");
                                }
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("Item not found.");
                    }
                }
            }
        }
예제 #2
0
파일: Shop.cs 프로젝트: james-d12/Text-RPG
        public static void Shop_Show_Items(Player _player, Friendly _Merchant, string sentence01, string sentence02)
        {
            Draw_UI.Draw_UI_Shop_Main(_Merchant, _player);
            string Input;

            do
            {
                Console.Write("Input: ");
                Input = Console.ReadLine();
            } while (Input.All(char.IsDigit) == false);
            switch (Input)
            {
            case "1":
                Shop_Purchase(_player, _Merchant, sentence01, sentence02);
                break;

            case "2":
                Shop_Sell(_Merchant, _player, sentence01, sentence02);
                break;

            case "3":
                break;
            }
        }