private void updateViewParamsDelta(ArcologyState postExecState) { labelDeltaArcologyIntegrity.Text = Math.Round((postExecState.ArcologyIntegrity - currentState.ArcologyIntegrity), 2).ToString(); labelDeltaFoodQuantity.Text = Math.Round((postExecState.FoodQuantity - currentState.FoodQuantity), 2).ToString(); labelDeltaPopulation.Text = Math.Round((postExecState.Population - currentState.Population), 2).ToString(); labelDeltaProduction.Text = Math.Round((postExecState.Production - currentState.Production), 2).ToString(); labelDeltaSocialCapital.Text = Math.Round((postExecState.SocialCapital - currentState.SocialCapital), 2).ToString(); labelDeltaWaste.Text = Math.Round((postExecState.Waste - currentState.Waste), 2).ToString(); currentState = postExecState; }
public MainView(CommandExecutor commandExecutor, ArcStateReceiver arcStateReceiver, ReportWriter reporter) { InitializeComponent(); this.commandExecutor = commandExecutor; this.arcStateReceiver = arcStateReceiver; this.reporter = reporter; resetSimulation(); currentState = arcStateReceiver.GetState(); updateViewArcState(currentState); }
public void UpdateCurrentReport(ArcologyState state, string[] events, string actionPerformed) { StreamWriter file = new StreamWriter(pathToCurrentReport, true); file.WriteLine("========================================================================"); file.WriteLine(""); file.WriteLine($"Turn: [{state.Turn}] Action performed: [{actionPerformed}]"); file.WriteLine($"IsTerminated: [{state.IsTerminated}] Should restart: [{state.ShouldIRestartExperimentAndCry}]"); file.WriteLine(""); file.WriteLine(String.Format("{0,-18} [{1}]", "Total score:", state.TotalScore)); file.WriteLine(String.Format("{0,-18} [{1}]", "Experiment score:", state.ExperimentScore)); file.WriteLine(String.Format("{0,-18} [{1}]", "Event score:", state.EventScore));; file.WriteLine(""); file.WriteLine("State of archology: "); file.WriteLine(String.Format(" - {0,-20} {1}", "Food quantity:", state.FoodQuantity)); file.WriteLine(String.Format(" - {0,-20} {1}", "Food capacity:", state.FoodCapacity)); file.WriteLine(String.Format(" - {0,-20} {1}", "Waste:", state.Waste)); file.WriteLine(String.Format(" - {0,-20} {1}", "Social capital:", state.SocialCapital)); file.WriteLine(String.Format(" - {0,-20} {1}", "Production:", state.Production)); file.WriteLine(String.Format(" - {0,-20} {1}", "Arcology integrity:", state.ArcologyIntegrity)); file.WriteLine(String.Format(" - {0,-20} {1}", "Population:", state.Population)); file.WriteLine(String.Format(" - {0,-20} {1}", "Population capacity:", state.PopulationCapacity)); file.WriteLine(""); file.WriteLine("Resulted in events: "); foreach (var singleEvent in events) { file.WriteLine(" - " + singleEvent); } file.WriteLine(""); file.WriteLine("Neho runes: "); if (state.NehoRunes != null) { foreach (var rune in state.NehoRunes) { file.WriteLine($"[{rune}]"); } } file.WriteLine(""); file.Close(); }
private void updateViewArcState(ArcologyState arcState) { labelFoodQuantityVal.Text = Math.Round(arcState.FoodQuantity, 3).ToString(); labelFoodCapacityVal.Text = Math.Round(arcState.FoodCapacity, 2).ToString(); labelPopulationVal.Text = Math.Round(arcState.Population, 2).ToString(); labelPopulationCapacityVal.Text = Math.Round(arcState.PopulationCapacity, 2).ToString(); labelProductionVal.Text = Math.Round(arcState.Production, 2).ToString(); labelArcologyIntegrityVal.Text = Math.Round(arcState.ArcologyIntegrity, 2).ToString(); labelSocialCapitalVal.Text = Math.Round(arcState.SocialCapital, 2).ToString(); labelWasteVal.Text = Math.Round(arcState.Waste, 2).ToString(); labelTotalScoreVal.Text = Math.Round(arcState.TotalScore, 5).ToString(); labelExperimentScoreVal.Text = Math.Round(arcState.ExperimentScore, 5).ToString(); labelEventScoreVal.Text = Math.Round(arcState.EventScore, 5).ToString(); labelTurnVal.Text = arcState.Turn.ToString(); labelTerminatedVal.Text = arcState.IsTerminated.ToString(); labelShouldRestartVal.Text = arcState.ShouldIRestartExperimentAndCry.ToString(); listBoxRunes.DataSource = arcState.NehoRunes; listBoxAllEvents.DataSource = arcState.Events; listBoxPostExecutionEvents.DataSource = postExecutionEvents; eventsSoFar = arcState.Events.Count(); }
private string[] getPostExecutionEvents(ArcologyState arcState) { return(arcState.Events.Skip(eventsSoFar).ToArray <string>()); }
private void updateViewAfterExecuting(ArcologyState postExecState) { postExecutionEvents = getPostExecutionEvents(postExecState); updateViewArcState(postExecState); updateViewParamsDelta(postExecState); }