public void AddCards(IEnumerable <Card> cards, bool announce = true) { var enumerable = cards as Card[] ?? cards.ToArray(); foreach (var card in enumerable) { CardsInHand.Add(card); } // Before announcing, check if the new cards from a quartet. if (ProcessQuartets()) { announce = false; } OrderCardPositions(); if (!announce) { return; } // announce to the player all the new cards that were added. var cardList = new ServerStatusHandler.CardsReceiveInfo(enumerable.Select(x => x.ServerCard).ToArray()); var message = new ServerMessage <ServerStatusHandler.CardsReceiveInfo>(ServerToClientStatuses.GetCard, cardList); ConnectionInfo.Server.Send(message); }
public void RemoveCards(IEnumerable <Card> cards, bool announce = true) { var enumerable = cards as Card[] ?? cards.ToArray(); foreach (var card in enumerable) { int index = CardsInHand.FindIndex(x => x.ToString() == card.ToString()); CardsInHand.RemoveAt(index); } OrderCardPositions(); if (!announce) { return; } // Announce the removal of these cards var cardList = new ServerStatusHandler.CardsReceiveInfo(enumerable.Select(x => x.ServerCard).ToArray()); var message = new ServerMessage <ServerStatusHandler.CardsReceiveInfo>(ServerToClientStatuses.GiveCard, cardList); ConnectionInfo.Server.Send(message); }