Esempio n. 1
0
        private void SellItems(Player customer)
        {
            var backpackItemsName = Player.backpack.Keys.ToList();  // hämmtar namnet på sakerna i backpacken
            var backpackItemsValue = Player.backpack.Values.ToList(); // hämtar värdet på sakerna i backpacken
            int choice;
            bool parseSuccessfull;
            if (Player.backpack.Count == 0)
            {
                Console.Clear();
                PrintDesign.WriteLineInRed("You have nothing to sell!");
            }
            else
            {
                do
                {
                    PrintDesign.PrintShop(Player.backpack);
                    Console.WriteLine("Select the number next to the item that you want to sell: ");
                    Console.Write("Number: ");
                    parseSuccessfull = int.TryParse(Console.ReadLine(), out choice);
                    if (choice > Player.backpack.Count + 1)
                    {
                        Console.Clear();
                        PrintDesign.WriteLineInRed("Number to high. Choose one of the numbers infront of the items");
                    }
                    else if (choice <= 0)
                    {
                        Console.Clear();
                        PrintDesign.WriteLineInRed("Number to low. Choose one of the numbers infront of the items");
                    }
                    else if (parseSuccessfull == false)
                    {
                        Console.Clear();
                        PrintDesign.WriteLineInRed("Something went wrong! Try again");
                    }

                } while (choice > Player.backpack.Count + 1 || choice <= 0 || parseSuccessfull == false);
                Console.Clear();
                PrintDesign.WriteLineInGreen($"\nSold {backpackItemsName[choice - 1]} for {backpackItemsValue[choice - 1]} gold");
                customer.Gold += backpackItemsValue[choice - 1]; // adderar guldet för den sålda varan till spelaren
                Player.backpack.Remove(backpackItemsName[choice - 1]); // tar bort sålda varan från ryggsäcken
            }

        }
Esempio n. 2
0
        /// <summary>
        /// Hämtar loot ifall det finns och ifall spelaren vill plocka upp det.
        /// </summary>

        public static void GetLoot(EnemyModel enemy, PlayerModel player)
        {
            string answer;
            int    lootValue;
            string loot = enemy.droppedLoot(out lootValue);

            if (loot == null)
            {
                PrintDesign.WriteLineInGreen($"You search dead {enemy.Name} and find {enemy.Gold} gold, but no additional loot.");
                player.Gold += enemy.Gold;
            }
            else
            {
                PrintDesign.WriteLineInGreen($"You search dead {enemy.Name} and find {enemy.Gold} gold, and {loot} (worth: {lootValue} coins).");
                player.Gold += enemy.Gold;
                do
                {
                    Console.WriteLine($"Do you want to pick up {loot}? Y/N");
                    answer = Console.ReadLine().ToLower().Replace(" ", "");

                    if (answer == "y")
                    {
                        Console.Clear();

                        if (Player.backpack.ContainsKey(loot))
                        {
                            PrintDesign.WriteLineInRed("You already own this item!");
                        }
                        else
                        {
                            Player.backpack.Add(loot, lootValue);
                            PrintDesign.WriteLineInGreen($"{loot} added to backpack!");
                        }
                    }
                    if (answer != "y" && answer != "n")
                    {
                        Console.Clear();
                        PrintDesign.WriteLineInRed("Invalid input! Try again.");
                    }
                } while (answer != "y" && answer != "n");
            }
        }
Esempio n. 3
0
        public static void StartFight(PlayerModel player, EnemyModel enemy)
        {
            Console.Clear();
            int expToGive = enemy.Exp;

            Console.WriteLine($"{player.Name} VS {enemy.Name}");
            Console.WriteLine();
            while (true)
            {
                Console.WriteLine($"{player.Name} health: {player.Health}");
                Console.WriteLine($"{enemy.Name} health: {enemy.Health}\n");
                if (GetAttackResult(player, enemy) == "Fight Over") // skickar in spelaren först (dvs spelaren attackerar) returneras stringen Fight Over så ges exp och loot.
                {
                    Console.Clear();

                    player.GainExp(expToGive);
                    PrintDesign.WriteLineInGreen($"\nYou won the fight! you gain {expToGive} Exp");

                    if (player.Level >= 10)
                    {
                        Program.WonGame();
                    }
                    GetLoot(enemy, player);
                    enemy.Health  = 100;                   // full health inför varje ny fight.
                    player.Health = 100;
                    if (player.FightClass == "warrior")
                    {
                        player.Health = 102;
                    }
                    break;
                }
                Console.WriteLine($"{player.Name} health: {player.Health}");
                Console.WriteLine($"{enemy.Name} health: {enemy.Health}\n");
                if (GetAttackResult(enemy, player) == "Fight Over") // skickar in fienden först (dvs fienden attackerar)
                {
                    Console.Clear();
                    PrintDesign.WriteLineInRed("\nYou lost!");
                    Program.Exit();
                    break;
                }
            }
        }
Esempio n. 4
0
 public static void Exit()
 {
     Console.Clear();
     PrintDesign.WriteLineInGreen("Thank you for playing! See you next time");
     Environment.Exit(0);
 }
Esempio n. 5
0
        private void SpecialItemsAvaliableForSell(Player customer)
        {

            var listOfItemNames = specialItemsToSell.Keys.ToList();  // hämmtar namnet på special item till salu
            var listOfItemPrices = specialItemsToSell.Values.ToList(); // hämtar värdet på special item till salu.
            int choice;
            bool parseSuccessfull;
            do
            {
                
                PrintDesign.WriteLineInGreen($"\nGold in wallet: {customer.Gold}");
                PrintDesign.PrintShop(specialItemsToSell);
                Console.Write("Number: ");

                parseSuccessfull = int.TryParse(Console.ReadLine(), out choice);

                if (choice < 0)
                {
                    PrintDesign.WriteLineInRed("Chosen number to small!");
                }
                else if (parseSuccessfull == false)
                {
                    PrintDesign.WriteLineInRed("Something went wrong!");
                }
                else if (choice > 4)
                {
                    PrintDesign.WriteLineInRed("Chosen number to high!");
                }

            } while (choice >= 4 || choice <= 0 || parseSuccessfull == false);

            if (listOfItemPrices[choice - 1] > customer.Gold)
            {
                Console.Clear();
                PrintDesign.WriteLineInRed($"You dont have enough money to buy {listOfItemNames[choice - 1]}!");
            }

            else if (customer.SpecialItem == listOfItemNames[choice - 1])
            {
                Console.Clear();
                PrintDesign.WriteLineInRed($"You already own {listOfItemNames[choice - 1]}!");
            }
            else
            {
                Console.Clear();
                PrintDesign.WriteLineInGreen($"\n{listOfItemNames[choice - 1]} bought and equipped!");
                customer.SpecialItem = listOfItemNames[choice - 1]; // adderar special item till spelaren
                customer.Gold -= listOfItemPrices[choice - 1]; // tar bort det antal guld från spelaren som den köpta varan kostar.

                if (choice == 1)
                {
                    customer.Health -= ExtraHealthFromItems;
                    ExtraHealthFromItems = 1;
                    customer.Health += ExtraHealthFromItems;
                }
                if (choice == 2)
                {
                    customer.Health -= ExtraHealthFromItems;
                    ExtraHealthFromItems = 2;
                    customer.Health += ExtraHealthFromItems;
                }
                if (choice == 3)
                {
                    customer.Health -= ExtraHealthFromItems;
                    ExtraHealthFromItems = 3;
                    customer.Health += ExtraHealthFromItems;
                }

            }
        }
Esempio n. 6
0
        private void ArmorsAvaliableForSell(Player customer)
        {
            var listOfArmorNames = armorsToSell.Keys.ToList();
            var listOfArmorPrices = armorsToSell.Values.ToList();
            int choice;
            bool parseSuccessfull;
            do
            {
                ;
                PrintDesign.WriteLineInGreen($"\nGold in wallet: {customer.Gold}");
                PrintDesign.PrintShop(armorsToSell);
                Console.Write("Number: ");

                parseSuccessfull = int.TryParse(Console.ReadLine(), out choice);

                if (choice <= 0)
                {
                    Console.Clear();
                    PrintDesign.WriteLineInRed("Chosen number to small!");
                }
                else if (parseSuccessfull == false)
                {
                    Console.Clear();
                    PrintDesign.WriteLineInRed("Something went wrong!");
                }
                else if (choice >= 4)
                {
                    Console.Clear();
                    PrintDesign.WriteLineInRed("Chosen number to high!");
                }

            } while (choice >= 4 || choice <= 0 || parseSuccessfull == false);

            if (listOfArmorPrices[choice - 1] > customer.Gold)
            {
                Console.Clear();
                PrintDesign.WriteLineInRed($"You dont have enough money to buy {listOfArmorNames[choice - 1]}!");
            }

            else if (customer.Armor.Contains(listOfArmorNames[choice - 1]))
            {
                Console.Clear();
                PrintDesign.WriteLineInRed($"You already {listOfArmorNames[choice - 1]}!");
            }
            else
            {
                PrintDesign.WriteLineInGreen($"\n{listOfArmorNames[choice - 1]} bought and equipped!");
                customer.Armor = listOfArmorNames[choice - 1];
                customer.Gold -= listOfArmorPrices[choice - 1];

                if (choice == 1)
                {
                    customer.MaxBlock -= ExtraDefenceFromArmor; // tar bort nuvarande bonusen från armor
                    ExtraDefenceFromArmor = 3;
                    customer.MaxBlock += ExtraDefenceFromArmor; // addrar bonusen från den nyköpta armor
                }
                if (choice == 2)
                {
                    customer.MaxBlock -= ExtraDefenceFromArmor;
                    ExtraDefenceFromArmor = 5;
                    customer.MaxBlock += ExtraDefenceFromArmor;
                }
                if (choice == 3)
                {
                    customer.MaxBlock -= ExtraDefenceFromArmor;
                    ExtraDefenceFromArmor = 7;
                    customer.MaxBlock += ExtraDefenceFromArmor;
                }

            }
        }
Esempio n. 7
0
        private void WeaponAvailableForSell(Player customer)
        {
            var listOfWeaponNames = weaponsToSell.Keys.ToList();
            var listOfWeaponPrices = weaponsToSell.Values.ToList();
            int choice;
            bool parseSuccessfull;

            Console.Clear();
            Console.WriteLine($"Weapons avaliable for the {customer.FightClass}:");
            do
            {
                
                PrintDesign.WriteLineInGreen($"\nGold in wallet: {customer.Gold}");
                PrintDesign.PrintShop(weaponsToSell);
                Console.Write("Number: ");

                parseSuccessfull = int.TryParse(Console.ReadLine(), out choice);

                if (choice <= 0)
                {
                    Console.Clear();
                    PrintDesign.WriteLineInRed("Chosen number to small!");
                }
                else if (parseSuccessfull == false)
                {
                    Console.Clear();
                    PrintDesign.WriteLineInRed("Something went wrong!");
                }
                else if (choice >= 4)
                {
                    Console.Clear();
                    PrintDesign.WriteLineInRed("Chosen number to high!");
                }

            } while (choice >= 4 || choice <= 0 || parseSuccessfull == false);

            if (listOfWeaponPrices[choice - 1] > customer.Gold)
            {
                Console.Clear();
                PrintDesign.WriteLineInRed($"You dont have enough money to buy {listOfWeaponNames[choice - 1]}!");
            }

            else if (customer.Weapon == listOfWeaponNames[choice - 1])
            {
                Console.Clear();
                PrintDesign.WriteLineInRed($"You already own {listOfWeaponNames[choice - 1]}!");
            }
            else
            {
                Console.Clear();
                PrintDesign.WriteLineInGreen($"\n{listOfWeaponNames[choice - 1]} bought and equipped!");
                customer.Weapon = listOfWeaponNames[choice - 1];
                customer.Gold -= listOfWeaponPrices[choice - 1];

                if (choice == 1)
                {
                    customer.MaxDmg -= ExtraDamageFromWeapons;
                    ExtraDamageFromWeapons = 3;
                    customer.MaxDmg += ExtraDamageFromWeapons;
                }
                if (choice == 2)
                {
                    customer.MaxDmg -= ExtraDamageFromWeapons;
                    ExtraDamageFromWeapons = 5;
                    customer.MaxDmg += ExtraDamageFromWeapons;
                }
                if (choice == 3)
                {
                    customer.MaxDmg -= ExtraDamageFromWeapons;
                    ExtraDamageFromWeapons = 7;
                    customer.MaxDmg += ExtraDamageFromWeapons;
                }
            }
        }