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); }
IngradientWithPrice CreateIngradienteWithPrice(Ingradient ingradiente) { //if (ingradiente.Equals(IngradientLoader.Tomato())) return(new IngradientWithPrice(ingradiente, 100, 100 * CostMod)); return(null); }
static void SerializeIngradiente(string name, string desc, DELIVERY_TYPE delType) { using (fout = new FileStream(ingradientsFolder + name + ".ing", FileMode.OpenOrCreate)) { ing = new Ingradient(delType, name, desc, 0, 10000); fs.Serialize(fout, ing); } }
public bool CanOrder(Ingradient ingradiente) { if (this.DeliveryType == DELIVERY_TYPE.All) { return(true); } return(ingradiente.DeliveredBy == this.DeliveryType); }
public void OrderIngradient(Ingradient what, bool Immediate = false) { if (what != null && delivery.CanOrder(what)) { delivery.AddToOrder(what); } if (Immediate || GetOrderPrice() >= 1500) { isOrdered = true; CheckOrder(); isOrdered = false; } }
public int CanTakeIngradient(Ingradient what) { CheckOrder(); Ingradient find = ingradients.Find(i => i.Name == what.Name); if (find == null) { return(-1); } if (find.MassGr < what.MassGr) { return(-1); } return(0); }
public bool IsInOrder(Ingradient what) { foreach (var i in toOrder) { if (i.Name == what.Name) { return(true); } } foreach (var i in toDeliver) { if (i.Name == what.Name) { return(true); } } return(false); }
public bool IsOrderedd(Ingradient what) { return((delivery as DeliveryBasic).IsInOrder(what)); }
public uint GetIngMass(Ingradient what) { IngradientOnCargo find = ingradients.Find(i => i.Name == what.Name); return(find?.MassGr ?? 0); }
public void AddToOrder(Ingradient ingradiente) { toOrder.Add(CreateIngradienteWithPrice(ingradiente)); }
public IngradientWithPrice(Ingradient basic, double _PriceBuy, double _PriceSell) : base(basic) { PriceBuy = _PriceBuy; PriceSell = _PriceSell; }
public Ingradient(Ingradient rhs) : this(rhs.DeliveredBy, rhs.Name, rhs.Description, rhs.MassGr, 0) { Quality = new Stat(rhs.Quality); }