// starts the production sequence and sets the appropraite messages public void Produce(MainStorage mainStorage, List <Chocolate> chocolatesStored) { var materialsNeeded = ProductionUnit.MaterialsNeeded(); var materialsSuffice = StorageUnit.MaterialsSuffice(materialsNeeded); if (!ProductionUnit.ProducedDailyProduction) { if (PersonelSuffice() && materialsSuffice) { var products = ProductionUnit.DailyProduction(); mainStorage.newProducts.AddRange(products); mainStorage.SortProducts(chocolatesStored); ProductionUnit.ProducedDailyProduction = true; } else if (!PersonelSuffice()) { Message.SetErrorMessage(MessageEnum.PersonelError); Message.SetMainStorageInfo(null, null); } else { Message.SetErrorMessage(MessageEnum.RawMaterialsError); Message.SetMainStorageInfo(null, null); } } else { Message.SetErrorMessage(MessageEnum.ProductionTurnError); Message.SetMainStorageInfo(null, null); } }
// breaks the Contract with an active Supplier and returns a message public string BreakContract(Safe vault) { if (Supplier != null) { decimal shipments = Convert.ToDecimal(StorageUnit.ShipmentsReceived); decimal offerAmount = Convert.ToDecimal(Supplier.OfferAmount); var penalty = (offerAmount - shipments) * Supplier.PricePerKilo * 0.5M; var supplierName = Supplier.Name; if (vault.MoneySuffice(penalty)) { Supplier = null; StorageUnit.ResetSupplier(); vault.WithdrawAmount(penalty); return($"{Name} Factory broke it's Contract with {supplierName}. You got charged with {penalty:F2}"); } return($"The penalty is {penalty:F2}! Seems you're stuck with these guys for now..."); } return("Something went wrong. Try again"); }