private List <GameCard> UpdateListAction(UpdateListParam updateListParam) { var list = Game.GetList(updateListParam.PlayerGuid, updateListParam.Kind).Cards; list.Clear(); foreach (var gameCard in updateListParam.Cards) { var card = Game.Cards.FirstOrDefault(x => x.CardId == gameCard.CardId); if (card != null) { list.Add(card); ChangeCardState(gameCard, updateListParam.Kind == ListType.Play); } } return(list); }
private void Timer_Elapsed(object sender, ElapsedEventArgs e) { foreach (var player in Game.Players) { var updateListParam = new UpdateListParam { PlayerGuid = player.PlayerGuid, Kind = ListType.Play, Cards = player.Play.Cards.Select(x => new ChangeCardParam() { CardId = x.CardId, CounterA = x.CounterA, CounterB = x.CounterB, IsDraggable = x.IsDraggable, IsFaceDown = x.IsFaceDown, IsMarked = x.IsMarked, Left = x.Left, Top = x.Top }).ToList() }; var gameAction = new GameAction { GameGuid = Game.Guid, PlayerGuid = player.PlayerGuid, ActionType = GameActionType.UpdateList, ActionData = JsonConvert.SerializeObject(updateListParam) }; GameRepository.PushGameAction(gameAction); } if (Game.StarTime.Add(AbsoluteTimeOut) < DateTime.Now) { GameRepository.DestroyGame(Game); } }