//METHODS public override void PassTime(int deltaTime) { runningTime = runningTime.AddMinutes(30).AddMilliseconds(deltaTime); patientInfo.Value = $"CURRENT CLIENT: {Environment.NewLine}{CurrentClient.GetCurrentState()}{Environment.NewLine}{Environment.NewLine}" + $"CLIENT GOALS: {Environment.NewLine}{CurrentClient.GetGoals()}{Environment.NewLine}{Environment.NewLine}" + $"TODAYS INTAKE:{Environment.NewLine}{CurrentClient.GetTodaysIntake()}"; clockDisplay.Value = "Current time: " + runningTime.ToString("HH:mm:ss"); clinicInfo.Value = $"CLINIC NAME: {TheClinic.Name} {Environment.NewLine}{Environment.NewLine}CLINIC STAFF: {Environment.NewLine}{TheDietitian.Position}: {TheDietitian.Name} {Environment.NewLine}{ThePersonalTrainer.Position}: {ThePersonalTrainer.Name} {Environment.NewLine}{Environment.NewLine}CLIENTS HELPED:{Environment.NewLine}{TheClinic.ClientRecord.Count - 1}"; if (runningTime.Day > startTime.Day) { messageBoard.Log("It's a new day! Let's check the progress:"); messageBoard.Log(CurrentClient.CheckTodaysIntake()); startTime = runningTime; } if (CurrentClient.NeedsHozpitalization()) { messageBoard.Log("Oups, this has gotten out of hand"); messageBoard.Log($"{CurrentClient.Name} is dangerouzly underweight and needs hospital care"); messageBoard.Log($"Bye {CurrentClient.Name} hope you feel better soon"); messageBoard.Log($"Let's sign in a new patient"); messageBoard.Log(TheClinic.SignInNewClient(ClientGenerator.GenerateRandomClient(TheClinic))); } if (CurrentClient.HasReachedNormalWeight()) { messageBoard.Log("Congrats, the client has reached normal BMI!"); messageBoard.Log($"We will sign him/her out and sign in a new client {Environment.NewLine}"); messageBoard.Log(TheClinic.SignInNewClient(ClientGenerator.GenerateRandomClient(TheClinic))); } headerMessageBoard.Value = simState.title; commandBox.Value = simState.FillCommandBox(); while (input.HasInput) { string command = input.Consume(); simState.HandleInput(command, this); } messageBoard.Log(""); }
public override void Update(int deltaTime) { clockDisplay.Value = "Day: " + simulationDay + " " + actualTime.ToString("HH:mm"); workingBakers.Lines = writer.WorkingBakers(bakery); moneyDisplay.Value = bakery.currentMoney + " Schmeckles"; pantryDisplay.Value = ("Sugar: " + bakery.pantry["Sugar"] + " Egg: " + bakery.pantry["Egg"] + " Butter: " + bakery.pantry["Butter"]); if (generateCustomers) { actualTime = actualTime.AddMinutes(30); string newOrderString = bakery.GenerateNewOrder(actualTime); string orderCompleteString = bakery.CheckIfOrderIsComplete(actualTime, payments); string apprenticeUpgradeString = bakery.UpgradeApprentice(actualTime); if (newOrderString != "") { newOrdersLog.Log(newOrderString); } if (orderCompleteString != "") { completedOrdersLog.Log(orderCompleteString); } if (apprenticeUpgradeString != "") { logForBakeryRelatedUpdates.Log(apprenticeUpgradeString); } } //making sure that this runs even if month or year changes if (actualTime.Day > currentDay.Day || actualTime.Month > currentDay.Month || actualTime.Year > currentDay.Year) { bakery.currentMoney = (payments.PayRent(bakery.currentMoney)); bakery.currentMoney = (payments.PayBakers(bakery.currentMoney, bakery.listOfBakers)); logForBakeryRelatedUpdates.Log("Day " + simulationDay + ": " + "Rent paid!"); simulationDay++; currentDay = actualTime; } while (input.HasInput) { string commandInput = input.Consume(); ExecuteCommand(commandInput, this); } }
public override void Update(int deltaTime) { if (Action != "") { log.Log(Action); Action = ""; } actionsHeaderDisplay.Value = "Available Commands"; actionsDisplay.Lines = _state.Actions; clockDisplay.Value = DateTime.Now.ToString("HH:mm:ss"); updateDisplay.Value = "Update: " + gui.LastUpdateTime.Milliseconds; renderDisplay.Value = "Render: " + gui.BackBufferRenderTime.Milliseconds; printDisplay.Value = "Print: " + gui.ScreenRenderTime.Milliseconds; while (input.HasInput) { HandelInput(input.Consume().ToLower()); } }
public override void PassTime(int deltaTime) { StringBuilder sb = new StringBuilder(); while (_input.HasInput) { string input = _input.Consume(); ICommand command = _parser.ParseInputToCommand(input); _commandInvoker.SetCommand(command); _commandInvoker.Invoke(); } foreach (IAnimal animal in Zoo.GetAnimals()) { animal.Update(_gameTime); sb.AppendLine(animal.GetState()); _listWriter.Log(sb.ToString()); } Zoo.Account.WithdrawInterest(_gameTime); _gameTime = DateTime.Now; _clockWriter.Log(_gameTime.ToString("yyyy-MM-dd HH:mm:ss")); _moneyWriter.Log("Money: " + Zoo.Account.GetBalance() + "$"); _loanWriter.Log("Loan: " + Zoo.Account.GetLoan() + "$"); }
public override void PassTime(int deltaTime) { var count = 0; workers.Value = "Workers avaible for work (if skilled enough): " + ws.AvaibleWorkers; ammountOfWorkItems.Value = "Current ammount of vehicles in shop: " + ws.WorkItems.Count; if (ws.WorkItems.Count > 0) { if (ws.WorkItems.Count == 2) { worker3.Value = ""; } else if (ws.WorkItems.Count == 1) { worker2.Value = ""; } else if (ws.WorkItems.Count == 0) { worker1.Value = ""; } foreach (var item in ws.WorkItems.ToList()) { if (count == 0) { if (!item.Vehicle.IsRepaired) { worker1.Value = (item.DoWork()); if (item.Vehicle.IsRepaired) { log.Log(item.Customer.Name + "'s " + item.Vehicle.Manufacturer + " " + item.Vehicle.ModelYear + " " + "(" + item.Vehicle.LicensePlate.ToUpper() + ")" + " is repaired! Cost of parts: " + item.Invoice.PriceOfParts + ". Cost of work: " + item.Invoice.PriceOfWork + ". Total cost: " + item.Invoice.Total); } } } else if (count == 1) { if (!item.Vehicle.IsRepaired) { worker2.Value = (item.DoWork()); if (item.Vehicle.IsRepaired) { worker2.Value = (item.Invoice.Total + " price of parts: " + item.Invoice.PriceOfParts + " price of work: " + item.Invoice.PriceOfWork); } } } else if (count == 2) { if (!item.Vehicle.IsRepaired) { worker3.Value = (item.DoWork()); if (item.Vehicle.IsRepaired) { worker3.Value = (item.Invoice.Total + " price of parts: " + item.Invoice.PriceOfParts + " price of work: " + item.Invoice.PriceOfWork); } } } if (item.Employee != null) { count++; } } } while (input.HasInput) { var command = input.Consume(); log.Log("Input: " + command); HandleCommand(command); } }