public ItemPurchaseInformation(Event itemEvent, GameState gameState) { ItemId = itemEvent.ItemId; ItemBefore = itemEvent.ItemBefore; ItemAfter = itemEvent.ItemAfter; if (!itemEvent.EventType.HasValue) { throw new ArgumentException("Event type must not be null.", "itemEvent"); } EventType = itemEvent.EventType.Value; GameState = gameState.Clone(); }
/// <summary> /// Create a clone of the game state (always use this when storing a copy, as it will change during processing). /// </summary> /// <returns></returns> public GameState Clone() { GameState state = new GameState() { Timestamp = this.Timestamp }; foreach (var team in Teams) { state.Teams.Add(team.Key, team.Value.Clone()); } foreach (var participant in ParticipantMap) { state.ParticipantMap.Add(participant.Key, participant.Value); } return state; }