// Executes the end-of-turn processes related to the game, // such as resetting the active unit, incrementing the year, // and updating shields, gold, and other ResourceType for all // the cities in the game. private void DoTurn() { HistoryItem historyItem; foreach (Country colony in this.countries) { colony.DoTurn(); historyItem = new HistoryItem(); historyItem.Country = colony; historyItem.CulturePoints = colony.CulturePoints; historyItem.Power = colony.PowerFactor; historyItem.Score = colony.Score; historyItem.Year = this.year; this.history.AddHistoryItem(historyItem); colony.NotifyEndOfTurn = false; } //TODO: correctly increment year based on current year this.year++; OnTurnFinished(); }
/// <summary> /// Loads the history. /// </summary> /// <param name="reader"></param> public void Load(XmlReader reader) { if (reader == null) { throw new ArgumentNullException("reader"); } while (reader.Read()) { if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "History") { break; } if (reader.NodeType == XmlNodeType.Element && reader.Name == "HistoryItem") { HistoryItem item = new HistoryItem(); item.Load(reader); this.historyQueue.Enqueue(item); } } }
/// <summary> /// Adds a history item to the History of the game. /// </summary> /// <param name="item"></param> public void AddHistoryItem(HistoryItem item) { this.historyQueue.Enqueue(item); }