Пример #1
0
        public Ingradient TakeIngradient(Ingradient what, ref double userMoney)
        {
            CheckOrder();
            IngradientOnCargo find = ingradients.Find(i => i.Name == what.Name);

            if (find == null || find.MassGr < what.MassGr)
            {
                return(null);

                throw new Exception("No more ings");
            }

            var res = new Ingradient(find)
            {
                MassGr = what.MassGr
            };

            find.MassGr        -= what.MassGr;
            res.Quality.current = (int)(res.Quality.current * this.QualityMod) - (DateTime.Now - find.PlacedOn).Seconds / 5;

            double deliverPriceBuy = find.PriceSell * what.MassGr / 1000;

            if (userMoney != 0)
            {
                userMoney   -= deliverPriceBuy * SellMod;
                EarnedMoney += deliverPriceBuy * SellMod;
            }

            if (find.MassGr == 0)
            {
                ingradients.Remove(find);
            }
            return(res);
        }
Пример #2
0
        public uint GetIngMass(Ingradient what)
        {
            IngradientOnCargo find = ingradients.Find(i => i.Name == what.Name);

            return(find?.MassGr ?? 0);
        }