/// <summary> /// Applies an <see cref="IGameCommit{T}"/> to the current <see cref="State.GameState"/>. /// </summary> /// <param name="commit">The received <see cref="IGameCommit{T}"/> containing <see cref="IGameAction{T}"/>s to apply.</param> public void ApplyCommit(IGameCommit <T> commit) { foreach (var action in commit.GetActions()) { ActionsList.Add(action); if (action.CanUpdate(GameState)) { action.Update(GameState); } } }
/// <inheritdoc/> public JToken Convert(IGameCommit <T> item) { return(new JObject( new JProperty("type", "commit"), new JProperty("actions", item.GetActions().Select(a => ActionConverters.GetTo(a))))); }
/// <inheritdoc/> public override JToken WriteItem(IGameCommit <T> item) { return(ConverterContainer.Resolve <IToJsonConverter <IGameCommit <T> > >().GetTo(item)); }
/// <inheritdoc/> public bool CanConvert(IGameCommit <T> item) => true;