Esempio n. 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Started...");
            Product prod1 = new Product(10, 1);
            Product prod2 = new Product(60, 1);
            Product prod3 = new Product(10, 2);
            Product prod4 = new Product(60, 2);
            Product prod5 = new Product
            {
                Type = 1
            };

            var checker = new PriceChecker(); // Publisher

            service1 = new Service1();
            service2 = new Service2();
            service3 = new AnnouncerService();
            checker.PriceChecking += service3.PriceChecking;

            List <Product> list = new List <Product> {
                prod1, prod2, prod3, prod4, prod5
            };

            list.ForEach(p => checker.CheckPrice(p));

            Console.WriteLine("Press Enter to exit:");
            Console.ReadLine();
        }
Esempio n. 2
0
        public void PullsPricesFromPriceSite()
        {
            var jita    = new SolarSystemId(30000142, "Jita");
            var trit    = new TypeId(34, "Tritanium");
            var subject = new PriceChecker();

            var result = subject.GetPrice(trit, jita);

            result.SellMin.Should().BeLessThan(10, "trit should not be crazy expensive");
            result.SellMin.Should().BeGreaterThan(0, "trit should not be free");
        }
Esempio n. 3
0
 public void DetermineValue(string itemLocation)
 {
     if (itemLocation == "Shop")
     {
         currentValue = PriceChecker.AppraiseItem(this, "Purchase");
     }
     else
     {
         currentValue = PriceChecker.AppraiseItem(this, "Sale");
     }
 }
Esempio n. 4
0
    void CheckPlayerFunds(Item item, int quantity)
    {
        float price = PriceChecker.AppraiseItem(item, "Purchase") * quantity;

        if (price <= playerWallet.GetCurrentBalance())
        {
            CommitPurchase(item, quantity, price);
        }
        else
        {
            Debug.Log("Insufficient funds, balance: $" + playerWallet.GetCurrentBalance());
            shopDialogue.SetCurrentMessage(LoadShop.MessageType.LOW_GOLD);
        }
    }
Esempio n. 5
0
    public void RightClickedToSell(Item item)
    {
        if (item != null)
        {
            float price = PriceChecker.AppraiseItem(item, "Sale") * item.quantity;

            if (InventoryManager.GetInstance().GetShopInventory().CheckSpaceAndGold(item, item.quantity, price))
            {
                InventoryManager.GetInstance().GetInventory().Remove(item);
                InventoryManager.GetInstance().GetShopInventory().AddItem(item); //needs to account for quantity
                ScriptToolbox.GetInstance().GetPlayerWallet().Deposit(price);
                InventoryManager.GetInstance().GetShopDialogue().SetCurrentMessage(LoadShop.MessageType.SUCCESS);
            }
            else
            {
                InventoryManager.GetInstance().GetShopDialogue().SetCurrentMessage(LoadShop.MessageType.INVAL_QNTY);
            }
        }
    }
Esempio n. 6
0
    void CommitSale(Item item, int quantity)
    {
        float price = PriceChecker.AppraiseItem(item, "Sale") * quantity;

        if (shop.CheckSpaceAndGold(item, quantity, price))
        {
            playerWallet.Deposit(price);
            Debug.Log("You have been credited $" + price);

            inv.SubtractQuantityFromItem(item, quantity);

            //create new item to go to shop
            Item soldItem = new Item(item);
            soldItem.quantity = quantity;
            shop.AddItem(soldItem);

            shopDialogue.SetCurrentMessage(LoadShop.MessageType.SUCCESS);
        }
        else
        {
            shopDialogue.SetCurrentMessage(LoadShop.MessageType.INVAL_QNTY);
        }
    }
Esempio n. 7
0
    public void ShopSlotRightClicked(Item item)
    {
        if (item == null)
        {
            return;
        }

        ShopDialogue        shopDialogue = InventoryManager.GetInstance().GetShopDialogue();
        CheckInventorySpace invCheck     = InventoryManager.GetInstance().GetInventorySpaceChecker();

        float price = PriceChecker.AppraiseItem(item, "Purchase") * item.quantity;

        if (playerWallet.GetCurrentBalance() >= price && invCheck.CheckItem(item))
        {
            InventoryManager.GetInstance().GetShopInventory().Remove(item);
            InventoryManager.GetInstance().GetInventory().AddItem(item);
            playerWallet.Withdraw(price);
            shopDialogue.SetCurrentMessage(LoadShop.MessageType.SUCCESS);
        }
        else
        {
            shopDialogue.SetCurrentMessage(LoadShop.MessageType.INVAL_QNTY); //SHOULD BE "GENERIC_NO"
        }
    }