Exemplo n.º 1
0
        //selects which shop you want to visit: Potion, Weapon or Inn
        public static void SelectShop(Entity player)
        {
            string shopChoice = CheckTown();

            if (shopChoice.Contains("potion"))
            {
                PotionShop.VisitPotionShop(player);
            }
            else if (shopChoice.Contains("weapon"))
            {
                WeaponShop.VisitWeaponShop(player);
            }
            else if (shopChoice.Contains("inn"))
            {
                Inn.VisitInn(player);
            }
            else if (shopChoice.Contains("leave"))
            {
                ConsoleEffects.TypeLine("Good luck out there!\r\n");
                ConsoleEffects.PressEnter();
                return;
            }
            else
            {
                SelectShop(player);
            }
        }
Exemplo n.º 2
0
        public static void VisitWeaponShop(Entity player)
        {
            //ConsoleEffects.TypeLine("Welcome to the Potion Shop!\r\n");
            string buySell = Actions.SelectBuySell();

            if (buySell.Contains("buy"))
            {
                CheckGoldToBuy(player, CreateItemSelected(player));
            }
            else if (buySell.Contains("sell"))
            {
                CheckQuantityToSell(player, CheckItemSelected(player));
            }
            else if (buySell.Contains("leave"))
            {
                Actions.SelectShop(player);
            }
            else
            {
                ConsoleEffects.TypeLine("I am sorry.  I do not understand you.");
                Console.Clear();
                VisitWeaponShop(player);
            }
            VisitWeaponShop(player);
        }
Exemplo n.º 3
0
        //used when an enemy attacks a player
        public static int AttackPlayer(Entity enemy, Entity player)
        {
            int enemyAttack = enemy.UseAttack();
            int chance      = ConsoleEffects.RandomNumber(1, 5);

            if (chance <= 3)
            {
                player.Health -= enemyAttack;
                CheckHealth(player);
                Console.WriteLine(enemy.Name + " hit " + player.Name + " for " + enemyAttack + ".");
                ConsoleEffects.TypeLine(player.Name + " has " + player.Health + " health.\r\n\r\n");
                return(player.Health);
            }
            //enemy hits twice
            if (chance == 4)
            {
                ConsoleEffects.TypeLine(enemy.Name + " hit " + player.Name + " for " + enemyAttack + ".\r\n");
                //possible random to decide damage
                int secondEnemyAttack = enemy.UseAttack();
                player.Health -= (enemyAttack + secondEnemyAttack);
                CheckHealth(player);
                System.Threading.Thread.Sleep(500);
                ConsoleEffects.ColorTextRed(enemy.Name + " hits for a second attacks. " + enemy.Name + " hit " + player.Name + " for " + secondEnemyAttack + ".");
                ConsoleEffects.TypeLine(player.Name + " has " + player.Health + " health.\r\n\r\n");
                return(player.Health);
            }
            Console.WriteLine(player.Name + " dodged the attack.\r\n");
            return(player.Health);
        }
Exemplo n.º 4
0
        //used when a player attacks an enemy
        public static int AttackEnemy(Entity enemy, Entity player)
        {
            int playerAttack = player.UseAttack();
            int chance       = ConsoleEffects.RandomNumber(1, 5);

            if (chance <= 3)
            {
                enemy.Health -= player.Attack;
                Console.WriteLine("\r\n" + player.Name + " hit " + enemy.Name + " for " + playerAttack + ".");
                CheckHealth(enemy);
                ConsoleEffects.TypeLine(enemy.Name + " has " + enemy.Health + " health.\r\n\r\n");
                return(enemy.Health);
            }
            //double attack
            else if (chance == 4)
            {
                Console.WriteLine("\r\n" + player.Name + " hit " + enemy.Name + " for " + playerAttack + ".");
                System.Threading.Thread.Sleep(500);
                //possible random to decide damage
                int secondPlayerAttack = player.UseAttack();
                enemy.Health -= (playerAttack + secondPlayerAttack);
                ConsoleEffects.ColorTextGreen(player.Name + " hits for a second attacks. " + player.Name + " hit " + enemy.Name + " for " + secondPlayerAttack + ".");
                CheckHealth(enemy);
                ConsoleEffects.TypeLine(enemy.Name + " has " + enemy.Health + " health.\r\n\r\n");

                return(enemy.Health);
            }
            else if (chance == 5)
            {
                Console.WriteLine(enemy.Name + " dodged the attack.\r\n\r\n");
                return(enemy.Health);
            }
            return(enemy.Health);
        }
Exemplo n.º 5
0
//End Fight Process



        public static int LootEnemy(Entity player, Entity enemy)
        {
            int goldAmount = ConsoleEffects.RandomNumber(8, enemy.Gold);

            ConsoleEffects.TypeLine(enemy.Name + " dropped " + goldAmount + " gold.\r\n");
            player.Gold += goldAmount;
            ConsoleEffects.TypeLine(player.Name + " now has " + player.Gold + " gold.");

            return(player.Gold);
        }
Exemplo n.º 6
0
        public static string SelectSleep()
        {
            ConsoleEffects.TypeLine("What can I do for you?\r\n");
            Console.WriteLine("-Rent a room");
            Console.WriteLine("-Leave");
            string sleepChoice = Console.ReadLine();

            Console.Clear();
            return(sleepChoice.ToLower());
        }
Exemplo n.º 7
0
        //Battle Process
        public static void Fight(Entity enemy, Entity player)
        {
            do
            {
                bool wrongAnswer;
                do
                {
                    wrongAnswer = false;
                    string selectBattlePlan = Actions.SelectBattlePlan(player);
                    if (selectBattlePlan.Contains("attack"))
                    {
                        AttackEnemy(enemy, player);
                    }
                    //uses magic if magic
                    else if (selectBattlePlan.Contains("magic") && player.IsMage())
                    {
                        UseMagicFire((Mage)player, enemy);
                    }
                    else if (selectBattlePlan.Contains("potion"))
                    {
                        if (Entity.CheckInventory(player, "potion"))
                        {
                            Item potion = Entity.GetItemFromInventory(player, "potion");
                            Entity.UsePotion(player, potion);
                        }
                        else
                        {
                            ConsoleEffects.TypeLine("I am afraid you do not have any potions.\r\n");
                            wrongAnswer = true;
                        }
                    }
                    else
                    {
                        ConsoleEffects.TypeLine("\r\nI'm afraid that isn't an option.\r\n");
                        wrongAnswer = true;
                    }
                } while (wrongAnswer);

                if (enemy.Health > 0 && player.Health > 0)
                {
                    AttackPlayer(enemy, player);
                }
            } while (enemy.Health > 0 && player.Health > 0);

            if (enemy.Health <= 0)
            {
                ConsoleEffects.TypeLine(player.Name + " wins!\r\n");
                LootEnemy(player, enemy);
            }
            else if (player.Health <= 0)
            {
                ConsoleEffects.TypeLine(player.Name + " has fainted.\r\n");
                Inn.Sleep(player);
            }
        }
Exemplo n.º 8
0
        //check if you have enough gold to buy potions
        public static Entity CheckGoldForPotion(Entity player)
        {
            bool stay = true;
            Item item = new Potion();

            do
            {
                string buyQuantity = BuyPotions();
                if (buyQuantity.Contains("1") || buyQuantity.Contains("one"))
                {
                    if (player.Gold >= item.Cost)
                    {
                        ConsoleEffects.TypeLine("Here you are!\r\n");
                        player.Gold -= item.Cost;
                        player.Inventory.Add(item);
                        Console.WriteLine("You received 1 " + item.Name + ". You now have " + player.Gold + " gold and " + Entity.CountInventory(player, item) + " potions");
                    }
                    else
                    {
                        ConsoleEffects.TypeLine("You do not have enough gold.");
                    }
                }
                else if (buyQuantity.Contains("3") || buyQuantity.Contains("three"))
                {
                    int itemDiscount = item.Cost + 2;
                    if (player.Gold >= itemDiscount)
                    {
                        ConsoleEffects.TypeLine("Here you are!\r\n");
                        player.Gold -= itemDiscount;
                        for (int i = 0; i < 3; i++)
                        {
                            player.Inventory.Add(item);
                        }
                        Console.WriteLine("You received 3 potions.  You now have " + player.Gold + " gold and " + Entity.CountInventory(player, item) + " potions");
                    }
                    else
                    {
                        ConsoleEffects.TypeLine("You do not have enough gold\r\n");
                    }
                }
                else if (buyQuantity.Contains("nevermind"))
                {
                    Console.Clear();
                    ConsoleEffects.TypeLine("Ah!  Maybe another time.\r\n");
                    stay = false;
                }
                else
                {
                    ConsoleEffects.TypeLine("Im sorry.  I do not know what you are trying to tell me.\r\n");
                }
            } while (stay);
            VisitPotionShop(player);
            return(player);
        }
Exemplo n.º 9
0
        //choose to buy or sell
        public static string SelectBuySell()
        {
            ConsoleEffects.TypeLine("What can I do for you?\r\n");
            Console.WriteLine("-Buy");
            Console.WriteLine("-Sell");
            Console.WriteLine("-Leave");
            string buySell = Console.ReadLine();

            Console.Clear();
            return(buySell.ToLower());
        }
Exemplo n.º 10
0
        //input on how many potions to buy
        public static string BuyPotions()
        {
            ConsoleEffects.TypeLine("We have plenty of goods to buy.\r\n");
            Console.WriteLine("-1 Potion --- 5 gold");
            Console.WriteLine("-3 Potions --- 7 gold");
            Console.WriteLine("-Nevermind");
            string total = Console.ReadLine();

            Console.Clear();
            return(total.ToLower());
        }
Exemplo n.º 11
0
        //input on how many potions to sell
        public static string SellPotions()
        {
            ConsoleEffects.TypeLine("What do you have to sell?\r\n");
            Console.WriteLine("-1 Potion --- 2 gold");
            Console.WriteLine("-3 Potions --- 4 gold");
            Console.WriteLine("-Nevermind");
            string total = Console.ReadLine();

            Console.Clear();
            return(total.ToLower());
        }
Exemplo n.º 12
0
        //Check if you have enough potions to sell
        public static Entity CheckPotionQuantity(Entity player)
        {
            bool stay = true;
            Item item = new Potion();

            do
            {
                string potionQuantity = SellPotions();
                if (potionQuantity.Contains("1") || potionQuantity.Contains("one"))
                {
                    if (Entity.CountInventory(player, item) >= 1)
                    {
                        player.Gold += 2;
                        player.Inventory.Remove(item);
                        ConsoleEffects.TypeLine("Here you are!\r\n");
                        ConsoleEffects.TypeLine(player.Name + " received 2 gold. " + player.Name + " now has " + player.Gold + " gold and " + Entity.CountInventory(player, item) + " potions.\r\n");
                    }
                    else
                    {
                        ConsoleEffects.TypeLine("You do not have enough potions to sell");
                    }
                }
                else if (potionQuantity.Contains("3") || potionQuantity.Contains("three"))
                {
                    if (Entity.CountInventory(player, item) >= 3)
                    {
                        player.Gold += 4;
                        for (int i = 0; i < 3; i++)
                        {
                            player.Inventory.Remove(item);
                        }
                        ConsoleEffects.TypeLine("Here you are!\r\n");
                        ConsoleEffects.TypeLine(player.Name + " received 4 gold. " + player.Name + " now has " + player.Gold + " gold and " + Entity.CountInventory(player, item) + " potions.\r\n");
                    }
                    else
                    {
                        ConsoleEffects.TypeLine("You do not have enough potions to sell\r\n");
                    }
                }
                else if (potionQuantity.Contains("nevermind"))
                {
                    Console.Clear();
                    ConsoleEffects.TypeLine("Ah!  Maybe another time.\r\n");
                    stay = false;
                }
                else
                {
                    ConsoleEffects.TypeLine("Im sorry.  I do not know what you are trying to tell me.\r\n");
                }
            } while (stay);
            VisitPotionShop(player);
            return(player);
        }
Exemplo n.º 13
0
        public static Item CheckItemSelected(Entity player)
        {
            string itemType = SellWeapons();
            Item   item     = player.Inventory.FirstOrDefault(o => o.Name == itemType);

            if (itemType.Contains("axe") && item.Name == "axe")
            {
                return(item);
            }
            ConsoleEffects.TypeLine("You do not own " + itemType + ".\r\n");
            CheckItemSelected(player);
            return(null);
        }
Exemplo n.º 14
0
        //inpsects the town
        public static string CheckTown()
        {
            Console.Clear();
            ConsoleEffects.TypeLine("You are now in town. Where would you like to go?\r\n");
            Console.WriteLine("-Potion Shop");
            Console.WriteLine("-Weapon Shop");
            Console.WriteLine("-Inn");
            Console.WriteLine("-Leave town");
            string shop = Console.ReadLine();

            Console.Clear();
            return(shop.ToLower());
        }
Exemplo n.º 15
0
        public static string BuyWeapons()
        {
            ConsoleEffects.TypeLine("We have plenty of goods to buy.\r\n");
            Console.WriteLine("Axe --- 12 gold");
            Console.WriteLine("Sword --- 10 gold");
            Console.WriteLine("Staff --- 15 gold");
            Console.WriteLine("Sceptor --- 15 gold");
            Console.WriteLine("Dagger --- 13 gold");
            Console.WriteLine("-Nevermind");
            string total = Console.ReadLine();

            Console.Clear();
            return(total.ToLower());
        }
Exemplo n.º 16
0
        public static string SellWeapons()
        {
            ConsoleEffects.TypeLine("What do you have to sell?\r\n");
            Console.WriteLine("Axe --- 6 gold");
            Console.WriteLine("Sword --- 5 gold");
            Console.WriteLine("Staff --- 7 gold");
            Console.WriteLine("Sceptor --- 7 gold");
            Console.WriteLine("Dagger --- 4 gold");
            Console.WriteLine("-Nevermind");
            string total = Console.ReadLine();

            Console.Clear();
            return(total.ToLower());
        }
Exemplo n.º 17
0
 public static (int, int) Sleep(Entity player)
 {
     ConsoleEffects.SpeedLine("zz..zzzz..zzz...zzz.zzzzzz\r\n", 100);
     ConsoleEffects.PressEnter();
     player.Health = player.MaxHealth;
     ConsoleEffects.TypeLine(player.Name + "'s health is now at " + player.Health + "\r\n");
     if (player.IsMagicClass())
     {
         player.Mana = player.MaxMana;
         ConsoleEffects.TypeLine(player.Name + "'s mana is now at " + player.Mana + "\r\n");
     }
     ConsoleEffects.PressEnter();
     VisitInn(player);
     return(player.Health, player.Mana);
 }
Exemplo n.º 18
0
        public static string SelectBattlePlan(Entity player)
        {
            ConsoleEffects.TypeLine("What would you like to do?\r\n");
            Console.WriteLine("-attack");
            //shows magic option if mage
            if (player.IsMagicClass())
            {
                Console.WriteLine("-magic");
            }

            Console.WriteLine("-potion");
            string battleChoice = Console.ReadLine();

            return(battleChoice.ToLower());
        }
Exemplo n.º 19
0
 //check the quantity of the item
 public static Entity CheckQuantityToSell(Entity player, Item item)
 {
     if (Entity.CountInventory(player, item) >= 1)
     {
         Console.WriteLine("Great!  Thanks!\r\n");
         player.Gold += item.SalePrice;
         player.Inventory.Remove(item);
         ConsoleEffects.TypeLine("You received " + item.SalePrice + " gold.\r\n");
     }
     else
     {
         ConsoleEffects.TypeLine("You do not own any " + item.Name + "s\r\n");
         VisitWeaponShop(player);
     }
     return(player);
 }
Exemplo n.º 20
0
        public static (int, int) UseMagicSmite(Priest player, Entity enemy)
        {
            if (player.Mana < 8)
            {
                ConsoleEffects.TypeLine("You do not have enough mana to do this.\r\n");
                return(enemy.Health, player.Mana);
            }
            int playerAttack = player.CastSmite();

            ConsoleEffects.TypeLine(player.Name + " cast smite. " + enemy.Name + " has been hit for " + playerAttack + "\r\n");
            enemy.Health -= playerAttack;
            player.Mana  -= 8;
            CheckHealth(enemy);
            ConsoleEffects.TypeLine(player.Name + " has " + player.Mana + " left.\r\n");
            ConsoleEffects.TypeLine(enemy.Name + " has " + enemy.Health + " health.\r\n\r\n");
            return(enemy.Health, player.Mana);
        }
Exemplo n.º 21
0
 public static Entity CheckGoldToBuy(Entity player, Item item)
 {
     if (player.Gold >= item.Cost)
     {
         ConsoleEffects.TypeLine("Here you are!\r\n");
         player.Gold -= item.Cost;
         player.Inventory.Add(item);
         Console.WriteLine("You received 1 " + item.Name + ". You now have " + player.Gold + " gold and " + Entity.CountInventory(player, item) + " " + item.Name);
         //CheckItemSelected();
     }
     else
     {
         ConsoleEffects.TypeLine("You do not have enough gold.");
         //CheckItemSelected();
     }
     CreateItemSelected(player);
     return(player);
 }
Exemplo n.º 22
0
        public static (int, int) UseMagicFire(Mage player, Entity enemy)
        {
            if (player.Mana < 8)
            {
                ConsoleEffects.TypeLine("You do not have enough mana to do this.\r\n");
                return(enemy.Health, player.Mana);
            }
            int playerAttack = player.CastFire();

            ConsoleEffects.TypeLine("\r\n" + player.Name + " casts fire. " + enemy.Name + " has been hit for " + playerAttack + "\r\n");
            enemy.Health -= playerAttack;

            int playerMana = player.UseMana(8);

            CheckHealth(enemy);
            ConsoleEffects.TypeLine(player.Name + " has " + playerMana + " mana left.\r\n");
            ConsoleEffects.TypeLine(enemy.Name + " has " + enemy.Health + " health.\r\n\r\n");
            return(enemy.Health, playerMana);
        }
Exemplo n.º 23
0
        //this should check for any item
        //why not have one shop?
        public static Item CreateItemSelected(Entity player)
        {
            string itemType = BuyWeapons();
            Item   item;

            if (itemType.Contains("nevermind"))
            {
                VisitWeaponShop(player);
            }
            //if (itemType.Contains("axe"))
            //{
            //    item = new Axe();
            //    return item;
            //}
            if (itemType.Contains("sword"))
            {
                item = new Sword();
                return(item);
            }
            ConsoleEffects.TypeLine("I am sorry.  I do not understand what you want.");
            return(CreateItemSelected(player));
        }
Exemplo n.º 24
0
        public static Entity UsePotion(Entity entity, Item potion)
        {
            int entityHealth = entity.Health += potion.Heal;

            entity.Inventory.Remove(potion);

            int overHeal;
            int potionHeal;

            if (entityHealth > entity.MaxHealth)
            {
                overHeal      = entity.Health - entity.MaxHealth;
                potionHeal    = potion.Heal - overHeal;
                entity.Health = entity.MaxHealth;
            }
            else
            {
                potionHeal = potion.Heal;
            }
            ConsoleEffects.TypeLine("\r\n" + entity.Name + " used " + potion.Name + " and gained " + potionHeal + " health.\r\n");
            ConsoleEffects.TypeLine(entity.Name + " now has " + entity.Health + " health.\r\n\r\n");
            return(entity);
        }
Exemplo n.º 25
0
        public static void VisitInn(Entity player)
        {
            string sleepTalk = Actions.SelectSleep();

            if (sleepTalk.Contains("rent"))
            {
                Sleep(player);
            }
            else if (sleepTalk.Contains("talk"))
            {
                //provide additional information based on story.
            }
            else if (sleepTalk.Contains("leave"))
            {
                Actions.SelectShop(player);
            }
            else
            {
                ConsoleEffects.TypeLine("I am sorry.  I do not understand you.");
                Console.Clear();
                VisitInn(player);
            }
            return;
        }
Exemplo n.º 26
0
        //input on what to do at the potion shop
        public static void VisitPotionShop(Entity player)
        {
            //ConsoleEffects.TypeLine("Welcome to the Potion Shop!\r\n");
            string buySell = Actions.SelectBuySell();

            if (buySell.Contains("buy"))
            {
                CheckGoldForPotion(player);
            }
            else if (buySell.Contains("sell"))
            {
                CheckPotionQuantity(player);
            }
            else if (buySell.Contains("leave"))
            {
                Actions.SelectShop(player);
            }
            else
            {
                ConsoleEffects.TypeLine("I am sorry.  I do not understand you.");
                Console.Clear();
                Actions.SelectBuySell();
            }
        }
Exemplo n.º 27
0
        static void Main(string[] args)
        {
            Entity      player = null;
            int         health;
            int         dodge;
            int         mana;
            int         gold;
            int         level = 1;
            string      redo;
            string      name;
            List <Item> inventory = new List <Item>();
            string      chosenClass;

            //string shop = "";
            //ConsoleEffects.makeVoice();
            ConsoleEffects.TypeLine("Greeting, traveller\r\n");
            ConsoleEffects.TypeLine("I see you are looking for adventure.");
            do
            {
                health      = 0;
                dodge       = 0;
                mana        = 0;
                gold        = 0;
                chosenClass = "";
                bool stop = false;
                bool providedName;
                ConsoleEffects.TypeLine(" What should I call you?\r\n");
                do
                {
                    providedName = true;
                    name         = Console.ReadLine();
                    if (string.IsNullOrEmpty(name))
                    {
                        Console.WriteLine("Everyone has a name!  What is yours?");
                        providedName = false;
                    }
                } while (providedName == false);

                name = ConsoleEffects.FirstCharToUpper(name);
                do
                {
                    ConsoleEffects.TypeLine("\r\nWhat class are you interested in?\r\n");
                    Console.WriteLine("Warrior");
                    Console.WriteLine("Mage");
                    Console.WriteLine("Rogue");
                    string study = Console.ReadLine();
                    switch (study.ToLower())
                    {
                    case "warrior":
                        player           = new Warrior();
                        player.Name      = name;
                        player.MaxHealth = player.RollHealth();
                        player.Health    = player.MaxHealth;
                        health           = player.Health;
                        dodge            = player.Dodge;
                        level            = player.Level;
                        gold             = player.Gold;
                        chosenClass      = "Warrior";
                        inventory        = player.Inventory;
                        stop             = true;
                        break;

                    case "mage":
                        player         = new Mage();
                        player.Name    = name;
                        player.MaxMana = player.RollMana();
                        mana           = player.MaxMana;
                        player.Mana    = mana;
                        health         = player.Health;
                        dodge          = player.Dodge;
                        level          = player.Level;
                        gold           = player.Gold;
                        chosenClass    = "Mage";
                        inventory      = player.Inventory;
                        stop           = true;
                        break;

                    case "rogue":
                        player       = new Rogue();
                        player.Name  = name;
                        player.Dodge = player.RollDodge();
                        dodge        = player.Dodge;
                        health       = player.Health;
                        level        = player.Level;
                        gold         = player.Gold;
                        chosenClass  = "Rogue";
                        inventory    = player.Inventory;
                        stop         = true;
                        break;

                    default:
                        ConsoleEffects.TypeLine("I am afraid I am not familiar with that line of study.  Please select again\r\n");
                        break;
                    }
                } while (stop == false);

                Actions.CheckCharacter(name, chosenClass, level, health, dodge, mana, gold);
                ConsoleEffects.TypeLine("\r\nIs this okay?\r\n");
                Console.WriteLine("-No, start over");
                Console.WriteLine("-Yes, that is correct");
                redo = Console.ReadLine();
                Console.Clear();
            } while (redo.ToLower().Contains("no"));

            Actions.SelectShop(player);
            Entity enemy = new Mage();

            enemy.Name   = "Bad Guy";
            enemy.Health = health;
            StoryOne.FirstChapter(enemy, player);
        }
Exemplo n.º 28
0
 public static void FirstChapter(Entity enemy, Entity player)
 {
     ConsoleEffects.TypeLine("FIGHT!!!\r\n");
     Battles.Fight(enemy, player);
 }