コード例 #1
0
ファイル: Player.cs プロジェクト: faiverAlb/russianCheckers
        private void NotificationFromDataAdapter(List <CheckerModel> added, List <CheckerModel> deleted, List <CheckerModel> modified)
        {
            var addedForPlayer = new List <CheckerModel>();

            foreach (var addedModel in added.Where(x => x.Side == Side))
            {
                PlayerPositions.Add(addedModel);
                addedForPlayer.Add(addedModel);
            }

            var deletedFromForPlayer = new List <CheckerModel>();

            foreach (var deletedModel in deleted.Where(x => x.Side == Side))
            {
                CheckerModel toRemove = PlayerPositions.Single(x => x.Column == deletedModel.Column && x.Row == deletedModel.Row);
                PlayerPositions.Remove(toRemove);
                deletedFromForPlayer.Add(toRemove);
            }

            modified = modified.Where(x => x.Side == Side).ToList();

            NotificationAction?.Invoke(addedForPlayer, deletedFromForPlayer, modified);
        }
コード例 #2
0
 public void AddPlayerPosition(IPlayer player)
 {
     PlayerPositions.Add(player);
 }