Exemplo n.º 1
0
        public void UseItem(Item item, Player player)
        {
            em.LoadEffects();
            switch (item.GetItemID())
            {
            //Small Health Potion
            case 1:
                if (player.GetHealth() >= player.GetMaxHealth())
                {
                    Console.WriteLine("|| Already Max Health!");
                }
                else
                {
                    player.AddHealth(100);
                    item.SetAmount(item.GetAmount() - 1);

                    Console.WriteLine("|| Used 1 {0}!", item.GetName());
                    Console.WriteLine("|| Recovered 100 Health!");
                }
                break;

            //Small Mana Potion
            case 2:
                if (player.GetMana() >= player.GetMaxMana())
                {
                    Console.WriteLine("|| Already Max Mana!");
                }
                else
                {
                    player.AddMana(30);
                    item.SetAmount(item.GetAmount() - 1);

                    Console.WriteLine("|| Used 1 {0}!", item.GetName());
                    Console.WriteLine("|| Recovered 30 Mana!");
                }
                break;

            //Medium Health Potion
            case 3:
                if (player.GetHealth() >= player.GetMaxHealth())
                {
                    Console.WriteLine("|| Already Max Health!");
                }
                else
                {
                    player.AddHealth(250);
                    item.SetAmount(item.GetAmount() - 1);

                    Console.WriteLine("|| Used 1 {0}!", item.GetName());
                    Console.WriteLine("|| Recovered 250 Health!");
                }
                break;

            //Medium Mana Potion
            case 4:
                if (player.GetMana() >= player.GetMaxMana())
                {
                    Console.WriteLine("|| Already Max Mana!");
                }
                else
                {
                    player.AddMana(70);
                    item.SetAmount(item.GetAmount() - 1);

                    Console.WriteLine("|| Used 1 {0}!", item.GetName());
                    Console.WriteLine("|| Recovered 70 Mana!");
                }
                break;

            default:
                Console.WriteLine("|| No item found");
                break;
            }

            player.RefreshInventory();
        }