Exemplo n.º 1
0
        /// <summary>
        /// Takes in a player object to get the items there can be used in the fight and setup a fight between the 2 Monsters
        /// the user keeps interacting between each attack and can either attack, use item or run from the fight
        /// </summary>
        /// <param name="player"></param>
        /// <param name="you"></param>
        /// <param name="enemy"></param>
        /// <returns></returns>
        internal Player FightMonster(Player player, Monster you, Enemy ene)
        {
            this.you = you;
            old = you;
            Monster enemy = ene.Tama;
            enemy.prepareForBattle(); //Configures the attack and armor to itself if it has been modified by a battle before
            this.you.prepareForBattle();  //Configures the attack and armor to itself if it has been modified by a battle before

            int choice = 0;
            Console.Clear();
            while (enemy.CurrentHealth > 0 && this.you.CurrentHealth > 0)
            {

            fightingMenu:
                Console.WriteLine("****************");
                Console.WriteLine("Enemy: " + enemy.CurrentHealth + " you: " + this.you.CurrentHealth);
                Console.WriteLine("****************");
                Console.WriteLine("Enemy stats: armor: " + enemy.CurrentArmor + " attack: " + enemy.CurrentAttack);
                Console.WriteLine();
                Console.WriteLine("Your stats: armor: " + this.you.CurrentArmor + " attack: " + this.you.CurrentAttack);
                Console.WriteLine("****************");
                Console.WriteLine();
                Console.WriteLine("1. Do you wanna attack?");
                Console.WriteLine("2. Use an item?");
                Console.WriteLine("3. Run from the fight?");

                try
                {
                    choice = Convert.ToInt32(Console.ReadLine());
                    Console.Clear();
                }
                catch (Exception)
                {
                    Console.Clear();
                    goto fightingMenu;
                }

                switch (choice)
                {
                    case 1:
                        int a = attack(this.you, enemy);
                        enemy.CurrentHealth -= a;
                        Console.WriteLine("You did " + a + " damage to it");
                        Console.WriteLine();
                        break;
                    case 2:
                        if (player.Inventory.Count <= 0)
                        {
                            goto fightingMenu;
                        }
                        for (int i = 0; i < player.Inventory.Count; i++)
                        {
                            if (!player.Inventory[i].Name.Contains("potion"))
                            {
                                goto fightingMenu;

                            }

                        }
                        player = useItem(player, this.you);
                        goto fightingMenu;
                    case 3:
                        this.you.CurrentHealth = this.you.MaxHealth;
                        player.Monsters.Remove(old);
                        player.Monsters.Add(this.you);
                        return player;
                    default:
                        goto fightingMenu;
                }

                if (enemy.CurrentHealth > 0 && this.you.CurrentHealth > 0)
                {
                    int a = attack(enemy, this.you);
                    this.you.CurrentHealth -= a;
                    Console.WriteLine(ene.Name +" did " + a + " damage to you");
                    Console.WriteLine();
                }

            }
            if (enemy.CurrentHealth <= 0)
            {
                Console.Clear();
                Console.WriteLine("Congratz you won the battle");
                Console.WriteLine();
                this.you = this.you.grantExp(you, 20 * enemy.Level);
                player.Money += 5 * enemy.Level;
                Console.WriteLine("Exp: " + 20 * enemy.Level);
                Console.WriteLine("Money: " + 5 * enemy.Level);
                player.updateQuests(ene, null, null, 0, 5 * enemy.Level, 0);
                Console.WriteLine();

            }
            else
            {
                Console.WriteLine("You lost the battle");
                Console.WriteLine();
                //TODO Decide what to do when the player lost the battle
            }
            this.you.CurrentHealth = this.you.MaxHealth;
            player.Monsters.Remove(old);
            player.Monsters.Add(this.you);

            return player;
        }
Exemplo n.º 2
0
        internal Player Graveyard(Player play)
        {
            Console.Clear();
            player = play;
            Area area = new Area("Graveyard", 7);
            player.Area = area;
            player.updateQuests(null, player.Area, null, 0, 0, 0);
            Console.WriteLine("The graveyards looks old and ruined as you enter it. \n" +
                "the graves looks like someone has been digging them all up \n" +
                "and the air feels cold as ice, as you look around you can \n" +
                "only see the castle upwards even though you feel like \n" +
                "someone is watching you");
            Console.WriteLine();
            Console.WriteLine("You are in " + area.Name + " level " + area.Level);
            Console.WriteLine(player.stats());
            Console.WriteLine();
            Console.WriteLine("1 Go to the The Plague Lands");
            Console.WriteLine("2 Go to the castle");
            Console.WriteLine("3 Save your progress");
            int choice = 0;
            try_again:
            try
            {
                choice = int.Parse(Console.ReadLine());
            }
            catch (Exception)
            {
                goto try_again;
            }

            switch (choice)
            {
                case 1:
                    player = The_Plague_Lands(player);
                    break;
                case 2:
                    player = Undead_Castle(player);
                    break;
                case 3:
                    return player;
            }
            return player;
        }
Exemplo n.º 3
0
        internal Player The_Plague_Lands(Player play)
        {
            Console.Clear();
            player = play;
            Area area = new Area("The_Plague_Lands", 6);
            player.Area = area;
            player.updateQuests(null, player.Area, null, 0, 0, 0);
            Console.WriteLine("As you enter the dark forest you feel an itching all over your body \n" +
                "the dirt looks tainted and all the leaves withered away. \n" +
                "you look around and spot a single hill with a castle upon \n" +
                "and around the hill you spot a huge graveyard");
            Console.WriteLine();
            Console.WriteLine("You are in " + area.Name + " level " + area.Level);
            Console.WriteLine(player.stats());
            Console.WriteLine();
            Console.WriteLine("1 Go to Graveyard (level 7)");
            Console.WriteLine("2 Go to Orexdale (level 3)");
            Console.WriteLine("3 Go to Undead Castle (level 9)");
            Console.WriteLine("4 Save your progress");
            int choice = 0;
            try_again:
            try
            {
                choice = int.Parse(Console.ReadLine());
            }
            catch (Exception)
            {
                goto try_again;
            }

            switch (choice)
            {
                case 1:
                    player = Graveyard(player);
                    break;
                case 2:
                    player = Orexdale(player);
                    break;
                case 3:
                    player = Undead_Castle(player);
                    break;
                case 4:
                    return player;
            }
            return player;
        }
Exemplo n.º 4
0
        internal Player WitchHut(Player play)
        {
            try_again:
            Console.Clear();
            player = play;
            Area area = new Area("WitchHut", 1);
            NPC npc = new NPC("Witch Doctor");
            Quest q1 = new Quest("Learning Brewing", "Go find 20 herbs for the Witch Doctor", 20, 0, "herbs 20", false, false);

            npc.addQuest(q1);
            area.setNPC(npc);
            player.Area = area;

            Console.Clear();
            Console.WriteLine("As you walk towards the hut a witch steps outside and looks at you and you wonder whether to \n" +
                                "confront her or go back");
            Console.WriteLine();
            Console.WriteLine(player.stats());
            Console.WriteLine();
            Console.WriteLine("1 Go to Pladósh (level 3)");
            Console.WriteLine("2 Talk to the " + npc.Name);
            Console.WriteLine("3 Save your progress");
            int choice = 0;

            try
            {
                choice = int.Parse(Console.ReadLine());
            }
            catch (Exception)
            {
                goto try_again;
            }

            switch (choice)
            {
                case 1:
                    player = Pladósh(player);
                    break;
                case 2:
                Witch:
                    Console.Clear();
                    Console.WriteLine("As you walk towards the witch she stares at you and let out a little squek before she asks you");
                    Console.WriteLine();
                    Console.WriteLine("1. Do you wanna brew something?");
                    Console.WriteLine("2. Or head back where you came from?");
                    int choice2;
                    try
                    {
                        choice2 = int.Parse(Console.ReadLine());
                    }
                    catch (Exception)
                    {
                        goto Witch;
                    }
                    switch (choice2)
                    {
                        case 1:
                            bool questCompleted = false;
                            foreach (var item in player.Questlog)
                            {
                                if (item.Name == q1.Name && item.Completed && item.Rewarded)
                                {
                                    questCompleted = true;
                                }
                            }
                            if (questCompleted)
                            {
                                PotionMenu();
                                goto Witch;
                            }
                            else
                            {
                                Console.WriteLine("Before you start brewing you have to do a quest for me");
                                Console.WriteLine();
                                Console.WriteLine("Press 1 to accept the quest");
                                int choice3;
                                try
                                {
                                    choice3 = int.Parse(Console.ReadLine());
                                }
                                catch (Exception)
                                {
                                    goto Witch;
                                }
                                switch (choice3)
                                {
                                    case 1:
                                        Console.Clear();
                                        area.Npc.displayQuests();
                                        if (player.checkQuest(area.Npc.Quests[choice3 - 1]))
                                        {
                                            Console.Clear();
                                            Console.WriteLine("The quest: " + area.Npc.Quests[choice3 - 1].Name + " has been added to your questlog!");
                                            player.Questlog.Add(area.Npc.Quests[choice3 - 1]);
                                            player.updateQuests(null, null, null, player.Herbs, 0, 0);
                                            Console.WriteLine();
                                            Console.WriteLine("Press enter to continue");
                                            Console.ReadLine();
                                        }
                                        else
                                        {
                                            if (player.completeQuest(area.Npc.Quests[choice3 - 1], null))
                                            {
                                                player.Herbs -= 20;
                                            }
                                            else
                                                Console.WriteLine("You'r either on the quest or finished it");
                                            Console.WriteLine();
                                            Console.WriteLine("Press enter to continue");
                                            Console.ReadLine();
                                        }
                                        break;
                                    default:
                                        goto Witch;
                                }
                            }
                            goto Witch;
                        case 2:
                            goto try_again;
                    }
                    break;
                case 3:
                    return player;

            }
            return player;
        }