Exemple #1
0
        public void Start()
        {
            bool leaveBank = false;

            while (leaveBank == false)
            {
                BankIntro();

                var Awnser = theGame.GetLowerReply();
                switch (Awnser)
                {
                case "d":
                case "deposit":
                    BankDeposit();
                    break;

                case "w":
                case "withdrawal":
                    BankWithdrawal();
                    break;

                case "l":
                    leaveBank = true;
                    break;

                default:
                    TypeWriter.WriteLine("Sorry, but I don't understand");
                    break;
                }
            }
        }
Exemple #2
0
 internal void displayItems()
 {
     foreach (var item in items)
     {
         TypeWriter.WriteLine("\t" + item.firstDescription);
     }
 }
Exemple #3
0
 internal void displayDescription()
 {
     foreach (var line in descriptions)
     {
         TypeWriter.WriteLine("\t" + line);
     }
 }
Exemple #4
0
 private void BankIntro()
 {
     TypeWriter.WriteLine(new Text("Hello would you like to make a ", Colours.Speech, TypeWriter.Speed.Talk),
                          new Text("(d)deposit ", Colours.Deposit, TypeWriter.Speed.Talk),
                          new Text("or make a ", Colours.Speech, TypeWriter.Speed.Talk),
                          new Text("(w)withdrawal", Colours.Withdrawal, TypeWriter.Speed.Talk));
     TypeWriter.WriteLine(new Text("or l to leave", Colours.Speech, TypeWriter.Speed.Talk));
 }
Exemple #5
0
        private void BankWithdrawal()
        {
            bool leave = false;

            while (leave == false)
            {
                int withdrawNumber;

                if (balance > 0)
                {
                    TypeWriter.WriteLine(new Text("You have "),
                                         new Text($"{balance} gold ", Colours.Gold),
                                         new Text("in your account"));
                    TypeWriter.WriteLine();
                }

                TypeWriter.WriteLine("How much gold would you like to withdraw?");
                TypeWriter.WriteLine("or l to leave");
                var withdrawAmount = theGame.GetLowerReply();
                if (withdrawAmount == "l")
                {
                    leave = true;
                    TypeWriter.WriteLine();
                    continue;
                }

                try
                {
                    withdrawNumber = int.Parse(withdrawAmount);
                }
                catch (Exception)
                {
                    TypeWriter.WriteLine("Sorry but only numbers are valid", TypeWriter.Speed.Talk);
                    TypeWriter.WriteLine();
                    Thread.Sleep(1000);
                    continue;
                }

                if (balance >= withdrawNumber)
                {
                    balance            -= withdrawNumber;
                    theGame.playerGold += withdrawNumber;

                    TypeWriter.WriteLine($"Your withdrawal of {withdrawNumber} gold has been made");
                    TypeWriter.WriteLine();
                }
                else
                {
                    TypeWriter.WriteLine("Sorry, but you don't have that amount in your account");
                    TypeWriter.WriteLine();
                }
            }
        }
Exemple #6
0
 internal override bool ItemPriceDecisions(TheGame game)
 {
     if (game.playerGold < price)
     {
         TypeWriter.WriteLine("Sorry but you don't have the required gold");
         return(false);
     }
     else
     {
         game.playerGold -= price;
         return(true);
     }
 }
Exemple #7
0
        internal Location GetNextLocation(string playerDirection)
        {
            string message;

            switch (playerDirection)
            {
            case "north":
            {
                if (northLocation != "")
                {
                    return(new Location(northLocation));
                }
                message = northMessage; break;
            }

            case "south":
            {
                if (southLocation != "")
                {
                    return(new Location(southLocation));
                }
                message = southMessage; break;
            }

            case "east":
            {
                if (eastLocation != "")
                {
                    return(new Location(eastLocation));
                }
                message = eastMessage; break;
            }

            case "west":
            {
                if (westLocation != "")
                {
                    return(new Location(westLocation));
                }
                message = westMessage; break;
            }

            default: message = "you can't go there"; break;
            }

            TypeWriter.WriteLine(message);
            return(this);
        }
Exemple #8
0
        internal override bool DoVerb(string verb, TheGame game)
        {
            if (isSynonymFor(verb, "eat"))
            {
                TypeWriter.WriteLine();
                TypeWriter.WriteLine(new Text($"You {verb} the "),
                                     name,
                                     new Text(" and it feels good"));
                game.playerHP += healing;
                TypeWriter.WriteLine();
                game.playerStats();
                return(true);
            }

            return(false);
        }
Exemple #9
0
 internal Item?tryTakeItem(string itemName, TheGame game)
 {
     if (items.Exists(e => e.name.text == itemName))
     {
         Item item = items.Find(e => e.name.text == itemName);
         if (item.ItemPriceDecisions(game))
         {
             items.Remove(item);
             return(item);
         }
     }
     else
     {
         TypeWriter.WriteLine($"There is no {itemName} here ?");
     }
     return(null);
 }