예제 #1
0
        public override void InteractWithShopkeep(Shopkeeper protag)
        {
            if (protag.Cart.ProtectionLvl == 0)
            {
                protag.Cart.Gold -= RobAmount;
                Dictionary <Item, int> copy = protag.Cart.Inventory;
                Item itemToTake             = copy.Keys.ElementAt(_rand.Next(0, copy.Count - 1));

                if (itemToTake != null)
                {
                    ConsoleIO.Display($"Rats! You encounter bandits, and they steal {RobAmount} gold and a {itemToTake.Name}!");

                    protag.Cart.RemoveInventoryItem(protag.Cart.Inventory, itemToTake);
                }
                else
                {
                    Console.WriteLine();
                }
            }
            else
            {
                protag.Cart.ProtectionLvl--;
                Console.WriteLine($"Bandits attacked, but they were staved off by your protection! Your cart's protection" +
                                  $" level is now {protag.Cart.ProtectionLvl}");
            }
        }
예제 #2
0
 public static void PrintInventory(Shopkeeper keeper)
 {
     Console.WriteLine("========");
     foreach (var item in keeper.Cart.Inventory)
     {
         Console.WriteLine($"Item: {item.Key.Name}\nValue: {item.Key.Value}\nQuantity: {item.Value}");
         Console.WriteLine("========");
     }
 }
예제 #3
0
 public static void DisplayStats(Shopkeeper keeper)
 {
     Console.WriteLine("****Stats****");
     Console.WriteLine($"Distance Traveled: {keeper.Distance}");
     Console.WriteLine($"Inventory:");
     ConsoleIO.PrintInventory(keeper);
     Console.WriteLine($"Total Gold: {keeper.Cart.Gold}");
     Console.WriteLine("********");
 }
예제 #4
0
        //private const int HAGGLE_CHANCE = 2;
        public override void InteractWithShopkeep(Shopkeeper protag)
        {
            Dictionary <Item, int> copy = protag.Cart.Inventory;
            Item itemToTake             = copy.Keys.ElementAt(_rand.Next(0, copy.Count - 1));

            ConsoleIO.Display($"A traveler appears and is interested in your wears! They offer to buy your {itemToTake.Name}" +
                              $" for its full price of {itemToTake.Value} gold");
            string userChoice = ConsoleIO.PromptString("Do you want to sell this item? [y/n]");

            if (userChoice.ToLower() == "y")
            {
                protag.Cart.Gold += itemToTake.Value;
                ConsoleIO.Display("Sold!");
                protag.Cart.RemoveInventoryItem(protag.Cart.Inventory, itemToTake);
            }
            else
            {
                Console.WriteLine($"You choose not to part with your beloved {itemToTake.Name} and continue on your way.");
            }
        }
예제 #5
0
 public GameEngine(Shopkeeper protag, Encounter encounter)
 {
     this.protag    = protag;
     this.encounter = encounter;
 }
예제 #6
0
 public abstract void InteractWithShopkeep(Shopkeeper protag);