Esempio n. 1
0
        public void UpgradeInventory(Player player)
        {
            Money price = CalculateCostToUpgradeInventory(player);
            if (price.Amount > player.Money.Amount)
            {
                throw new System.Exception("Upgrade costs: " + price.ToString() + ", you have: " + player.Money.ToString());
            }

            // upgrade the inventory
            player.Inventory.MaxWeight += 5;
            player.Money.Amount -= price.Amount;

            preferences.BaseBagUpgradePrice += (int)(preferences.BaseBagUpgradePrice * preferences.BagUpgradePricePercentageIncrease / 100.0);
        }
Esempio n. 2
0
 public Money CalculateCostToUpgradeInventory(Player player)
 {
     return new Money(preferences.BaseBagUpgradePrice);
 }
Esempio n. 3
0
        // TOOD
        public void SellToShop(Shop shop, Player player, Item[] itemsToSell)
        {
            for(int i = 0; i < itemsToSell.Length; ++i)
            {
                Item item = itemsToSell[i];

                player.Money.Amount += shop.PriceOf(item).Amount;
                player.Inventory.Remove(item);

                shop.Add(item);
            }
        }
Esempio n. 4
0
        public void BuyFromShop(Shop shop, Player player, Item[] itemsToBuy)
        {
            Money price = PriceOf(itemsToBuy, shop);

            if (player.Money.Amount < price.Amount)
            {
                throw new Exception("You only have: " + player.Money.ToString() + ", the items you wish to buy cost: " + PriceOf(itemsToBuy, shop).ToString());
            }

            if (!player.Inventory.CanHold(itemsToBuy))
            {
                throw new Exception("You cannot hold the items that you wish to purchase!");
            }

            foreach (Item item in itemsToBuy)
            {
                Money priceOfItem = shop.PriceOf(item);

                player.Money.Amount -= priceOfItem.Amount;
                player.Inventory.Add(item);

                shop.Remove(item);
            }
        }